Java Code Examples for io.protostuff.Input#mergeObject()
The following examples show how to use
io.protostuff.Input#mergeObject() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocalDateTimeSchema.java From joyrpc with Apache License 2.0 | 6 votes |
@Override public void mergeFrom(final Input input, final LocalDateTime message) throws IOException { while (true) { int number = input.readFieldNumber(this); switch (number) { case 0: return; case 1: LocalDate localDate = LocalDate.now(); input.mergeObject(localDate, LocalDateSchema.INSTANCE); setValue(FIELD_DATE, message, localDate); break; case 2: LocalTime localTime = LocalTime.now(); input.mergeObject(localTime, LocalTimeSchema.INSTANCE); setValue(FIELD_TIME, message, localTime); break; default: input.handleUnknownField(number, this); } } }
Example 2
Source File: OffsetDateTimeSchema.java From joyrpc with Apache License 2.0 | 6 votes |
@Override public void mergeFrom(final Input input, final OffsetDateTime message) throws IOException { while (true) { int number = input.readFieldNumber(this); switch (number) { case 0: return; case 1: LocalDateTime localDateTime = LocalDateTime.now(); input.mergeObject(localDateTime, LocalDateTimeSchema.INSTANCE); setValue(FIELD_DATE_TIME, message, localDateTime); break; case 2: //不能使用0,0会缓存结果对象 ZoneOffset offset = ZoneOffset.ofTotalSeconds(1); input.mergeObject(offset, ZoneOffsetSchema.INSTANCE); setValue(FIELD_ZONE_OFFSET, message, offset); break; default: input.handleUnknownField(number, this); } } }
Example 3
Source File: OffsetTimeSchema.java From joyrpc with Apache License 2.0 | 6 votes |
@Override public void mergeFrom(final Input input, final OffsetTime message) throws IOException { while (true) { int number = input.readFieldNumber(this); switch (number) { case 0: return; case 1: LocalTime localTime = LocalTime.now(); input.mergeObject(localTime, LocalTimeSchema.INSTANCE); setValue(FIELD_TIME, message, localTime); break; case 2: //不能使用0,0会缓存结果对象 ZoneOffset offset = ZoneOffset.ofTotalSeconds(1); input.mergeObject(offset, ZoneOffsetSchema.INSTANCE); setValue(FIELD_OFFSET, message, offset); break; default: input.handleUnknownField(number, this); } } }
Example 4
Source File: SimpleEvent.java From datawave with Apache License 2.0 | 6 votes |
public void mergeFrom(Input input, SimpleEvent message) throws IOException { int number; while ((number = input.readFieldNumber(this)) != 0) { switch (number) { case 1: message.metadata = input.mergeObject(null, Metadata.getSchema()); break; case 2: if (message.fields == null) message.fields = new ArrayList<>(); SimpleField f = input.mergeObject(null, SimpleField.getSchema()); message.fields.add(f); break; case 3: if (message.markings == null) message.markings = Maps.newHashMap(); input.mergeObject(message.markings, MapSchema.SCHEMA); default: input.handleUnknownField(number, this); break; } } }
Example 5
Source File: DefaultFacets.java From datawave with Apache License 2.0 | 6 votes |
public void mergeFrom(Input input, DefaultFacets message) throws IOException { int number; while ((number = input.readFieldNumber(this)) != 0) { switch (number) { case 1: if (message.fields == null) message.fields = new ArrayList<FieldCardinalityBase>(); DefaultFieldCardinality f = input.mergeObject(null, DefaultFieldCardinality.getSchema()); message.fields.add(f); break; default: input.handleUnknownField(number, this); break; } } }
Example 6
Source File: AbstractRuntimeObjectSchemaTest.java From protostuff with Apache License 2.0 | 5 votes |
@Override public AbstractCollection<T> readFrom(Input input) throws IOException { ArrayList<T> list = new ArrayList<T>(); input.mergeObject(list, schema); return new ImmutableList<T>(list); }
Example 7
Source File: ZonedDateTimeSchema.java From joyrpc with Apache License 2.0 | 5 votes |
@Override public void mergeFrom(final Input input, final ZonedDateTime message) throws IOException { while (true) { int number = input.readFieldNumber(this); switch (number) { case 0: return; case 1: LocalDateTime localDateTime = LocalDateTime.now(); input.mergeObject(localDateTime, LocalDateTimeSchema.INSTANCE); setValue(FIELD_DATE_TIME, message, localDateTime); break; case 2: //不能使用0,0会缓存结果对象 ZoneOffset offset = ZoneOffset.ofTotalSeconds(1); input.mergeObject(offset, ZoneOffsetSchema.INSTANCE); setValue(FIELD_ZONE_OFFSET, message, offset); break; case 3: ZoneId zoneId = ZoneId.of("America/New_York"); input.mergeObject(zoneId, ZoneIdSchema.INSTANCE); setValue(FIELD_ZONE_ID, message, zoneId); break; default: input.handleUnknownField(number, this); } } }
Example 8
Source File: AbstractRuntimeObjectSchemaTest.java From protostuff with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Override public AbstractCollection<T> readFrom(Input input) throws IOException { ArrayList<T> list = new ArrayList<T>(); input.mergeObject(list, schema); HashMap<T, Object> map = new HashMap<T, Object>(); for (T t : list) map.put(t, null); return (AbstractCollection<T>) map.keySet(); }
Example 9
Source File: PolymorphicMapSchema.java From protostuff with Apache License 2.0 | 5 votes |
private static Object readSynchronizedMapFrom(Input input, Schema<?> schema, Object owner, IdStrategy strategy, boolean graph, Object map, boolean sm) throws IOException { if (graph) { // update the actual reference. ((GraphInput) input).updateLast(map, owner); } final Wrapper wrapper = new Wrapper(); Object m = input.mergeObject(wrapper, strategy.POLYMORPHIC_MAP_SCHEMA); if (!graph || !((GraphInput) input).isCurrentMessageReference()) m = wrapper.value; try { fSynchronizedMap_m.set(map, m); fSynchronizedMap_mutex.set(map, map); if (sm) fSynchronizedSortedMap_sm.set(map, m); } catch (Exception e) { throw new RuntimeException(e); } return map; }
Example 10
Source File: PolymorphicMapSchema.java From protostuff with Apache License 2.0 | 5 votes |
private static Object readUnmodifiableMapFrom(Input input, Schema<?> schema, Object owner, IdStrategy strategy, boolean graph, Object map, boolean sm) throws IOException { if (graph) { // update the actual reference. ((GraphInput) input).updateLast(map, owner); } final Wrapper wrapper = new Wrapper(); Object m = input.mergeObject(wrapper, strategy.POLYMORPHIC_MAP_SCHEMA); if (!graph || !((GraphInput) input).isCurrentMessageReference()) m = wrapper.value; try { fUnmodifiableMap_m.set(map, m); if (sm) fUnmodifiableSortedMap_sm.set(map, m); } catch (Exception e) { throw new RuntimeException(e); } return map; }
Example 11
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 5 votes |
@Override public Object readFrom(Input input, Object owner) throws IOException { if (ID_ARRAY_LEN != input.readFieldNumber(this)) throw new ProtostuffException("Corrupt input."); final int len = input.readInt32(); Object[] array = (Object[])Array.newInstance(hs.getSchema().typeClass(), len); if (input instanceof GraphInput) { // update the actual reference. ((GraphInput) input).updateLast(array, owner); } for (int i = 0; i < len;) { switch (input.readFieldNumber(this)) { case ID_ARRAY_DATA: array[i++] = input.mergeObject(null, hs.getSchema()); break; case ID_ARRAY_NULLCOUNT: i += input.readUInt32(); break; default: throw new ProtostuffException("Corrupt input."); } } if (0 != input.readFieldNumber(this)) throw new ProtostuffException("Corrupt input."); return array; }
Example 12
Source File: PolymorphicCollectionSchema.java From protostuff with Apache License 2.0 | 5 votes |
private static Object readCheckedCollectionFrom(Input input, Schema<?> schema, Object owner, IdStrategy strategy, boolean graph, Object collection, boolean ss, boolean list) throws IOException { if (graph) { // update the actual reference. ((GraphInput) input).updateLast(collection, owner); } final Wrapper wrapper = new Wrapper(); Object c = input.mergeObject(wrapper, strategy.POLYMORPHIC_COLLECTION_SCHEMA); if (!graph || !((GraphInput) input).isCurrentMessageReference()) c = wrapper.value; if (1 != input.readFieldNumber(schema)) throw new ProtostuffException("Corrupt input."); Object type = input.mergeObject(wrapper, strategy.CLASS_SCHEMA); if (!graph || !((GraphInput) input).isCurrentMessageReference()) type = wrapper.value; try { fCheckedCollection_c.set(collection, c); fCheckedCollection_type.set(collection, type); if (ss) fCheckedSortedSet_ss.set(collection, c); if (list) fCheckedList_list.set(collection, c); } catch (Exception e) { throw new RuntimeException(e); } return collection; }
Example 13
Source File: PolymorphicCollectionSchema.java From protostuff with Apache License 2.0 | 5 votes |
private static Object readSynchronizedCollectionFrom(Input input, Schema<?> schema, Object owner, IdStrategy strategy, boolean graph, Object collection, boolean ss, boolean list) throws IOException { if (graph) { // update the actual reference. ((GraphInput) input).updateLast(collection, owner); } final Wrapper wrapper = new Wrapper(); Object c = input.mergeObject(wrapper, strategy.POLYMORPHIC_COLLECTION_SCHEMA); if (!graph || !((GraphInput) input).isCurrentMessageReference()) c = wrapper.value; try { fSynchronizedCollection_c.set(collection, c); // mutex is the object itself. fSynchronizedCollection_mutex.set(collection, collection); if (ss) fSynchronizedSortedSet_ss.set(collection, c); if (list) fSynchronizedList_list.set(collection, c); } catch (Exception e) { throw new RuntimeException(e); } return collection; }
Example 14
Source File: PolymorphicCollectionSchema.java From protostuff with Apache License 2.0 | 5 votes |
private static Object readUnmodifiableCollectionFrom(Input input, Schema<?> schema, Object owner, IdStrategy strategy, boolean graph, Object collection, boolean ss, boolean list) throws IOException { if (graph) { // update the actual reference. ((GraphInput) input).updateLast(collection, owner); } final Wrapper wrapper = new Wrapper(); Object c = input.mergeObject(wrapper, strategy.POLYMORPHIC_COLLECTION_SCHEMA); if (!graph || !((GraphInput) input).isCurrentMessageReference()) c = wrapper.value; try { fUnmodifiableCollection_c.set(collection, c); if (ss) fUnmodifiableSortedSet_ss.set(collection, c); if (list) fUnmodifiableList_list.set(collection, c); } catch (Exception e) { throw new RuntimeException(e); } return collection; }
Example 15
Source File: DefaultField.java From datawave with Apache License 2.0 | 5 votes |
@Override public void mergeFrom(Input input, DefaultField message) throws IOException { int number; while ((number = input.readFieldNumber(this)) != 0) { switch (number) { case 1: message.markings = new HashMap<String,String>(); input.mergeObject(message.markings, MapSchema.SCHEMA); break; case 2: message.columnVisibility = input.readString(); break; case 3: message.timestamp = input.readUInt64(); break; case 4: message.name = input.readString(); break; case 5: message.value = input.mergeObject(null, TypedValue.getSchema()); break; default: input.handleUnknownField(number, this); break; } } }
Example 16
Source File: DefaultEvent.java From datawave with Apache License 2.0 | 5 votes |
public void mergeFrom(Input input, DefaultEvent message) throws IOException { int number; Schema<DefaultField> schema = null; while ((number = input.readFieldNumber(this)) != 0) { switch (number) { case 1: message.markings = new HashMap<String,String>(); input.mergeObject(message.markings, MapSchema.SCHEMA); break; case 2: message.metadata = input.mergeObject(null, Metadata.getSchema()); break; case 3: if (message.fields == null) message.fields = new ArrayList<DefaultField>(); if (null == schema) { DefaultField field = new DefaultField(); schema = field.cachedSchema(); } DefaultField f = input.mergeObject(null, schema); message.fields.add(f); break; default: input.handleUnknownField(number, this); break; } } }
Example 17
Source File: PolymorphicMapSchema.java From protostuff with Apache License 2.0 | 4 votes |
private static Object readCheckedMapFrom(Input input, Schema<?> schema, Object owner, IdStrategy strategy, boolean graph, Object map, boolean sm) throws IOException { if (graph) { // update the actual reference. ((GraphInput) input).updateLast(map, owner); } final Wrapper wrapper = new Wrapper(); Object m = input.mergeObject(wrapper, strategy.POLYMORPHIC_MAP_SCHEMA); if (!graph || !((GraphInput) input).isCurrentMessageReference()) m = wrapper.value; if (1 != input.readFieldNumber(schema)) throw new ProtostuffException("Corrupt input."); Object keyType = input.mergeObject(wrapper, strategy.CLASS_SCHEMA); if (!graph || !((GraphInput) input).isCurrentMessageReference()) keyType = wrapper.value; if (2 != input.readFieldNumber(schema)) throw new ProtostuffException("Corrupt input."); Object valueType = input.mergeObject(wrapper, strategy.CLASS_SCHEMA); if (!graph || !((GraphInput) input).isCurrentMessageReference()) valueType = wrapper.value; try { fCheckedMap_m.set(map, m); fCheckedMap_keyType.set(map, keyType); fCheckedMap_valueType.set(map, valueType); if (sm) fCheckedSortedMap_sm.set(map, m); } catch (Exception e) { throw new RuntimeException(e); } return map; }
Example 18
Source File: QueryImpl.java From datawave with Apache License 2.0 | 4 votes |
public void mergeFrom(Input input, QueryImpl message) throws IOException { int number; while ((number = input.readFieldNumber(this)) != 0) { switch (number) { case 1: message.queryLogicName = input.readString(); break; case 2: message.id = input.readString(); break; case 3: message.queryName = input.readString(); break; case 4: message.userDN = input.readString(); break; case 5: message.query = input.readString(); break; case 6: message.beginDate = new Date(input.readInt64()); break; case 7: message.endDate = new Date(input.readInt64()); break; case 8: message.queryAuthorizations = input.readString(); break; case 9: message.expirationDate = new Date(input.readInt64()); break; case 10: message.pagesize = input.readUInt32(); break; case 11: if (message.parameters == null) message.parameters = new HashSet<Parameter>(); Parameter p = input.mergeObject(null, Parameter.SCHEMA); message.addParameter(p.getParameterName(), p.getParameterValue()); break; case 12: message.owner = input.readString(); break; case 13: if (null == message.dnList) message.dnList = new ArrayList<String>(); message.dnList.add(input.readString()); break; case 14: message.columnVisibility = input.readString(); break; case 15: message.pageTimeout = input.readUInt32(); break; default: input.handleUnknownField(number, this); break; } } }