public FeatureTypeRegistry(NamespaceSupport namespaces) { if (namespaces != null) { GML = new GMLHandler(namespaces.getURI("gml")); } else { GML = new GMLHandler(null); } schemas = new ArrayList<SchemaIndex>(); typeFactory = new ComplexFeatureTypeFactoryImpl(); descriptorRegistry = new HashMap<Name, AttributeDescriptor>(); typeRegistry = new HashMap<Name, AttributeType>(); anonTypeRegistry = new HashMap<Name, AttributeType>(); processingTypes = new Stack<Name>(); if (FOUNDATION_TYPES.isEmpty()) { createFoundationTypes(); } typeRegistry.putAll(FOUNDATION_TYPES); descriptorRegistry.putAll(FOUNDATION_DESCRIPTORS); }
/** * Determines if elements of the given complex type definition are required to have an * identifier by looking for a child element of <code>typeDefinition</code> of the form * <code><xs:attribute ref="gml:id" use="required" /></code> * * @param typeDefinition * @return */ private boolean isIdentifiable(XSDComplexTypeDefinition typeDefinition) { List attributeUses = typeDefinition.getAttributeUses(); final String idAttName = GML.getId().getLocalPart(); for (Iterator it = attributeUses.iterator(); it.hasNext();) { XSDAttributeUse use = (XSDAttributeUse) it.next(); XSDAttributeUseCategory useCategory = use.getUse(); XSDAttributeDeclaration idAtt = use.getAttributeDeclaration(); String targetNamespace = idAtt.getTargetNamespace(); String name = idAtt.getName(); if (GML.getNameSpace().equals(targetNamespace) && idAttName.equals(name)) { if (XSDAttributeUseCategory.REQUIRED_LITERAL.equals(useCategory)) { return true; } } } return false; }
/** * NOTE: to be called only by {@link #createType(Name, XSDTypeDefinition)} * * @param assignedName * @param schema * @param typeDefinition * @param superType * @return */ private AttributeType createComplexAttributeType(final Name assignedName, final Collection<PropertyDescriptor> schema, final XSDComplexTypeDefinition typeDefinition, final AttributeType superType) { AttributeType abstractFType = getType(GML.getNameSpace(), GML.getAbstractFeatureType().getLocalPart()); assert abstractFType != null; boolean isFeatureType = isDerivedFrom(typeDefinition, abstractFType.getName()); boolean isAbstract = false;// TODO List<Filter> restrictions = Collections.emptyList(); InternationalString description = null; // TODO AttributeType type; if (isFeatureType) { type = typeFactory.createFeatureType(assignedName, schema, null, isAbstract, restrictions, superType, description); } else { boolean isIdentifiable = isIdentifiable((XSDComplexTypeDefinition) typeDefinition); type = typeFactory.createComplexType(assignedName, schema, isIdentifiable, isAbstract, restrictions, superType, description); } return type; }
private AttributeType createProxiedType(final Name assignedName, final XSDTypeDefinition typeDefinition, Map typeRegistry) { AttributeType type; if (null == typeDefinition.getSimpleType() && typeDefinition instanceof XSDComplexTypeDefinition) { boolean isFeatureType = isDerivedFrom(typeDefinition, GML.getAbstractFeatureType()); if (isFeatureType) { type = new FeatureTypeProxy(assignedName, typeRegistry); } else { type = new ComplexTypeProxy(assignedName, typeRegistry); } } else { boolean isGeometryType = isDerivedFrom(typeDefinition, GML.getAbstractGeometryType()); if (isGeometryType) { type = new GeometryTypeProxy(assignedName, typeRegistry); } else { type = new AttributeTypeProxy(assignedName, typeRegistry); } } return type; }