Package org.locationtech.geogig.storage

Examples of org.locationtech.geogig.storage.FieldType


            } else {
                Object value = null;
                for (Tag tag : tags) {
                    if (fields.containsKey(tag.getKey())) {
                        if (fields.get(tag.getKey()).getName().equals(attrName)) {
                            FieldType type = FieldType.forBinding(clazz);
                            value = getAttributeValue(tag.getValue(), type);
                            break;
                        }
                    }
                }
View Full Code Here


    public void writeFeature(RevFeature feature, String tag) throws XMLStreamException {
        out.writeStartElement(tag);
        writeElement("id", feature.getId().toString());
        ImmutableList<Optional<Object>> values = feature.getValues();
        for (Optional<Object> opt : values) {
            final FieldType type = FieldType.forValue(opt);
            String valueString = TextValueSerializer.asString(opt);
            out.writeStartElement("attribute");
            writeElement("type", type.toString());
            writeElement("value", valueString);
            out.writeEndElement();
        }

        out.writeEndElement();
View Full Code Here

            Preconditions.checkArgument(tokens.length == 2, "Wrong attribute definition: "
                    + featureChanges.get(i));
            String fieldName = tokens[0];
            AttributeDescriptor desc = ft.getDescriptor(fieldName);
            Preconditions.checkNotNull(desc, "Wrong attribute in feature description");
            FieldType type = FieldType.forBinding(desc.getType().getBinding());
            Object value = TextValueSerializer.fromString(type, tokens[1]);
            ftb.set(tokens[0], value);
        }
        return ftb.buildFeature(featureId);
    }
View Full Code Here

        ImmutableList<Optional<Object>> values = feature.getValues();

        writeUnsignedVarInt(values.size(), data);

        for (Optional<Object> field : values) {
            FieldType type = FieldType.forValue(field);
            data.writeByte(type.getTag());
            if (type != FieldType.NULL) {
                DataStreamValueSerializerV2.write(field, data);
            }
        }
    }
View Full Code Here

        final int count = readUnsignedVarInt(in);
        final ImmutableList.Builder<Optional<Object>> builder = ImmutableList.builder();

        for (int i = 0; i < count; i++) {
            final byte fieldTag = in.readByte();
            final FieldType fieldType = FieldType.valueOf(fieldTag);
            Object value = DataStreamValueSerializerV2.read(fieldType, in);
            builder.add(Optional.fromNullable(value));
        }

        return new RevFeatureImpl(id, builder.build());
View Full Code Here

    private static AttributeType readAttributeType(DataInput in, FeatureTypeFactory typeFactory)
            throws IOException {
        final Name name = readName(in);
        final byte typeTag = in.readByte();
        final FieldType type = FieldType.valueOf(typeTag);
        if (Geometry.class.isAssignableFrom(type.getBinding())) {
            final boolean isCRSCode = in.readBoolean(); // as opposed to a raw WKT string
            final String crsText = in.readUTF();
            final CoordinateReferenceSystem crs;
            try {
                if (isCRSCode) {
                    if ("urn:ogc:def:crs:EPSG::0".equals(crsText)) {
                        crs = null;
                    } else {
                        boolean forceLongitudeFirst = crsText.startsWith("EPSG:");
                        crs = CRS.decode(crsText, forceLongitudeFirst);
                    }
                } else {
                    crs = CRS.parseWKT(crsText);
                }
            } catch (FactoryException e) {
                throw new RuntimeException(e);
            }
            return typeFactory.createGeometryType(name, type.getBinding(), crs, false, false,
                    Collections.<Filter> emptyList(), null, null);
        } else {
            return typeFactory.createAttributeType(name, type.getBinding(), false, false,
                    Collections.<Filter> emptyList(), null, null);
        }
    }
View Full Code Here

     *
     * @param opt
     * @param data
     */
    public static void write(Optional<Object> opt, DataOutput data) throws IOException {
        FieldType type = FieldType.forValue(opt);
        if (serializers.containsKey(type)) {
            serializers.get(type).write(opt.orNull(), data);
        } else {
            throw new IllegalArgumentException("The specified type (" + type + ") is not supported");
        }
View Full Code Here

        final int count = in.readInt();
        final ImmutableList.Builder<Optional<Object>> builder = ImmutableList.builder();

        for (int i = 0; i < count; i++) {
            final byte fieldTag = in.readByte();
            final FieldType fieldType = FieldType.valueOf(fieldTag);
            Object value = DataStreamValueSerializerV1.read(fieldType, in);
            builder.add(Optional.fromNullable(value));
        }

        return new RevFeatureImpl(id, builder.build());
View Full Code Here

    private static AttributeType readAttributeType(DataInput in, FeatureTypeFactory typeFactory)
            throws IOException {
        final Name name = readName(in);
        final byte typeTag = in.readByte();
        final FieldType type = FieldType.valueOf(typeTag);
        if (Geometry.class.isAssignableFrom(type.getBinding())) {
            final boolean isCRSCode = in.readBoolean(); // as opposed to a raw
                                                        // WKT string
            final String crsText = in.readUTF();
            final CoordinateReferenceSystem crs;
            try {
                if (isCRSCode) {
                    if ("urn:ogc:def:crs:EPSG::0".equals(crsText)) {
                        crs = null;
                    } else {
                        boolean forceLongitudeFirst = crsText.startsWith("EPSG:");
                        crs = CRS.decode(crsText, forceLongitudeFirst);
                    }
                } else {
                    crs = CRS.parseWKT(crsText);
                }
            } catch (FactoryException e) {
                throw new RuntimeException(e);
            }
            return typeFactory.createGeometryType(name, type.getBinding(), crs, false, false,
                    Collections.<Filter> emptyList(), null, null);
        } else {
            return typeFactory.createAttributeType(name, type.getBinding(), false, false,
                    Collections.<Filter> emptyList(), null, null);
        }
    }
View Full Code Here

        public void write(RevFeature feature, OutputStream out) throws IOException {
            DataOutput data = new DataOutputStream(out);
            writeHeader(data, "feature");
            data.writeInt(feature.getValues().size());
            for (Optional<Object> field : feature.getValues()) {
                FieldType type = FieldType.forValue(field);
                data.writeByte(type.getTag());
                if (type != FieldType.NULL) {
                    DataStreamValueSerializerV1.write(field, data);
                }
            }
        }
View Full Code Here

TOP

Related Classes of org.locationtech.geogig.storage.FieldType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.