static private void add(DataStreamMarshaller dsm) { marshaller[dsm.getDataStructureType()] = dsm; }
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; } }
size += dsm.tightMarshal1(this, c, bs); size += bs.marshalledSize(); dsm.tightMarshal2(this, c, dataOut, bs); dsm.looseMarshal(this, c, looseOut);
public DataStructure looseUnmarshalNestedObject(DataInput dis) throws IOException { if (dis.readBoolean()) { byte dataType = dis.readByte(); DataStreamMarshaller dsm = dataMarshallers[dataType & 0xFF]; if (dsm == null) { throw new IOException("Unknown data type: " + dataType); } DataStructure data = dsm.createObject(); dsm.looseUnmarshal(this, data, dis); return data; } else { return null; } }
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; } }
/** * 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); } }
public void looseMarshalNestedObject(DataStructure o, DataOutput dataOut) throws IOException { dataOut.writeBoolean(o != null); if (o != null) { byte type = o.getDataStructureType(); dataOut.writeByte(type); DataStreamMarshaller dsm = dataMarshallers[type & 0xFF]; if (dsm == null) { throw new IOException("Unknown data type: " + type); } dsm.looseMarshal(this, o, dataOut); } }
public DataStructure looseUnmarshalNestedObject(DataInput dis) throws IOException { if (dis.readBoolean()) { byte dataType = dis.readByte(); DataStreamMarshaller dsm = dataMarshallers[dataType & 0xFF]; if (dsm == null) { throw new IOException("Unknown data type: " + dataType); } DataStructure data = dsm.createObject(); dsm.looseUnmarshal(this, data, dis); return data; } else { return null; } }
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; } }
public int tightMarshalNestedObject1(DataStructure o, BooleanStream bs) throws IOException { bs.writeBoolean(o != null); if (o == null) { return 0; } if (o.isMarshallAware()) { // MarshallAware ma = (MarshallAware)o; ByteSequence sequence = null; // sequence=ma.getCachedMarshalledForm(this); bs.writeBoolean(sequence != null); if (sequence != null) { return 1 + sequence.getLength(); } } byte type = o.getDataStructureType(); DataStreamMarshaller dsm = dataMarshallers[type & 0xFF]; if (dsm == null) { throw new IOException("Unknown data type: " + type); } return 1 + dsm.tightMarshal1(this, o, bs); }
public void tightMarshalNestedObject2(DataStructure o, DataOutput ds, BooleanStream bs) throws IOException { if (!bs.readBoolean()) { return; } byte type = o.getDataStructureType(); ds.writeByte(type); if (o.isMarshallAware() && bs.readBoolean()) { // We should not be doing any caching throw new IOException("Corrupted stream"); // MarshallAware ma = (MarshallAware) o; // ByteSequence sequence=ma.getCachedMarshalledForm(this); // ds.write(sequence.getData(), sequence.getOffset(), // sequence.getLength()); } else { DataStreamMarshaller dsm = dataMarshallers[type & 0xFF]; if (dsm == null) { throw new IOException("Unknown data type: " + type); } dsm.tightMarshal2(this, o, ds, bs); } }
public void looseMarshalNestedObject(DataStructure o, DataOutput dataOut) throws IOException { dataOut.writeBoolean(o != null); if (o != null) { byte type = o.getDataStructureType(); dataOut.writeByte(type); DataStreamMarshaller dsm = dataMarshallers[type & 0xFF]; if (dsm == null) { throw new IOException("Unknown data type: " + type); } dsm.looseMarshal(this, o, dataOut); } }
size += dsm.tightMarshal1(this, c, bs); size += bs.marshalledSize(); dsm.tightMarshal2(this, c, bytesOut, bs); sequence = bytesOut.toByteSequence(); dsm.looseMarshal(this, c, bytesOut); sequence = bytesOut.toByteSequence();
static private void add(DataStreamMarshaller dsm) { marshaller[dsm.getDataStructureType()] = dsm; }
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; } }
public DataStructure looseUnmarshalNestedObject(DataInput dis) throws IOException { if (dis.readBoolean()) { byte dataType = dis.readByte(); DataStreamMarshaller dsm = dataMarshallers[dataType & 0xFF]; if (dsm == null) { throw new IOException("Unknown data type: " + dataType); } DataStructure data = dsm.createObject(); dsm.looseUnmarshal(this, data, dis); return data; } else { return null; } }
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; } }
/** * 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); } }