private void collectAttributes( SimpleFeatureType schema, List<String> retainedAttributes, SimpleFeatureTypeBuilder tb) { for (AttributeDescriptor descriptor : schema.getAttributeDescriptors()) { // check whether descriptor has been selected in the attribute list boolean isInRetainList = true; if (retainedAttributes != null) { isInRetainList = retainedAttributes.contains(descriptor.getLocalName()); logger.fine("Checking " + descriptor.getLocalName() + " --> " + isInRetainList); } if (!isInRetainList || schema.getGeometryDescriptor() == descriptor) { continue; } // build the attribute to return AttributeTypeBuilder builder = new AttributeTypeBuilder(); builder.setName(schema.getName().getLocalPart() + "_" + descriptor.getName()); builder.setNillable(descriptor.isNillable()); builder.setBinding(descriptor.getType().getBinding()); builder.setMinOccurs(descriptor.getMinOccurs()); builder.setMaxOccurs(descriptor.getMaxOccurs()); builder.setDefaultValue(descriptor.getDefaultValue()); builder.setCRS(schema.getCoordinateReferenceSystem()); AttributeDescriptor intersectionDescriptor = builder.buildDescriptor( schema.getName().getLocalPart() + "_" + descriptor.getName(), descriptor.getType()); tb.add(intersectionDescriptor); tb.addBinding(descriptor.getType()); } }
/** * Sets the default value of the next attribute added to the feature type. * * <p>This value is reset after a call to {@link #add(String, Class)} */ public SimpleFeatureTypeBuilder defaultValue(Object defaultValue) { attributeBuilder.setDefaultValue(defaultValue); return this; }