/** * Deserializes the input parameter and returns an Object which must then be cast to a core data * type * * @param <T> type * @param in input * @param target target * @return Object object */ @SuppressWarnings("unchecked") public <T> T deserialize(Input in, Type target) { byte type = in.readDataType(); log.debug("Type: {}", type); while (type == DataTypes.CORE_SKIP) { type = in.readDataType(); log.debug("Type (skip): {}", type); } log.debug("Datatype: {}", DataTypes.toStringValue(type)); Object result; switch (type) { case DataTypes.CORE_NULL: result = in.readNull(target); break; case DataTypes.CORE_BOOLEAN: result = in.readBoolean(target); break; case DataTypes.CORE_NUMBER: result = in.readNumber(target); break; case DataTypes.CORE_STRING: result = in.readString(target); break; case DataTypes.CORE_DATE: result = in.readDate(target); break; case DataTypes.CORE_ARRAY: result = in.readArray(this, target); break; case DataTypes.CORE_MAP: result = in.readMap(this, target); break; case DataTypes.CORE_XML: result = in.readXML(target); break; case DataTypes.CORE_OBJECT: result = in.readObject(this, target); break; case DataTypes.CORE_BYTEARRAY: result = in.readByteArray(target); break; case DataTypes.OPT_REFERENCE: result = in.readReference(target); break; default: result = in.readCustom(target); break; } return (T) postProcessExtension(result, target); }
/** * Deserializes the input parameter and returns an Object which must then be cast to a core data * type * * @param in * @param target * @return Object */ public <T> T deserialize(Input in, Class<T> target) { byte type = in.readDataType(); while (type == DataTypes.CORE_SKIP) { type = in.readDataType(); } if (log.isDebugEnabled()) { log.debug("Datatype: " + DataTypes.toStringValue(type)); } Object result; switch (type) { case DataTypes.CORE_NULL: result = in.readNull(); break; case DataTypes.CORE_BOOLEAN: result = in.readBoolean(); break; case DataTypes.CORE_NUMBER: result = in.readNumber(); break; case DataTypes.CORE_STRING: result = in.readString(); break; case DataTypes.CORE_DATE: result = in.readDate(); break; case DataTypes.CORE_ARRAY: result = in.readArray(this); break; case DataTypes.CORE_MAP: result = in.readMap(this); break; case DataTypes.CORE_XML: result = in.readXML(); break; case DataTypes.CORE_OBJECT: result = in.readObject(this); break; case DataTypes.CORE_BYTEARRAY: result = in.readByteArray(); break; case DataTypes.OPT_REFERENCE: result = in.readReference(); break; default: result = in.readCustom(); break; } return (T) postProcessExtension(result, target); }
public void mergeFrom(Input input, Foo message) throws IOException { for (int number = input.readFieldNumber(this); ; number = input.readFieldNumber(this)) { switch (number) { case 0: return; case 1: if (message.someInt == null) message.someInt = new ArrayList<Integer>(); message.someInt.add(input.readInt32()); break; case 2: if (message.someString == null) message.someString = new ArrayList<String>(); message.someString.add(input.readString()); break; case 3: if (message.someBar == null) message.someBar = new ArrayList<Bar>(); message.someBar.add(input.mergeObject(null, Bar.getSchema())); break; case 4: if (message.someEnum == null) message.someEnum = new ArrayList<EnumSample>(); message.someEnum.add(EnumSample.valueOf(input.readEnum())); break; case 5: if (message.someBytes == null) message.someBytes = new ArrayList<ByteString>(); message.someBytes.add(input.readBytes()); break; case 6: if (message.someBoolean == null) message.someBoolean = new ArrayList<Boolean>(); message.someBoolean.add(input.readBool()); break; case 7: if (message.someFloat == null) message.someFloat = new ArrayList<Float>(); message.someFloat.add(input.readFloat()); break; case 8: if (message.someDouble == null) message.someDouble = new ArrayList<Double>(); message.someDouble.add(input.readDouble()); break; case 9: if (message.someLong == null) message.someLong = new ArrayList<Long>(); message.someLong.add(input.readInt64()); break; default: input.handleUnknownField(number, this); } } }