@Override public void writeMap(Map<String, Object> map, DataOutput data) throws IOException { data.writeInt(map.size()); for (Entry<String, Object> e : map.entrySet()) { String key = e.getKey(); writeString(key, data); Object value = e.getValue(); FieldType fieldType = FieldType.forValue(value); data.writeByte(fieldType.getTag()); encode(fieldType, value, data); } }
@Override public void writeMap(Map<String, Object> map, DataOutput data) throws IOException { data.writeInt(map.size()); for (Entry<String, Object> e : map.entrySet()) { String key = e.getKey(); writeString(key, data); Object value = e.getValue(); FieldType fieldType = FieldType.forValue(value); data.writeByte(fieldType.getTag()); encode(fieldType, value, data); } }
@Override public void writeMap(Map<String, Object> map, DataOutput out) throws IOException { final int size = map.size(); writeUnsignedVarInt(size, out); for (Entry<String, Object> e : map.entrySet()) { String key = e.getKey(); writeString(key, out); Object value = e.getValue(); FieldType fieldType = FieldType.forValue(value); out.writeByte(fieldType.getTag()); encode(fieldType, value, out); } } }
@Override public void writeMap(Map<String, Object> map, DataOutput out) throws IOException { final int size = map.size(); writeUnsignedVarInt(size, out); for (Entry<String, Object> e : map.entrySet()) { String key = e.getKey(); writeString(key, out); Object value = e.getValue(); FieldType fieldType = FieldType.forValue(value); out.writeByte(fieldType.getTag()); encode(fieldType, value, out); } } }
@Override public void write(RevFeature feature, OutputStream out) throws IOException { DataOutputStream data = new DataOutputStream(out); try { writeHeader(data, "feature"); data.writeInt(feature.size()); for (Optional<Object> field : feature.getValues()) { Object value = field.orNull(); FieldType type = FieldType.forValue(value); data.writeByte(type.getTag()); DataStreamValueSerializerV1.INSTANCE.encode(type, value, data); } } finally { data.flush(); } } }
@Override public void write(RevFeature feature, OutputStream out) throws IOException { DataOutputStream data = new DataOutputStream(out); try { writeHeader(data, "feature"); data.writeInt(feature.size()); for (Optional<Object> field : feature.getValues()) { Object value = field.orNull(); FieldType type = FieldType.forValue(value); data.writeByte(type.getTag()); DataStreamValueSerializerV1.INSTANCE.encode(type, value, data); } } finally { data.flush(); } } }
public void writeFeature(RevFeature feature, DataOutput data) throws IOException { writeUnsignedVarInt(feature.size(), data); for (int i = 0; i < feature.size(); i++) { Object field = feature.get(i).orNull(); FieldType type = FieldType.forValue(field); data.writeByte(type.getTag()); valueEncoder.encode(type, field, data); } }
public void writeFeature(RevFeature feature, DataOutput data) throws IOException { writeUnsignedVarInt(feature.size(), data); for (int i = 0; i < feature.size(); i++) { Object field = feature.get(i).orNull(); FieldType type = FieldType.forValue(field); data.writeByte(type.getTag()); valueEncoder.encode(type, field, data); } }
private static void writePropertyType(PropertyType type, DataOutput data) throws IOException { writeName(type.getName(), data); data.writeByte(FieldType.forBinding(type.getBinding()).getTag()); if (type instanceof GeometryType) { GeometryType gType = (GeometryType) type;
private void writePropertyType(PropertyType type, DataOutput data) throws IOException { writeName(type.getName(), data); data.writeByte(FieldType.forBinding(type.getBinding()).getTag()); if (type instanceof GeometryType) { GeometryType gType = (GeometryType) type;
private static void writePropertyType(PropertyType type, DataOutput data) throws IOException { writeName(type.getName(), data); data.writeByte(FieldType.forBinding(type.getBinding()).getTag()); if (type instanceof GeometryType) { GeometryType gType = (GeometryType) type;
private void writePropertyType(PropertyType type, DataOutput data) throws IOException { writeName(type.getName(), data); data.writeByte(FieldType.forBinding(type.getBinding()).getTag()); if (type instanceof GeometryType) { GeometryType gType = (GeometryType) type;
data.writeByte(type.getTag()); encode(value, data); i++;
Object value = feature.get(i).orNull(); FieldType type = FieldType.forValue(value); data.writeByte(type.getTag() & 0xFF); valueEncoder.encode(type, value, data); dataOffsets[i] = offset;
@Test public void testValueOf() { assertEquals(FieldType.NULL, FieldType.valueOf(FieldType.NULL.getTag())); assertEquals(FieldType.BOOLEAN, FieldType.valueOf(FieldType.BOOLEAN.getTag())); assertEquals(FieldType.BYTE, FieldType.valueOf(FieldType.BYTE.getTag())); assertEquals(FieldType.SHORT, FieldType.valueOf(FieldType.SHORT.getTag())); assertEquals(FieldType.INTEGER, FieldType.valueOf(FieldType.INTEGER.getTag())); assertEquals(FieldType.LONG, FieldType.valueOf(FieldType.LONG.getTag())); assertEquals(FieldType.FLOAT, FieldType.valueOf(FieldType.FLOAT.getTag())); assertEquals(FieldType.DOUBLE, FieldType.valueOf(FieldType.DOUBLE.getTag())); assertEquals(FieldType.STRING, FieldType.valueOf(FieldType.STRING.getTag())); assertEquals(FieldType.BOOLEAN_ARRAY, FieldType.valueOf(FieldType.BOOLEAN_ARRAY.getTag())); assertEquals(FieldType.BYTE_ARRAY, FieldType.valueOf(FieldType.BYTE_ARRAY.getTag())); assertEquals(FieldType.SHORT_ARRAY, FieldType.valueOf(FieldType.SHORT_ARRAY.getTag())); assertEquals(FieldType.INTEGER_ARRAY, FieldType.valueOf(FieldType.INTEGER_ARRAY.getTag())); assertEquals(FieldType.LONG_ARRAY, FieldType.valueOf(FieldType.LONG_ARRAY.getTag())); assertEquals(FieldType.FLOAT_ARRAY, FieldType.valueOf(FieldType.FLOAT_ARRAY.getTag())); assertEquals(FieldType.DOUBLE_ARRAY, FieldType.valueOf(FieldType.DOUBLE_ARRAY.getTag())); assertEquals(FieldType.STRING_ARRAY, FieldType.valueOf(FieldType.STRING_ARRAY.getTag())); assertEquals(FieldType.POINT, FieldType.valueOf(FieldType.POINT.getTag())); assertEquals(FieldType.LINESTRING, FieldType.valueOf(FieldType.LINESTRING.getTag())); assertEquals(FieldType.POLYGON, FieldType.valueOf(FieldType.POLYGON.getTag())); assertEquals(FieldType.MULTIPOINT, FieldType.valueOf(FieldType.MULTIPOINT.getTag())); assertEquals(FieldType.MULTILINESTRING, FieldType.valueOf(FieldType.MULTILINESTRING.getTag())); assertEquals(FieldType.MULTIPOLYGON, FieldType.valueOf(FieldType.MULTIPOLYGON.getTag())); assertEquals(FieldType.GEOMETRYCOLLECTION, FieldType.valueOf(FieldType.GEOMETRYCOLLECTION.getTag())); assertEquals(FieldType.GEOMETRY, FieldType.valueOf(FieldType.GEOMETRY.getTag())); assertEquals(FieldType.UUID, FieldType.valueOf(FieldType.UUID.getTag()));
Object value = feature.get(i).orNull(); FieldType type = FieldType.forValue(value); data.writeByte(type.getTag() & 0xFF); valueEncoder.encode(type, value, data); dataOffsets[i] = offset;
FieldType fieldType = FieldType.forBinding(binding); Preconditions.checkArgument(fieldType != FieldType.UNKNOWN); bindingCode = fieldType.getTag();// just because they do match
@Override public void funnel(PropertyDescriptor descriptor, PrimitiveSink into) { NameFunnel.funnel(descriptor.getName(), into); PropertyType attrType = descriptor.getType(); NameFunnel.funnel(attrType.getName(), into); FieldType type = FieldType.forBinding(attrType.getBinding()); into.putInt(type.getTag()); into.putBoolean(descriptor.isNillable()); into.putInt(descriptor.getMaxOccurs()); into.putInt(descriptor.getMinOccurs()); if (descriptor instanceof GeometryDescriptor) { CoordinateReferenceSystem crs; crs = ((GeometryDescriptor) descriptor).getCoordinateReferenceSystem(); String srsName; if (crs == null) { srsName = RevObjects.NULL_CRS_IDENTIFIER; } else { srsName = CRS.toSRS(crs); } NullableStringFunnel.funnel(srsName, into); } } };
@Override public void funnel(PropertyDescriptor descriptor, PrimitiveSink into) { NameFunnel.funnel(descriptor.getName(), into); PropertyType attrType = descriptor.getType(); NameFunnel.funnel(attrType.getName(), into); FieldType type = FieldType.forBinding(attrType.getBinding()); into.putInt(type.getTag()); into.putBoolean(descriptor.isNillable()); into.putInt(descriptor.getMaxOccurs()); into.putInt(descriptor.getMinOccurs()); if (descriptor instanceof GeometryDescriptor) { CoordinateReferenceSystem crs; crs = ((GeometryDescriptor) descriptor).getCoordinateReferenceSystem(); String srsName; if (crs == null) { srsName = RevObjects.NULL_CRS_IDENTIFIER; } else { srsName = CRS.toSRS(crs); } NullableStringFunnel.funnel(srsName, into); } } };