/** * Adds an association to the complex attribute being built. <br> * * <p>This method uses the type supplied in {@link #setType(AttributeType)} in order to * determine the association type. * * @param value The value of the association, an attribute. * @param name The name of the association. * @param namespaceURI The namespace of the association */ public void associate(Attribute value, Name name) { AssociationDescriptor descriptor = associationDescriptor(name); Association association = attributeFactory.createAssociation(value, descriptor); properties().add(association); }
/** * Factors out attribute creation code, needs to be called with either one of type or descriptor * null. */ protected Attribute create( Object value, AttributeType type, AttributeDescriptor descriptor, String id) { if (descriptor != null) { type = (AttributeType) descriptor.getType(); } // if (type instanceof FeatureCollectionType) { // attribute = descriptor != null ? attributeFactory.createFeatureCollection( // (Collection) value, descriptor, id) : attributeFactory.createFeatureCollection( // (Collection) value, (FeatureCollectionType) type, id); // } else if (type instanceof FeatureType) { return descriptor != null ? attributeFactory.createFeature((Collection) value, descriptor, id) : attributeFactory.createFeature((Collection) value, (FeatureType) type, id); } else if (type instanceof ComplexType) { return createComplexAttribute((Collection) value, (ComplexType) type, descriptor, id); } else if (type instanceof GeometryType) { return attributeFactory.createGeometryAttribute( value, (GeometryDescriptor) descriptor, id, getCRS(value)); } else { return attributeFactory.createAttribute(value, descriptor, id); } }
/** * Create complex attribute * * @param value * @param type * @param descriptor * @param id * @return */ public ComplexAttribute createComplexAttribute( Object value, ComplexType type, AttributeDescriptor descriptor, String id) { return descriptor != null ? attributeFactory.createComplexAttribute((Collection) value, descriptor, id) : attributeFactory.createComplexAttribute((Collection) value, type, id); }
return factory.createAttribute(value, newDescriptor, null); } else { return factory.createComplexAttribute( Collections.<Property>singletonList((Property) value), newDescriptor, null);
return factory.createFeature(properties, ad, id); } else { return factory.createFeature(properties, featureType, id);
Map<Object, Object> featureUserData = this.featureUserData; reset(); SimpleFeature sf = factory.createSimpleFeature(values, featureType, id);
@Override public Object next() { //create a new descriptor based on teh xml type AttributeType xmlType = findType(descriptor.getType().getBinding()); if (xmlType == null) { throw new RuntimeException("Unable to map attribute " + descriptor.getName() + " to xml type"); } Object value = next.getProperty(descriptor.getName()).getValue(); //because simple features don't carry around their namespace, create a descritor name // that actually used the feature type schema namespace Name name = new NameImpl(next.getType().getName().getNamespaceURI(), descriptor.getLocalName()); AttributeDescriptor newDescriptor = typeFactory.createAttributeDescriptor(xmlType, name, descriptor.getMinOccurs(), descriptor.getMaxOccurs(), descriptor.isNillable(), descriptor.getDefaultValue()); next = null; return factory.createAttribute(value, newDescriptor, null); }
return ff.createFeature( value, (FeatureType) schema, SimpleFeatureBuilder.createDefaultFeatureId());
public SimpleFeature buildFeature(String fid) { return factory.createSimpleFeature( properties, schema, fid ); }
/** * Factors out attribute creation code, needs to be called with either one of type or descriptor * null. */ protected Attribute create(Object value, AttributeType type, AttributeDescriptor descriptor, String id) { if (descriptor != null) { type = (AttributeType) descriptor.getType(); } // if (type instanceof FeatureCollectionType) { // attribute = descriptor != null ? attributeFactory.createFeatureCollection( // (Collection) value, descriptor, id) : attributeFactory.createFeatureCollection( // (Collection) value, (FeatureCollectionType) type, id); // } else if (type instanceof FeatureType) { return descriptor != null ? attributeFactory.createFeature((Collection) value, descriptor, id) : attributeFactory.createFeature((Collection) value, (FeatureType) type, id); } else if (type instanceof ComplexType) { return createComplexAttribute((Collection) value, (ComplexType) type, descriptor, id); } else if (type instanceof GeometryType) { return attributeFactory.createGeometryAttribute(value, (GeometryDescriptor) descriptor, id, getCRS()); } else { return attributeFactory.createAttribute(value, descriptor, id); } }
/** * Adds an association to the complex attribute being built. <br> * <p> * This method uses the type supplied in {@link #setType(AttributeType)} in order to determine * the association type. * </p> * * @param value * The value of the association, an attribute. * @param name * The name of the association. * @param namespaceURI * The namespace of the association */ public void associate(Attribute value, Name name) { AssociationDescriptor descriptor = associationDescriptor(name); Association association = attributeFactory.createAssociation(value, descriptor); properties().add(association); }
/** * Create complex attribute * * @param value * @param type * @param descriptor * @param id * @return */ public ComplexAttribute createComplexAttribute(Object value, ComplexType type, AttributeDescriptor descriptor, String id) { return descriptor != null ? attributeFactory.createComplexAttribute((Collection) value, descriptor, id) : attributeFactory.createComplexAttribute((Collection) value, type, id); }
/** * Create a non-simple template feature from feature type schema * * @param schema the feature type * @return a template feature */ public static Feature templateFeature(FeatureType schema) { FeatureFactory ff = CommonFactoryFinder.getFeatureFactory(null); Collection<Property> value = new ArrayList<Property>(); for (PropertyDescriptor pd : schema.getDescriptors()) { if (pd instanceof AttributeDescriptor) { if (pd instanceof GeometryDescriptor) { value.add(new GeometryAttributeImpl (((AttributeDescriptor) pd).getDefaultValue(), (GeometryDescriptor) pd, null) ); } else { value.add(new AttributeImpl (((AttributeDescriptor) pd).getDefaultValue(), (AttributeDescriptor) pd, null) ); } } } return ff.createFeature(value, (FeatureType) schema, SimpleFeatureBuilder.createDefaultFeatureId()); }
Map<Object,Object> featureUserData = this.featureUserData; reset(); SimpleFeature sf = factory.createSimpleFeature(values, featureType, id);
Association association = f.createAssociation(null, associationDescriptor); association.getUserData().put("gml:id", rtable + "." + rfid);