/** * 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); } }
return factory.createAttribute(value, newDescriptor, null); } else { return factory.createComplexAttribute(
/** * 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); } }
@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); }