/** * Determines if <code>parent</code> is a super type of <code>type</code> * * @param type The type in question. * @param parent The possible parent type. */ public static boolean isSuperType(PropertyType type, PropertyType parent) { while (type.getSuper() != null) { type = type.getSuper(); if (type.equals(parent)) return true; } return false; }
public GeometryAttribute getDefaultGeometryProperty() { if (defaultGeometry != null) { return defaultGeometry; } synchronized (this) { if (defaultGeometry == null) { // look it up from the type if (((FeatureType) getType()).getGeometryDescriptor() == null) { return null; } GeometryType geometryType = (GeometryType) getType().getGeometryDescriptor().getType(); if (geometryType != null) { for (Iterator itr = getValue().iterator(); itr.hasNext(); ) { Property property = (Property) itr.next(); if (property instanceof GeometryAttribute) { if (property.getType().equals(geometryType)) { defaultGeometry = (GeometryAttribute) property; break; } } } } } } return defaultGeometry; }
/** Check if a property type should appear multiple times or be encoded as a list. */ private PropertyDescriptor isMultipleType(PropertyType parentType, PropertyType type) { if (!(parentType instanceof ComplexType)) { // only properties that belong to a complex type can be chained features return null; } // search the current type on the parent properties ComplexType complexType = (ComplexType) parentType; PropertyDescriptor foundType = null; for (PropertyDescriptor descriptor : complexType.getDescriptors()) { if (descriptor.getType().equals(type)) { // found our type foundType = descriptor; } } // if the found type can appear multiples time is not a chained feature if (foundType == null) { return null; } if (foundType.getMaxOccurs() > 1) { // this type can appear more than once so it should not be encoded as a list return foundType; } return null; }
@Override public Feature next() { Feature original = delegate.next(); // this does not really work... // for (PropertyDescriptor pd : original.getType().getDescriptors()) { // Collection<Property> properties = original.getProperties(pd.getName()); // if(properties != null) { // for (Property p : properties) { // if (names.contains(p.getName()) || // names.contains(p.getName().getLocalPart())) { // builder.append(pd.getName(), p); // } // } // } // } for (Property p : original.getProperties()) { if (names.contains(p.getName()) || names.contains(p.getName().getLocalPart())) { // this makes the thing type specific, but at least it works for the record case // TODO: eventually figure out how to make this for the general case... if (p.getType().equals(CSWRecordDescriptor.SIMPLE_LITERAL)) { builder.append(CSWRecordDescriptor.DC_ELEMENT_NAME, p); } else { builder.append(p.getName(), p); } } } return builder.buildFeature(original.getIdentifier().getID()); }