public boolean isComplexType() { return (xsTypeDefinition.getTypeCategory() & XSConstants.PARTICLE) != 0; }
public boolean isSimpleValued() { if (this.type.getTypeCategory() == 14) { return true; } if (this.type.getTypeCategory() == 13) { int contentType = ((XSComplexTypeDefinition) this.type) .getContentType(); return contentType == 1; } return false; }
public boolean isTypeComplex() { if(currentElementType == null) { throw new JBossXBRuntimeException("There is no current element!"); } return currentElementType.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE; }
/** * @see org.apache.ode.utils.xsd.SchemaModel#isSimpleType(javax.xml.namespace.QName) */ public boolean isSimpleType(QName type) { if (type == null) throw new NullPointerException("Null type argument!"); XSTypeDefinition typeDef = _model.getTypeDefinition(type.getLocalPart(), type.getNamespaceURI()); return (typeDef != null) && (typeDef.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE); }
/** * check whether simple type derived is valid derived from base, * given a subset of {restriction, extension}. */ public boolean checkSimpleDerivationOk(XSSimpleType derived, XSTypeDefinition base, short block) { // if derived is anySimpleType, then it's valid only if the base // is ur-type if (derived == SchemaGrammar.fAnySimpleType) { return (base == fAnyType || base == SchemaGrammar.fAnySimpleType); } // if base is complex type if (base.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) { // if base is anyType, change base to anySimpleType, // otherwise, not valid if (base == fAnyType) base = SchemaGrammar.fAnySimpleType; else return false; } return checkSimpleDerivation((XSSimpleType)derived, (XSSimpleType)base, block); }
private TypeBinding bindType(XSTypeDefinition type) { TypeBinding binding; switch(type.getTypeCategory()) { case XSTypeDefinition.SIMPLE_TYPE: binding = bindSimpleType((XSSimpleTypeDefinition)type); break; case XSTypeDefinition.COMPLEX_TYPE: binding = bindComplexType((XSComplexTypeDefinition)type); break; default: throw new JBossXBRuntimeException("Unexpected type category: " + type.getTypeCategory()); } return binding; }
private void exportType( XMLStreamWriter writer, XSTypeDefinition type ) throws XMLStreamException { short typeCat = type.getTypeCategory(); if ( typeCat == SIMPLE_TYPE ) { exportSimpleType( writer, (XSSimpleTypeDefinition) type ); } else if ( typeCat == COMPLEX_TYPE ) { exportComplexType( writer, (XSComplexTypeDefinition) type ); } }
public void printSimpleTypesSummary( String namespace ) { XSNamedMap elementMap = schema.getComponentsByNamespace( XSConstants.TYPE_DEFINITION, namespace ); SortedSet<String> simpleTypeNames = new TreeSet<String>(); for ( int i = 0; i < elementMap.getLength(); i++ ) { XSTypeDefinition typeDef = (XSTypeDefinition) elementMap.item( i ); if ( typeDef.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE ) { System.out.println( toString( ( (XSSimpleTypeDefinition) typeDef ) ) ); simpleTypeNames.add( typeDef.getName() ); } } System.out.println( simpleTypeNames.size() + " simple types in namespace: '" + namespace + "':\n" ); for ( String typeName : simpleTypeNames ) { System.out.println( typeName ); } }
public void printComplexTypesSummary( String namespace ) { XSNamedMap elementMap = schema.getComponentsByNamespace( XSConstants.TYPE_DEFINITION, namespace ); SortedSet<String> complexTypeNames = new TreeSet<String>(); for ( int i = 0; i < elementMap.getLength(); i++ ) { XSTypeDefinition typeDef = (XSTypeDefinition) elementMap.item( i ); if ( typeDef.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE ) { System.out.println( toString( ( (XSComplexTypeDefinition) typeDef ) ) ); complexTypeNames.add( typeDef.getName() ); } } System.out.println( complexTypeNames.size() + " complex types in namespace: '" + namespace + "':\n" ); for ( String typeName : complexTypeNames ) { System.out.println( typeName ); } }
private void analyzeElement(XSElementDeclaration element, String parentName, String namespace, Integer minOccurs, Integer maxOccurs) { String name = element.getName(); if (element.getScope() != XSConstants.SCOPE_GLOBAL) { name = parentName + ">" + name; anonymousElementMap.put(namespace + ":" + name, element); } if (maxOccurs != null && maxOccurs.intValue() > 1) { String key = namespace + ":" + name + "[" + minOccurs.intValue() + "," + maxOccurs.intValue() + "]"; anonymousTypeMap.put(key, createArrayWrapperComplexType(element, name, namespace, minOccurs, maxOccurs)); if (minOccurs.intValue() == 1) { key = namespace + ":" + name + "[" + "," + maxOccurs.intValue() + "]"; anonymousTypeMap.put(key, createArrayWrapperComplexType(element, name, namespace, minOccurs, maxOccurs)); } } XSTypeDefinition type = element.getTypeDefinition(); if (type.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) analyzeComplexType((XSComplexTypeDefinition)type, name, namespace); if (type.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) analyzeSimpleType((XSSimpleTypeDefinition)type, name, namespace); }
/** * 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) { for (int i = 0; i < fNSNum; i++) { if (isEqual(namespace, fNamespaces[i])) { XSTypeDefinition type = (XSTypeDefinition)fMaps[i].get(localName); // only return it if it matches the required type if (type != null && type.getTypeCategory() == fType) { return type; } return null; } } return null; }
private static boolean isArrayWrapper(XSTypeDefinition type) { boolean is = false; if(XSTypeDefinition.COMPLEX_TYPE == type.getTypeCategory()) { XSComplexTypeDefinition cType = (XSComplexTypeDefinition)type; XSParticle particle = cType.getParticle(); if(particle != null) { is = particle.getMaxOccursUnbounded() || particle.getMaxOccurs() > 1; } } return is; }
private static boolean checkBooleanType(XSTypeDefinition td) { if (td.getTypeCategory() != XSTypeDefinition.SIMPLE_TYPE) { return false; } final XSSimpleTypeDefinition st = ((XSSimpleTypeDefinition) td); final XSObjectList facets = st.getFacets(); for (int i = 0; i < facets.getLength(); i++) { final XSFacet facet = (XSFacet) facets.item(i); if (facet.getFacetKind() == XSSimpleTypeDefinition.FACET_LENGTH) { if ("0".equals(facet.getLexicalFacetValue())) { return true; } } } return false; }
private List getAssertsForEvaluation(QName element, XMLAttributes attributes) { List assertionList = null; XSTypeDefinition typeDefn = fXmlSchemaValidator.fCurrentPSVI.getTypeDefinition(); if (typeDefn != null) { if (typeDefn.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) { // if element's schema type is a "complex type" XSObjectListImpl complexTypeAsserts = getAssertsFromComplexType((XSComplexTypeDefinition) typeDefn, attributes); if (complexTypeAsserts.size() > 0) { assertionList = complexTypeAsserts; } } else { // if element's schema type is a "simple type" assertionList = getAssertsFromSimpleType((XSSimpleTypeDefinition) typeDefn); } } return assertionList; } // getAssertsForEvaluation
protected void handleContent(XSTypeDefinition type, boolean nillable, Object actualValue, short valueType, ShortList itemValueType) { if (type == null || type.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE && ((XSComplexTypeDefinition) type).getContentType() != XSComplexTypeDefinition.CONTENTTYPE_SIMPLE) { // the content must be simpleType content fStore.reportError( "cvc-id.3", new Object[] { fIdentityConstraint.getName(), fStore.getElementName()}); } fMatchedString = actualValue; matched(fMatchedString, valueType, itemValueType, nillable); } // handleContent(XSElementDecl, String)
private XSElementDecl findLocallyDeclaredType(QName element, XSCMValidator currentCM, XSTypeDefinition baseType) { XSElementDecl elemDecl = null; if (currentCM != null) { elemDecl = currentCM.findMatchingElemDecl(element, fSubGroupHandler); } if (elemDecl == null) { if (baseType.getTypeCategory() != XSTypeDefinition.SIMPLE_TYPE && baseType != SchemaGrammar.getXSAnyType(fSchemaVersion)) { currentCM = ((XSComplexTypeDecl) baseType).getContentModel(fCMBuilder); return findLocallyDeclaredType(element, currentCM, baseType.getBaseType()); } } return elemDecl; }
/** * Element/Attribute traversers call this method to check whether * the type is NOTATION without enumeration facet */ void checkNotationType(String refName, XSTypeDefinition typeDecl, Element elem) { if (typeDecl.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE && ((XSSimpleType)typeDecl).getVariety() == XSSimpleType.VARIETY_ATOMIC && ((XSSimpleType)typeDecl).getPrimitiveKind() == XSSimpleType.PRIMITIVE_NOTATION) { if ((((XSSimpleType)typeDecl).getDefinedFacets() & XSSimpleType.FACET_ENUMERATION) == 0) { reportSchemaError("enumeration-required-notation", new Object[]{typeDecl.getName(), refName, DOMUtil.getLocalName(elem)}, elem); } } }
private void addBaseTypeParts(XSTypeDefinition baseType, List<XSParticle> xsparts) { if (baseType == null) throw MESSAGES.illegalNullArgumentInSchemaMapping("baseType"); if (XSTypeDefinition.COMPLEX_TYPE == baseType.getTypeCategory()) { XSTypeDefinition btype = baseType.getBaseType(); if (btype != null) addBaseTypeParts(btype, xsparts); //Recurse //Just add the particles from this basetype as a ModelGroup sequence XSParticle part = ((XSComplexTypeDefinition)baseType).getParticle(); XSTerm term = part.getTerm(); if (term instanceof XSModelGroup) { JBossXSParticle p = new JBossXSParticle(); p.setTerm(term); xsparts.add(p); } } }
private Schema createTypeSchema(XSTypeDefinition type, boolean optional, boolean array) { typeLevel++; Schema schema; if (type.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) schema = Schema.create(getPrimitiveType((XSSimpleTypeDefinition) type)); else { String name = complexTypeName(type); debug("Creating schema for type " + name); schema = schemas.get(name); if (schema == null) schema = createRecordSchema(name, (XSComplexTypeDefinition) type); } if (array || isGroupTypeWithMultipleOccurs(type)) schema = Schema.createArray(schema); else if (optional) { Schema nullSchema = Schema.create(Schema.Type.NULL); schema = Schema.createUnion(Arrays.asList(nullSchema, schema)); } typeLevel--; return schema; }
String generateTypeHierarchy( XSTypeDefinition type, String indent ) { String s = "\n" + indent + "-> '" + type.getName() + "' (" + type.getNamespace() + "'): "; switch ( type.getTypeCategory() ) { case XSTypeDefinition.SIMPLE_TYPE: { s += "simple"; break; } case XSTypeDefinition.COMPLEX_TYPE: { s += "complex"; break; } default: { // cannot happen } } if ( type.getBaseType() != null && type.getBaseType() != type ) { s += generateTypeHierarchy( type.getBaseType(), " " + indent ); } return s; }