/** * Adds a descriptor directly to the builder. * * <p>Use of this method is discouraged. Consider using {@link #add(String, Class)}. */ public void add(AttributeDescriptor descriptor) { attributes().add(descriptor); }
/** * Adds a descriptor to the builder by index. * * <p>Use of this method is discouraged. Consider using {@link #add(String, Class)}. */ public void add(int index, AttributeDescriptor descriptor) { attributes().add(index, descriptor); }
/** * Replace the descriptor at the provided index. * * @param index * @param descriptor */ public void set(int index, AttributeDescriptor descriptor) { attributes().set(index, descriptor); } /**
/** * Gets an AttributeBuilder configured using the descriptor at the provided index. * * @param index attribute index * @return attribute builder configured with descriptor */ public AttributeDescriptor get(int index) { return this.attributes().get(index); }
/** * Directly sets the list of attributes. * * @param attributes the new list of attributes, or null to reset the list */ public void setAttributes(List<AttributeDescriptor> attributes) { List<AttributeDescriptor> atts = attributes(); atts.clear(); if (attributes != null) atts.addAll(attributes); }
/** * Directly sets the list of attributes. * * @param attributes the new list of attributes, or null to reset the list */ public void setAttributes(AttributeDescriptor[] attributes) { List<AttributeDescriptor> atts = attributes(); atts.clear(); if (attributes != null) atts.addAll(Arrays.asList(attributes)); }
/** * Adds a new geometric attribute w/ provided name, class, and coordinate reference system. * * <p>The <tt>crs</tt> parameter may be <code>null</code>. * * @param name The name of the attribute. * @param binding The class that the attribute is bound to. * @param crs The crs of of the geometry, may be <code>null</code>. */ public void add(String name, Class<?> binding, CoordinateReferenceSystem crs) { attributeBuilder.setBinding(binding); attributeBuilder.setName(name); attributeBuilder.setCRS(crs); GeometryType type = attributeBuilder.buildGeometryType(); GeometryDescriptor descriptor = attributeBuilder.buildDescriptor(name, type); attributes().add(descriptor); }
List<AttributeDescriptor> atts = attributes(); for (int i = 0; i < atts.size(); i++) { AttributeDescriptor att = atts.get(i); for (AttributeDescriptor att : attributes()) { if (att instanceof GeometryDescriptor) { defGeom = (GeometryDescriptor) att; factory.createSimpleFeatureType( name(), attributes(), defGeom, isAbstract,
public static SimpleFeatureType retype(SimpleFeatureType original, List<String> types) { SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder(); // initialize the builder b.init(original); // clear the attributes b.attributes().clear(); // add attributes in order for (int i = 0; i < types.size(); i++) { b.add(original.getDescriptor(types.get(i))); } // handle default geometry GeometryDescriptor defaultGeometry = original.getGeometryDescriptor(); if (defaultGeometry != null && types.contains(defaultGeometry.getLocalName())) { b.setDefaultGeometry(defaultGeometry.getLocalName()); } else { b.setDefaultGeometry(null); } return b.buildFeatureType(); }
attributes().add(descriptor);
/** * Copys a feature type. * * <p>This method does a deep copy in that all individual attributes are copied as well. */ public static SimpleFeatureType copy(SimpleFeatureType original) { SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder(); // initialize the builder b.init(original); // clear attributes b.attributes().clear(); // add attributes in order for (AttributeDescriptor descriptor : original.getAttributeDescriptors()) { AttributeTypeBuilder ab = new AttributeTypeBuilder(b.factory); ab.init(descriptor); b.add(ab.buildDescriptor(descriptor.getLocalName())); } return b.buildFeatureType(); } }
/** Initializes the builder with state from a pre-existing feature type. */ public void init(SimpleFeatureType type) { init(); if (type == null) return; uri = type.getName().getNamespaceURI(); local = type.getName().getLocalPart(); description = type.getDescription(); restrictions = null; restrictions().addAll(type.getRestrictions()); this.defaultCrs = type.getCoordinateReferenceSystem(); this.defaultCrsSet = true; if (type.getGeometryDescriptor() != null) { this.defaultGeometry = type.getGeometryDescriptor().getLocalName(); } attributes = null; attributes().addAll(type.getAttributeDescriptors()); isAbstract = type.isAbstract(); superType = (SimpleFeatureType) type.getSuper(); }
/** * Create a SimpleFeatureType with the same content; just updating the geometry attribute to * match the provided coordinate reference system. * * @param original SimpleFeatureType * @param crs CoordinateReferenceSystem of result * @return SimpleFeatureType updated with the provided CoordinateReferenceSystem */ public static SimpleFeatureType retype( SimpleFeatureType original, CoordinateReferenceSystem crs) { SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder(); // initialize the builder b.init(original); // clear the attributes b.attributes().clear(); // add attributes in order for (AttributeDescriptor descriptor : original.getAttributeDescriptors()) { if (descriptor instanceof GeometryDescriptor) { GeometryDescriptor geometryDescriptor = (GeometryDescriptor) descriptor; AttributeTypeBuilder adjust = new AttributeTypeBuilder(b.factory); adjust.init(geometryDescriptor); adjust.setCRS(crs); b.add(adjust.buildDescriptor(geometryDescriptor.getLocalName())); continue; } b.add(descriptor); } return b.buildFeatureType(); }
/** * Adds a descriptor to the builder by index. * <p> * Use of this method is discouraged. Consider using {@link #add(String, Class)}. * </p> */ public void add( int index, AttributeDescriptor descriptor ) { attributes().add(index, descriptor); }
/** * Adds a descriptor directly to the builder. * <p> * Use of this method is discouraged. Consider using {@link #add(String, Class)}. * </p> */ public void add( AttributeDescriptor descriptor ) { attributes().add(descriptor); }
/** * Directly sets the list of attributes. * @param attributes the new list of attributes, or null to reset the list */ public void setAttributes(List<AttributeDescriptor> attributes) { List<AttributeDescriptor> atts = attributes(); atts.clear(); if(attributes != null) atts.addAll(attributes); }
/** * Directly sets the list of attributes. * @param attributes the new list of attributes, or null to reset the list */ public void setAttributes(AttributeDescriptor[] attributes) { List<AttributeDescriptor> atts = attributes(); atts.clear(); if(attributes != null) atts.addAll(Arrays.asList(attributes)); }
public static SimpleFeatureType retype( SimpleFeatureType original, List<String> types ) { SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder(); //initialize the builder b.init( original ); //clear the attributes b.attributes().clear(); //add attributes in order for ( int i = 0; i < types.size(); i++ ) { b.add( original.getDescriptor( types.get(i) ) ); } return b.buildFeatureType(); } /**
/** * Adds a new geometric attribute w/ provided name, class, and coordinate * reference system. * <p> * The <tt>crs</tt> parameter may be <code>null</code>. * </p> * @param name The name of the attribute. * @param binding The class that the attribute is bound to. * @param crs The crs of of the geometry, may be <code>null</code>. */ public void add(String name, Class<?> binding, CoordinateReferenceSystem crs ) { attributeBuilder.setBinding(binding); attributeBuilder.setName(name); attributeBuilder.setCRS(crs); GeometryType type = attributeBuilder.buildGeometryType(); GeometryDescriptor descriptor = attributeBuilder.buildDescriptor(name,type); attributes().add(descriptor); }
/** * Copys a feature type. * <p> * This method does a deep copy in that all individual attributes are copied as well. * </p> */ public static SimpleFeatureType copy( SimpleFeatureType original ) { SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder(); //initialize the builder b.init( original ); //clear attributes b.attributes().clear(); //add attributes in order for( AttributeDescriptor descriptor : original.getAttributeDescriptors() ){ AttributeTypeBuilder ab = new AttributeTypeBuilder( b.factory ); ab.init( descriptor ); b.add( ab.buildDescriptor( descriptor.getLocalName() )); } return b.buildFeatureType(); } }