/** * The number of <code>XSObjects</code> in the <code>XSObjectList</code>. The range of valid child * node indices is 0 to <code>length-1</code> inclusive. */ public synchronized int getLength() { if (fLength == -1) { // first get the number of components for all types int length = 0; for (int i = 0; i < fNSNum; i++) length += fMaps[i].getLength(); // then copy all types to an temporary array int pos = 0; XSObject[] array = new XSObject[length]; for (int i = 0; i < fNSNum; i++) { pos += fMaps[i].getValues(array, pos); } // then copy either simple or complex types to fArray, // depending on which kind is required fLength = 0; fArray = new XSObject[length]; XSTypeDefinition type; for (int i = 0; i < length; i++) { type = (XSTypeDefinition) array[i]; if (type.getTypeCategory() == fType) { fArray[fLength++] = type; } } } return fLength; }
/** * Retrieves an <code>XSObject</code> specified by local name and namespace URI. * * @param namespace The namespace URI of the <code>XSObject</code> to retrieve. * @param localName The local name of the <code>XSObject</code> to retrieve. * @return A <code>XSObject</code> (of any type) with the specified local name and namespace URI, * or <code>null</code> if they do not identify any <code>XSObject</code> in this map. */ public XSObject itemByName(String namespace, String localName) { if (namespace != null) namespace = namespace.intern(); for (int i = 0; i < fNSNum; i++) { if (namespace == fNamespaces[i]) { XSTypeDefinition type = (XSTypeDefinition) fMaps[i].get(localName); // only return it if it mataches the required type if (type.getTypeCategory() == fType) return type; return null; } } return null; }
/** * this method shows how to query information about the different properties of 'Simple Type' * definiton schema component. It prints the values of properties of 'SimpleType Definition Schema * Component'. * * @param simpleType object of XSSimpleType */ public void querySimpleType(XSSimpleType simpleType) { // getting information about the different properties of 'Simple Type' definition schema // component. System.err.println(); System.err.println("Properties information of 'Simple Type' definiton schema component"); System.err.println(); // 'name' property if (simpleType.getAnonymous()) System.err.println("Anonymous Simple Type"); else { System.err.println("'name' \t\t\t\t: " + simpleType.getName()); } // 'target namespace' property String targetNameSpace = simpleType.getNamespace(); System.err.println("'target namespace' \t\t: " + targetNameSpace); // 'variety' property short variety = simpleType.getVariety(); printVariety(variety); // 'base type definition' property XSTypeDefinition baseType = (XSTypeDefinition) simpleType.getBaseType(); System.err.println( "'base type definition' name \t: " + (baseType != null ? baseType.getName() : "null")); System.err.println( "'base type definition' target namespace : " + (baseType != null ? baseType.getNamespace() : "null")); // check if base type is simple or complex if (baseType != null && (baseType.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE)) { // now we can get all the details of base type XSSimpleType simpleTypeDecl = (XSSimpleType) baseType; } // 'facets' property // gives bit combination of the constants defined in XSSimpleType interface. short facets = simpleType.getDefinedFacets(); printFacets(facets); // 'final' property // the explicit values of this property extension, restriction, list and union prevent further // derivations by extension (to yield a complex type) and restriction (to yield a simple type) // and use in constructing lists and unions respectively. short finalSet = simpleType.getFinal(); printFinal(finalSet); // if variety is 'list' if (variety == XSSimpleType.VARIETY_LIST) { // 'Item Type definition' property of List Simple Type Definition Schema Component. XSSimpleType listDecl = (XSSimpleType) simpleType.getItemType(); } else if (variety == XSSimpleType.VARIETY_UNION) { // 'Member Type definitions' property of Union Simple Type Definition Schema Component. XSObjectList memberTypes = simpleType.getMemberTypes(); } // fundamental facet information // ordered schema component short ordered = simpleType.getOrdered(); printOrdered(ordered); // bounded schema component boolean bounded = simpleType.getBounded(); if (bounded) { System.err.println("'bounded' \t\t\t\t: true"); } else { System.err.println("'bounded' \t\t\t\t: false"); } // cardinality schema component boolean isFinite = simpleType.getFinite(); printCardinality(isFinite); // numeric schema component boolean numeric = simpleType.getNumeric(); if (numeric) { System.err.println("'numeric' \t\t\t\t: true"); } else { System.err.println("'numeric' \t\t\t\t: false"); } } // getInformation()