Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
private int __id = -1;
private final static net.sourceforge.floggy.persistence.PersistableMetadata __persistableMetadata = new net.sourceforge.floggy.persistence.PersistableMetadata("PersonArray264188287");
public net.sourceforge.floggy.persistence.PersistableMetadata __getPersistableMetadata() {
    return __persistableMetadata;
}
public void __load(byte[] buffer) throws java.lang.Exception {
    java.io.ByteArrayInputStream bais = new java.io.ByteArrayInputStream(buffer);
    java.io.DataInputStream dis = new java.io.DataInputStream(bais);
    if(dis.readByte() == 0) {
        int count = dis.readInt();
        this.age = new int[count];
        for(int n = 0; n < count; n++) {
            this.age[n] = dis.readInt();
        }
    }
    else {
        age = null;
    }
    if(dis.readByte() == 0) {
        int count = dis.readInt();
        this.name = new java.lang.String[count];
        for(int o = 0; o < count; o++) {
            if(dis.readByte() == 0) {
                this.name[o] = dis.readUTF();
            }
            else {
                this.name[o] = null;
            }
        }
    }
    else {
        name = null;
    }
    if(dis.readByte() == 0) {
        int count = dis.readInt();
        this.x = new net.sourceforge.floggy.persistence.beans.Person[count];
        for(int p = 0; p < count; p++) {
            if(dis.readByte() == 0) {
                net.sourceforge.floggy.persistence.internal.__Persistable someClass = new net.sourceforge.floggy.persistence.beans.Person();
                someClass.__load(dis.readInt());
                this.x[p] = someClass;
            }
            else {
                this.x[p] = null;
            }
        }
    }
    else {
        x = null;
    }
    dis.close();
}
public void __load(int id) throws java.lang.Exception {
    javax.microedition.rms.RecordStore rs = net.sourceforge.floggy.persistence.PersistableManager.getRecordStore(__persistableMetadata);
    byte[] buffer = rs.getRecord(id);
    rs.closeRecordStore();
    this.__load(buffer);
    this.__id = id;
}
public int __save() throws java.lang.Exception {
    java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
    java.io.DataOutputStream dos = new java.io.DataOutputStream(baos);
    javax.microedition.rms.RecordStore rs = net.sourceforge.floggy.persistence.PersistableManager.getRecordStore(__persistableMetadata);
    if(this.age == null) {
        dos.writeByte(1);
    }
    else {
        dos.writeByte(0);
        int count = this.age.length;
        dos.writeInt(count);
        for(int q = 0; q < count; q++) {
            dos.writeInt(this.age[q]);
        }
    }
    if(this.name == null) {
        dos.writeByte(1);
    }
    else {
        dos.writeByte(0);
        int count = this.name.length;
        dos.writeInt(count);
        for(int r = 0; r < count; r++) {
            if(this.name[r] == null) {
                dos.writeByte(1);
            }
            else {
                dos.writeByte(0);
                dos.writeUTF(this.name[r]);
            }
        }
    }
    if(this.x == null) {
        dos.writeByte(1);
    }
    else {
        dos.writeByte(0);
        int count = this.x.length;
        dos.writeInt(count);
        for(int s = 0; s < count; s++) {
            if(this.x[s] == null) {
                dos.writeByte(1);
            }
            else {
                dos.writeByte(0);
                dos.writeInt(((net.sourceforge.floggy.persistence.internal.__Persistable) this.x[s]).__save());
            }
        }
    }
    if(this.__id == -1) {
        this.__id = rs.addRecord(baos.toByteArray(), 0, baos.size());
    }
    else {
        rs.setRecord(this.__id, baos.toByteArray(), 0, baos.size());
    }
    rs.closeRecordStore();
    dos.close();
    return this.__id;
}
public void __delete() throws java.lang.Exception {
    if (this.__id != -1) {
        javax.microedition.rms.RecordStore rs = net.sourceforge.floggy.persistence.PersistableManager.getRecordStore(__persistableMetadata);
        rs.deleteRecord(this.__id);
        rs.closeRecordStore();
    }
}
New to GrepCode? Check out our FAQ X