public static RevTag readTag(ObjectId id, DataInput in) throws IOException { final ObjectId commitId = readObjectId(in); final String name = in.readUTF(); final String message = in.readUTF(); final RevPerson tagger = readRevPerson(in); return RevTagBuilder.create(id, name, commitId, message, tagger); }
@Override public RevObject read(ObjectId id, InputStream rawData) throws IOException { DataInput in = new DataInputStream(rawData); String header = readToMarker(in, NUL); if ("commit".equals(header)) return readCommit(id, in); else if ("tree".equals(header)) return readTree(id, in); else if ("feature".equals(header)) return readFeature(id, in); else if ("featuretype".equals(header)) return readFeatureType(id, in); else if ("tag".equals(header)) return readTag(id, in); else throw new IllegalArgumentException("Unrecognized object header: " + header); }
@Override public RevFeature read(ObjectId id, InputStream rawData) throws IllegalArgumentException { DataInput in = new DataInputStream(rawData); try { requireHeader(in, "feature"); return readFeature(id, in); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public RevFeatureType read(ObjectId id, InputStream rawData) throws IllegalArgumentException { DataInput in = new DataInputStream(rawData); try { requireHeader(in, "featuretype"); return readFeatureType(id, in); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public RevCommit read(ObjectId id, InputStream rawData) throws IllegalArgumentException { DataInput in = new DataInputStream(rawData); try { requireHeader(in, "commit"); return readCommit(id, in); } catch (IOException e) { Throwables.throwIfUnchecked(e); throw new RuntimeException(e); } }
break; case OBJECT_AND_DIFF_ENTRY: { ObjectId id = readObjectId(data); revObj = serializer.read(id, in); ObjectId mdid = readObjectId(data); metadata = serializer.read(mdid, in); ObjectId id = readObjectId(data); revObj = serializer.read(id, in); DiffEntry diff = FormatCommonV1.readDiff(data); return new DiffPacket(diff, revObj, metadata);
public static RevFeatureType readFeatureType(ObjectId id, DataInput in, FeatureTypeFactory typeFactory) throws IOException { Name name = readName(in); int propertyCount = in.readInt(); List<AttributeDescriptor> attributes = new ArrayList<AttributeDescriptor>(); for (int i = 0; i < propertyCount; i++) { attributes.add(readAttributeDescriptor(in, typeFactory)); } SimpleFeatureType ftype = typeFactory.createSimpleFeatureType(name, attributes, null, false, Collections.<Filter> emptyList(), BasicFeatureTypes.FEATURE, null); return RevFeatureTypeBuilder.create(id, ftype); }
private static AttributeDescriptor readAttributeDescriptor(DataInput in, FeatureTypeFactory typeFactory) throws IOException { final Name name = readName(in); final boolean nillable = in.readBoolean(); final int minOccurs = in.readInt(); final int maxOccurs = in.readInt(); final AttributeType type = readAttributeType(in, typeFactory); if (type instanceof GeometryType) return typeFactory.createGeometryDescriptor((GeometryType) type, name, minOccurs, maxOccurs, nillable, null); else return typeFactory.createAttributeDescriptor(type, name, minOccurs, maxOccurs, nillable, null); }
Node n = readNode(in); if (n.getType() != RevObject.TYPE.FEATURE) { throw new IllegalStateException("Non-feature node in tree's feature list."); Node n = readNode(in); if (n.getType() != RevObject.TYPE.TREE) { throw new IllegalStateException("Non-tree node in tree's subtree list."); for (int i = 0; i < nBuckets; i++) { int key = in.readInt(); Bucket bucket = readBucket(in); buckets.put(key, bucket);
public static final Bucket readBucket(DataInput in) throws IOException { final byte[] hash = new byte[20]; in.readFully(hash); ObjectId objectId = ObjectId.createNoClone(hash); Envelope bounds = readBBox(in); return Bucket.create(objectId, bounds); }
public static RevFeatureType readFeatureType(ObjectId id, DataInput in) throws IOException { return readFeatureType(id, in, DEFAULT_FEATURETYPE_FACTORY); }
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);
public static RevFeatureType readFeatureType(ObjectId id, DataInput in, FeatureTypeFactory typeFactory) throws IOException { Name name = readName(in); int propertyCount = in.readInt(); List<AttributeDescriptor> attributes = new ArrayList<AttributeDescriptor>(); for (int i = 0; i < propertyCount; i++) { attributes.add(readAttributeDescriptor(in, typeFactory)); } SimpleFeatureType ftype = typeFactory.createSimpleFeatureType(name, attributes, null, false, Collections.<Filter> emptyList(), BasicFeatureTypes.FEATURE, null); return RevFeatureType.builder().id(id).type(ftype).build(); }
@Override public RevFeature read(ObjectId id, InputStream rawData) throws IllegalArgumentException { DataInput in = new DataInputStream(rawData); try { requireHeader(in, "feature"); return readFeature(id, in); } catch (IOException e) { Throwables.propagate(e); } throw new IllegalStateException( "Didn't expect to reach end of FeatureReader.read(); We should have returned or thrown an error before this point."); }
@Override public RevCommit read(ObjectId id, InputStream rawData) throws IllegalArgumentException { DataInput in = new DataInputStream(rawData); try { requireHeader(in, "commit"); return readCommit(id, in); } catch (IOException e) { Throwables.propagate(e); } throw new IllegalStateException( "Unexpected state: neither succeeded nor threw exception while trying to read commit " + id); }
@Override public RevFeatureType read(ObjectId id, InputStream rawData) throws IllegalArgumentException { DataInput in = new DataInputStream(rawData); try { requireHeader(in, "featuretype"); return readFeatureType(id, in); } catch (IOException e) { throw new RuntimeException(e); } }
private static AttributeDescriptor readAttributeDescriptor(DataInput in, FeatureTypeFactory typeFactory) throws IOException { final Name name = readName(in); final boolean nillable = in.readBoolean(); final int minOccurs = in.readInt(); final int maxOccurs = in.readInt(); final AttributeType type = readAttributeType(in, typeFactory); if (type instanceof GeometryType) return typeFactory.createGeometryDescriptor((GeometryType) type, name, minOccurs, maxOccurs, nillable, null); else return typeFactory.createAttributeDescriptor(type, name, minOccurs, maxOccurs, nillable, null); }
Node n = readNode(in); if (n.getType() != RevObject.TYPE.FEATURE) { throw new IllegalStateException("Non-feature node in tree's feature list."); Node n = readNode(in); if (n.getType() != RevObject.TYPE.TREE) { throw new IllegalStateException("Non-tree node in tree's subtree list."); for (int i = 0; i < nBuckets; i++) { int index = in.readInt(); Bucket bucket = readBucket(index, in); buckets.add(bucket);
public static Node readNode(DataInput in) throws IOException { final String name = in.readUTF(); final byte[] objectId = new byte[20]; in.readFully(objectId); final byte[] metadataId = new byte[20]; in.readFully(metadataId); final RevObject.TYPE contentType = RevObject.TYPE.valueOf(in.readByte()); final Envelope bbox = readBBox(in); Map<String, Object> extraData = DataStreamValueSerializerV1.INSTANCE.readMap(in); final Node node; node = Node.create(name, ObjectId.createNoClone(objectId), ObjectId.createNoClone(metadataId), contentType, bbox, extraData); return node; }
public static RevFeatureType readFeatureType(ObjectId id, DataInput in) throws IOException { return readFeatureType(id, in, DEFAULT_FEATURETYPE_FACTORY); }