/** * Returns the set of all descriptors of a complex type, including from supertypes. * * @param type The type, non null. * @return The list of all descriptors. */ public static List<PropertyDescriptor> descriptors(ComplexType type) { // get list of descriptors from types and all supertypes List<PropertyDescriptor> children = new ArrayList<PropertyDescriptor>(); ComplexType loopType = type; while (loopType != null) { children.addAll(loopType.getDescriptors()); loopType = loopType.getSuper() instanceof ComplexType ? (ComplexType) loopType.getSuper() : null; } return children; }
/** * Return true if name is the name of a descriptor of the type or of an ancestor type. * * @param type type to test * @param name name of descriptor * @return true if the type or an ancestor has a descriptor of this name */ private boolean isValidDescriptor(ComplexType type, Name name) { if (type.getDescriptor(name) != null) { return true; } else if (type.getSuper() instanceof ComplexType) { return isValidDescriptor((ComplexType) type.getSuper(), name); } else { return false; } }
/** * Returns the set of descriptors matching the given name. * * @param type The type, non null. * @param name The name, non null. * @return The list of descriptors named 'name', or an empty list if none such match. */ public static List /* <PropertyDescriptor> */ descriptors(ComplexType type, Name name) { if (name == null) return Collections.EMPTY_LIST; List match = new ArrayList(); for (Iterator itr = type.getDescriptors().iterator(); itr.hasNext(); ) { PropertyDescriptor descriptor = (PropertyDescriptor) itr.next(); Name descriptorName = descriptor.getName(); if (name.equals(descriptorName)) { match.add(descriptor); } } // only look up in the super type if the descriptor is not found // as a direct child definition if (match.size() == 0) { AttributeType superType = type.getSuper(); if (superType instanceof ComplexType) { List superDescriptors = descriptors((ComplexType) superType, name); match.addAll(superDescriptors); } } return match; }
/** * Returns the set of descriptors matching the given local name within the given type. * * @param type The type, non null. * @param name The name, non null. * @return The list of descriptors named 'name', or an empty list if none such match. */ public static List /* <PropertyDescriptor> */ descriptors(ComplexType type, String name) { if (name == null) return Collections.EMPTY_LIST; List match = new ArrayList(); for (Iterator itr = type.getDescriptors().iterator(); itr.hasNext(); ) { PropertyDescriptor descriptor = (PropertyDescriptor) itr.next(); String localPart = descriptor.getName().getLocalPart(); if (name.equals(localPart)) { match.add(descriptor); } } // only look up in the super type if the descriptor is not found // as a direct child definition if (match.size() == 0) { AttributeType superType = type.getSuper(); if (superType instanceof ComplexType) { List superDescriptors = descriptors((ComplexType) superType, name); match.addAll(superDescriptors); } } return match; }
AttributeType superType = schema.getSuper(); if (superType instanceof ComplexType) { return node((ComplexType) superType, name);
/** * Returns the set of all descriptors of a complex type, including from supertypes. * * @param type * The type, non null. * * @return The list of all descriptors. */ public static List<PropertyDescriptor> descriptors(ComplexType type) { //get list of descriptors from types and all supertypes List<PropertyDescriptor> children = new ArrayList<PropertyDescriptor>(); ComplexType loopType = type; while (loopType != null) { children.addAll(loopType.getDescriptors()); loopType = loopType.getSuper() instanceof ComplexType? (ComplexType) loopType.getSuper() : null; } return children; }
assertTrue(testType instanceof FeatureType); AttributeType superType = testType.getSuper(); assertNotNull(superType); Types.descriptor(phenomenonPropertyType, name(SWENS, "Phenomenon")); ComplexType phenomenonType = (ComplexType) phenomenon.getType(); assertNotNull(phenomenonType.getSuper()); assertEquals(typeName(GMLNS, "DefinitionType"), phenomenonType.getSuper().getName());
AttributeType superType = type.getSuper(); if (superType instanceof ComplexType) { List superDescriptors = descriptors((ComplexType) superType, name);
AttributeType superType = type.getSuper(); if (superType instanceof ComplexType) { List superDescriptors = descriptors((ComplexType) superType, name);
/** * Tests if the schema-to-FM parsing code developed for complex data store configuration loading * can parse the GeoSciML types * * @throws Exception */ @Test public void testParseSchema() throws Exception { SchemaIndex schemaIndex = loadSchema("http://schemas.opengis.net/GeoSciML/Gsml.xsd"); AppSchemaFeatureTypeRegistry typeRegistry = new AppSchemaFeatureTypeRegistry(); try { typeRegistry.addSchemas(schemaIndex); Name typeName = Types.typeName(GSMLNS, "GeologicUnitType"); ComplexType mf = (ComplexType) typeRegistry.getAttributeType(typeName); assertNotNull(mf); assertTrue(mf instanceof FeatureType); AttributeType superType = mf.getSuper(); assertNotNull(superType); Name superTypeName = Types.typeName(GSMLNS, "GeologicFeatureType"); assertEquals(superTypeName, superType.getName()); assertTrue(superType instanceof FeatureType); } finally { typeRegistry.disposeSchemaIndexes(); } }
AttributeType superType = schema.getSuper(); if (superType instanceof ComplexType) { return node((ComplexType) superType, name);
assertTrue(testType instanceof FeatureType); AttributeType superType = testType.getSuper(); assertNotNull(superType); phenomenonPropertyType, name(SWENS, "Phenomenon")); ComplexType phenomenonType = (ComplexType) phenomenon.getType(); assertNotNull(phenomenonType.getSuper()); assertEquals(typeName(GMLNS, "DefinitionType"), phenomenonType.getSuper().getName());
/** * Tests if the schema-to-FM parsing code developed for complex data store configuration loading * can parse the GeoSciML types * * @throws Exception */ @Test public void testParseSchema() throws Exception { SchemaIndex schemaIndex = loadSchema("http://schemas.opengis.net/GeoSciML/Gsml.xsd"); FeatureTypeRegistry typeRegistry = new FeatureTypeRegistry(); try { typeRegistry.addSchemas(schemaIndex); Name typeName = Types.typeName(GSMLNS, "GeologicUnitType"); ComplexType mf = (ComplexType) typeRegistry.getAttributeType(typeName); assertNotNull(mf); assertTrue(mf instanceof FeatureType); AttributeType superType = mf.getSuper(); assertNotNull(superType); Name superTypeName = Types.typeName(GSMLNS, "GeologicFeatureType"); assertEquals(superTypeName, superType.getName()); assertTrue(superType instanceof FeatureType); } finally { typeRegistry.disposeSchemaIndexes(); } }