public DataStructure tightUnmarshalNestedObject(DataInput dis, BooleanStream bs) throws IOException { if (bs.readBoolean()) { byte dataType = dis.readByte(); DataStreamMarshaller dsm = dataMarshallers[dataType & 0xFF]; if (dsm == null) { throw new IOException("Unknown data type: " + dataType); } DataStructure data = dsm.createObject(); if (data.isMarshallAware() && bs.readBoolean()) { dis.readInt(); dis.readByte(); BooleanStream bs2 = new BooleanStream(); bs2.unmarshal(dis); dsm.tightUnmarshal(this, data, dis, bs2); // TODO: extract the sequence from the dis and associate it. // MarshallAware ma = (MarshallAware)data // ma.setCachedMarshalledForm(this, sequence); } else { dsm.tightUnmarshal(this, data, dis, bs); } return data; } else { return null; } }
protected int tightMarshalByteArray1(byte[] data, BooleanStream bs) throws IOException { bs.writeBoolean(data != null); if (data != null) { return data.length + 4; } else { return 0; } }
public void unmarshal(DataInput dataIn) throws IOException { arrayLimit = (short)(dataIn.readByte() & 0xFF); if (arrayLimit == 0xC0) { arrayLimit = (short)(dataIn.readByte() & 0xFF); } else if (arrayLimit == 0x80) { arrayLimit = dataIn.readShort(); } if (data.length < arrayLimit) { data = new byte[arrayLimit]; } dataIn.readFully(data, 0, arrayLimit); clear(); }
public Object doUnmarshal(DataInput dis) throws IOException { byte dataType = dis.readByte(); if (dataType != NULL_TYPE) { DataStreamMarshaller dsm = dataMarshallers[dataType & 0xFF]; if (dsm == null) { throw new IOException("Unknown data type: " + dataType); } Object data = dsm.createObject(); if (this.tightEncodingEnabled) { BooleanStream bs = new BooleanStream(); bs.unmarshal(dis); dsm.tightUnmarshal(this, data, dis, bs); } else { dsm.looseUnmarshal(this, data, dis); } return data; } else { return null; } }
bs = new BooleanStream(); bs.writeBoolean(true); // the partial data byte[] is chunkSize -= bs.marshalledSize(); } else { chunkSize -= 1; bs.marshal(writeBuffer);
BooleanStream bs = new BooleanStream(); size += dsm.tightMarshal1(this, c, bs); size += bs.marshalledSize(); bs.marshal(dataOut); dsm.tightMarshal2(this, c, dataOut, bs);
protected byte[] tightUnmarshalByteArray(DataInput dataIn, BooleanStream bs) throws IOException { byte rc[] = null; if (bs.readBoolean()) { int size = dataIn.readInt(); rc = new byte[size]; dataIn.readFully(rc); } return rc; }
/** * Used by NIO or AIO transports */ public int tightMarshal1(Object o, BooleanStream bs) throws IOException { int size = 1; if (o != null) { DataStructure c = (DataStructure)o; byte type = c.getDataStructureType(); DataStreamMarshaller dsm = dataMarshallers[type & 0xFF]; if (dsm == null) { throw new IOException("Unknown data type: " + type); } size += dsm.tightMarshal1(this, c, bs); size += bs.marshalledSize(); } return size; }
/** * Used by NIO or AIO transports; note that the size is not written as part * of this method. */ public void tightMarshal2(Object o, DataOutput ds, BooleanStream bs) throws IOException { if (cacheEnabled) { runMarshallCacheEvictionSweep(); } if (o != null) { DataStructure c = (DataStructure)o; byte type = c.getDataStructureType(); DataStreamMarshaller dsm = dataMarshallers[type & 0xFF]; if (dsm == null) { throw new IOException("Unknown data type: " + type); } ds.writeByte(type); bs.marshal(ds); dsm.tightMarshal2(this, c, ds, bs); } }
bs = new BooleanStream(); bs.writeBoolean(true); // the partial data byte[] is chunkSize -= bs.marshalledSize(); } else { chunkSize -= 1; bs.marshal(dataOut);
BooleanStream bs = new BooleanStream(); size += dsm.tightMarshal1(this, c, bs); size += bs.marshalledSize(); bs.marshal(bytesOut); dsm.tightMarshal2(this, c, bytesOut, bs); sequence = bytesOut.toByteSequence();
protected byte[] tightUnmarshalByteArray(DataInput dataIn, BooleanStream bs) throws IOException { byte rc[] = null; if (bs.readBoolean()) { int size = dataIn.readInt(); rc = new byte[size]; dataIn.readFully(rc); } return rc; }
public Object doUnmarshal(DataInput dis) throws IOException { byte dataType = dis.readByte(); if (dataType != NULL_TYPE) { DataStreamMarshaller dsm = dataMarshallers[dataType & 0xFF]; if (dsm == null) { throw new IOException("Unknown data type: " + dataType); } Object data = dsm.createObject(); if (this.tightEncodingEnabled) { BooleanStream bs = new BooleanStream(); bs.unmarshal(dis); dsm.tightUnmarshal(this, data, dis, bs); } else { dsm.looseUnmarshal(this, data, dis); } return data; } else { return null; } }
/** * Used by NIO or AIO transports */ public int tightMarshal1(Object o, BooleanStream bs) throws IOException { int size = 1; if (o != null) { DataStructure c = (DataStructure)o; byte type = c.getDataStructureType(); DataStreamMarshaller dsm = dataMarshallers[type & 0xFF]; if (dsm == null) { throw new IOException("Unknown data type: " + type); } size += dsm.tightMarshal1(this, c, bs); size += bs.marshalledSize(); } return size; }
/** * Used by NIO or AIO transports; note that the size is not written as part * of this method. */ public void tightMarshal2(Object o, DataOutput ds, BooleanStream bs) throws IOException { if (cacheEnabled) { runMarshallCacheEvictionSweep(); } if (o != null) { DataStructure c = (DataStructure)o; byte type = c.getDataStructureType(); DataStreamMarshaller dsm = dataMarshallers[type & 0xFF]; if (dsm == null) { throw new IOException("Unknown data type: " + type); } ds.writeByte(type); bs.marshal(ds); dsm.tightMarshal2(this, c, ds, bs); } }
bs = new BooleanStream(); bs.writeBoolean(true); // the partial data byte[] is chunkSize -= bs.marshalledSize(); } else { chunkSize -= 1; bs.marshal(writeBuffer);
BooleanStream bs = new BooleanStream(); size += dsm.tightMarshal1(this, c, bs); size += bs.marshalledSize(); bs.marshal(dataOut); dsm.tightMarshal2(this, c, dataOut, bs);
public DataStructure tightUnmarshalNestedObject(DataInput dis, BooleanStream bs) throws IOException { if (bs.readBoolean()) { byte dataType = dis.readByte(); DataStreamMarshaller dsm = dataMarshallers[dataType & 0xFF]; if (dsm == null) { throw new IOException("Unknown data type: " + dataType); } DataStructure data = dsm.createObject(); if (data.isMarshallAware() && bs.readBoolean()) { dis.readInt(); dis.readByte(); BooleanStream bs2 = new BooleanStream(); bs2.unmarshal(dis); dsm.tightUnmarshal(this, data, dis, bs2); // TODO: extract the sequence from the dis and associate it. // MarshallAware ma = (MarshallAware)data // ma.setCachedMarshalledForm(this, sequence); } else { dsm.tightUnmarshal(this, data, dis, bs); } return data; } else { return null; } }
protected int tightMarshalByteArray1(byte[] data, BooleanStream bs) throws IOException { bs.writeBoolean(data != null); if (data != null) { return data.length + 4; } else { return 0; } }
protected void tightMarshalByteArray2(byte[] data, DataOutput dataOut, BooleanStream bs) throws IOException { if (bs.readBoolean()) { dataOut.writeInt(data.length); dataOut.write(data); } }