private static int readDSFIDHeader(final DataInput in, DSCODE dscode) throws IOException { switch (dscode) { case DS_FIXED_ID_BYTE: return in.readByte(); case DS_FIXED_ID_SHORT: return in.readShort(); case DS_FIXED_ID_INT: return in.readInt(); default: throw new IllegalStateException("unexpected byte: " + dscode + " while reading dsfid"); } }
protected long readId(DataInput in, byte idType) throws IOException { switch (idType) { case ID_ONE_BYTE: return in.readByte() - Byte.MIN_VALUE; case ID_TWO_BYTES: return in.readShort() - Short.MIN_VALUE; case ID_FOUR_BYTES: return in.readInt() - Integer.MIN_VALUE; case ID_EIGHT_BYTES: return in.readLong() - Long.MIN_VALUE; default: throw new Error("Unknown idType " + idType); } }
public long tightUnmarshalLong(OpenWireFormat wireFormat, DataInput dataIn, BooleanStream bs) throws IOException { if (bs.readBoolean()) { if (bs.readBoolean()) { return dataIn.readLong(); } else { return toLong(dataIn.readInt()); } } else { if (bs.readBoolean()) { return toLong(dataIn.readShort()); } else { return 0; } } }
/** * Fill out this instance of the message using the <code>DataInput</code> Required to be a * {@link org.apache.geode.DataSerializable}Note: must be symmetric with * {@link #toData(DataOutput)}in what it reads */ @Override public void fromData(DataInput in) throws IOException, ClassNotFoundException { super.fromData(in); this.flags = in.readShort(); setBooleans(this.flags, in); this.regionId = in.readInt(); // extra field post 9.0 if (InternalDataSerializer.getVersionForDataStream(in).compareTo(Version.GFE_90) >= 0) { this.isTransactionDistributed = in.readBoolean(); } }
public void readFrom(DataInput in) throws Exception { type=in.readByte(); switch(type) { case DATA: seqno=Bits.readLong(in); conn_id=in.readShort(); first=in.readBoolean(); break; case ACK: seqno=Bits.readLong(in); conn_id=in.readShort(); timestamp=Bits.readInt(in); break; case SEND_FIRST_SEQNO: timestamp=Bits.readInt(in); break; case XMIT_REQ: break; case CLOSE: conn_id=in.readShort(); break; } } }
info.setBrowser(bs.readBoolean()); info.setDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); info.setPrefetchSize(dataIn.readInt()); info.setMaximumPendingMessageLimit(dataIn.readInt()); info.setDispatchAsync(bs.readBoolean()); info.setSelector(tightUnmarshalString(dataIn, bs)); info.setClientId(tightUnmarshalString(dataIn, bs)); info.setSubscriptionName(tightUnmarshalString(dataIn, bs)); info.setNoLocal(bs.readBoolean()); info.setExclusive(bs.readBoolean()); info.setRetroactive(bs.readBoolean()); info.setPriority(dataIn.readByte()); if (bs.readBoolean()) { short size = dataIn.readShort(); org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size]; for( int i=0; i < size; i++ ) { if (bs.readBoolean()) { short size = dataIn.readShort(); org.apache.activemq.command.ConsumerId value[] = new org.apache.activemq.command.ConsumerId[size]; for( int i=0; i < size; i++ ) {
public void readFrom(DataInput in) throws Exception { // 1. read the leading byte first byte leading=in.readByte(); // 2. the flags flags=in.readShort(); // 3. dest_addr if(Util.isFlagSet(leading, DEST_SET)) dest_addr=Util.readAddress(in); // 4. src_addr if(Util.isFlagSet(leading, SRC_SET)) src_addr=Util.readAddress(in); // 5. headers int len=in.readShort(); this.headers=createHeaders(len); for(int i=0; i < len; i++) { short id=in.readShort(); Header hdr=readHeader(in).setProtId(id); this.headers[i]=hdr; } // 6. buf if(Util.isFlagSet(leading, BUF_SET)) { len=in.readInt(); buf=new byte[len]; in.readFully(buf, 0, len); length=len; } }
@SuppressWarnings("deprecation") protected String tightUnmarshalString(DataInput dataIn, BooleanStream bs) throws IOException { if (bs.readBoolean()) { if (bs.readBoolean()) { int size = dataIn.readShort(); byte data[] = new byte[size]; dataIn.readFully(data); // Yes deprecated, but we know what we are doing. // This allows us to create a String from a ASCII byte array. (no UTF-8 decoding) return new String(data, 0); } else { return dataIn.readUTF(); } } else { return null; } }
/** * Un-marshal an object instance from the data input stream * * @param o the object to un-marshal * @param dataIn the data input stream to build the object from * @throws IOException */ public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { super.tightUnmarshal(wireFormat, o, dataIn, bs); DestinationInfo info = (DestinationInfo)o; info.setConnectionId((org.apache.activemq.command.ConnectionId) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); info.setDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); info.setOperationType(dataIn.readByte()); info.setTimeout(tightUnmarshalLong(wireFormat, dataIn, bs)); if (bs.readBoolean()) { short size = dataIn.readShort(); org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size]; for( int i=0; i < size; i++ ) { value[i] = (org.apache.activemq.command.BrokerId) tightUnmarsalNestedObject(wireFormat,dataIn, bs); } info.setBrokerPath(value); } else { info.setBrokerPath(null); } }
/** * Fill out this instance of the message using the <code>DataInput</code> Required to be a * {@link org.apache.geode.DataSerializable}Note: must be symmetric with * {@link #toData(DataOutput)}in what it reads */ @Override public void fromData(DataInput in) throws IOException, ClassNotFoundException { super.fromData(in); this.flags = in.readShort(); setFlags(this.flags, in); this.regionPath = DataSerializer.readString(in); this.isTransactionDistributed = in.readBoolean(); }
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(); }
/** * Un-marshal an object instance from the data input stream * * @param o the object to un-marshal * @param dataIn the data input stream to build the object from * @throws IOException */ public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException { super.tightUnmarshal(wireFormat, o, dataIn, bs); ProducerInfo info = (ProducerInfo)o; info.setProducerId((org.apache.activemq.command.ProducerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); info.setDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalCachedObject(wireFormat, dataIn, bs)); if (bs.readBoolean()) { short size = dataIn.readShort(); org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size]; for( int i=0; i < size; i++ ) { value[i] = (org.apache.activemq.command.BrokerId) tightUnmarsalNestedObject(wireFormat,dataIn, bs); } info.setBrokerPath(value); } else { info.setBrokerPath(null); } info.setDispatchAsync(bs.readBoolean()); info.setWindowSize(dataIn.readInt()); }
private AnnotationHolder readAnnotation(DataInput input) throws IOException { AnnotationHolder annotation = new AnnotationHolder(symbolTable.at(input.readInt())); int valueCount = input.readShort(); for (int i = 0; i < valueCount; ++i) { String name = symbolTable.at(input.readInt()); AnnotationValue value = readAnnotationValue(input); annotation.getValues().put(name, value); } return annotation; }
protected DataStructure tightUnmarsalCachedObject(OpenWireFormat wireFormat, DataInput dataIn, BooleanStream bs) throws IOException { if (wireFormat.isCacheEnabled()) { if (bs.readBoolean()) { short index = dataIn.readShort(); DataStructure object = wireFormat.tightUnmarshalNestedObject(dataIn, bs); wireFormat.setInUnmarshallCache(index, object); return object; } else { short index = dataIn.readShort(); return wireFormat.getFromUnmarshallCache(index); } } else { return wireFormat.tightUnmarshalNestedObject(dataIn, bs); } }
/** * read the bits from an input stream * * @param dataIn * @throws IOException */ public void readFromStream(DataInput dataIn) throws IOException { length = dataIn.readByte(); if (length <= BYTE_SIZE) { bits = dataIn.readByte(); } else if (length <= SHORT_SIZE) { bits = dataIn.readShort(); } else if (length <= INT_SIZE) { bits = dataIn.readInt(); } else { bits = dataIn.readLong(); } } }
public long tightUnmarshalLong(OpenWireFormat wireFormat, DataInput dataIn, BooleanStream bs) throws IOException { if (bs.readBoolean()) { if (bs.readBoolean()) { return dataIn.readLong(); } else { return toLong(dataIn.readInt()); } } else { if (bs.readBoolean()) { return toLong(dataIn.readShort()); } else { return 0; } } }
/** * Un-marshal an object instance from the data input stream * * @param o the object to un-marshal * @param dataIn the data input stream to build the object from * @throws IOException */ public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { super.looseUnmarshal(wireFormat, o, dataIn); ProducerInfo info = (ProducerInfo)o; info.setProducerId((org.apache.activemq.command.ProducerId) looseUnmarsalCachedObject(wireFormat, dataIn)); info.setDestination((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalCachedObject(wireFormat, dataIn)); if (dataIn.readBoolean()) { short size = dataIn.readShort(); org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size]; for( int i=0; i < size; i++ ) { value[i] = (org.apache.activemq.command.BrokerId) looseUnmarsalNestedObject(wireFormat,dataIn); } info.setBrokerPath(value); } else { info.setBrokerPath(null); } info.setDispatchAsync(dataIn.readBoolean()); info.setWindowSize(dataIn.readInt()); }
/** * Un-marshal an object instance from the data input stream * * @param o the object to un-marshal * @param dataIn the data input stream to build the object from * @throws IOException */ public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException { super.looseUnmarshal(wireFormat, o, dataIn); DestinationInfo info = (DestinationInfo)o; info.setConnectionId((org.apache.activemq.command.ConnectionId) looseUnmarsalCachedObject(wireFormat, dataIn)); info.setDestination((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalCachedObject(wireFormat, dataIn)); info.setOperationType(dataIn.readByte()); info.setTimeout(looseUnmarshalLong(wireFormat, dataIn)); if (dataIn.readBoolean()) { short size = dataIn.readShort(); org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size]; for( int i=0; i < size; i++ ) { value[i] = (org.apache.activemq.command.BrokerId) looseUnmarsalNestedObject(wireFormat,dataIn); } info.setBrokerPath(value); } else { info.setBrokerPath(null); } }