private boolean isGroupTypeWithMultipleOccurs(XSTypeDefinition type) { return type instanceof XSComplexTypeDefinition && isGroupTypeWithMultipleOccurs(((XSComplexTypeDefinition) type).getParticle()); }
private void analyzeComplexType(XSComplexTypeDefinition complexType, String parentName, String namespace) { // Prevent reentrancy if (processed.contains(complexType)) { return; } processed.add(complexType); String name = analyzeType(complexType, parentName, namespace); analyzeParticle(complexType.getParticle(), name, namespace); }
public boolean getGeometryTypesFromGeometryProperty( XSElementDeclaration element, List result) { XSTypeDefinition type = element.getTypeDefinition(); if ((type instanceof XSComplexTypeDefinition)) { XSComplexTypeDefinition complexType = (XSComplexTypeDefinition) type; XSParticle particle = complexType.getParticle(); if (particle == null) return false; return getGeometryTypesFromGeometryProperty(particle, result); } return false; }
public boolean getTopologyTypesFromTopologyProperty( XSElementDeclaration element, List result) { XSTypeDefinition type = element.getTypeDefinition(); if ((type instanceof XSComplexTypeDefinition)) { XSComplexTypeDefinition complexType = (XSComplexTypeDefinition) type; XSParticle particle = complexType.getParticle(); if (particle == null) return false; return getTopologyTypesFromTopologyProperty(particle, result); } return false; }
/** * Collects names of schema elements that are defined with the ref:swaRef * schema type. * @param xsType a schema type. * @return a list of names found. */ private List collectSwaRefs(XSTypeDefinition xsType) { List swaRefs = new ArrayList(); if (xsType != null) { // If this is a complex type if (xsType.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) { XSComplexTypeDefinition xsComplexType = (XSComplexTypeDefinition) xsType; // If it contains mixed context if (xsComplexType.getParticle() != null) { // collecting element names swaRefs.addAll(collectSwaRefs(xsComplexType.getParticle().getTerm())); } } } return swaRefs; }
public Collection getProperties(XSElementDeclaration element) { List properties = new ArrayList(); XSComplexTypeDefinition complexType = (XSComplexTypeDefinition) element .getTypeDefinition(); if (complexType == null) { complexType = element.getEnclosingCTDefinition(); } setProperties(properties, complexType.getParticle()); return properties; }
public Collection getPropertyNames() { List properties = new ArrayList(); XSComplexTypeDefinition complexType = (XSComplexTypeDefinition) this.element .getTypeDefinition(); if (complexType == null) { complexType = this.element.getEnclosingCTDefinition(); } setPropertyNames(properties, this.element, complexType.getParticle()); return properties; }
public Collection getMandatoryPropertyNames() { List properties = new ArrayList(); XSComplexTypeDefinition complexType = (XSComplexTypeDefinition) this.element .getTypeDefinition(); if (complexType == null) { complexType = this.element.getEnclosingCTDefinition(); } setMandatoryPropertyNames(properties, this.element, complexType.getParticle()); return properties; }
public GmlPropertyDefinition getProperty(String propertyNamespaceUri, String propertyLocalName) { XSComplexTypeDefinition complexType = (XSComplexTypeDefinition) this.element .getTypeDefinition(); if (complexType == null) { complexType = this.element.getEnclosingCTDefinition(); } return getProperty(complexType.getParticle(), propertyNamespaceUri, propertyLocalName); }
public Collection getPropertyNames(XSElementDeclaration element) { List properties = new ArrayList(); if (isFeature(element)) { XSComplexTypeDefinition complexType = (XSComplexTypeDefinition) element .getTypeDefinition(); if (complexType == null) { complexType = element.getEnclosingCTDefinition(); } setPropertyNames(properties, element, complexType.getParticle()); } return properties; }
private Pair<XSElementDeclaration, Boolean> getTargetElement( Pair<XSElementDeclaration, Boolean> context, QName elName, int num ) { XSTypeDefinition typeDef = context.getFirst().getTypeDefinition(); if ( !( typeDef instanceof XSComplexTypeDefinition ) ) { throw new IllegalArgumentException( "XPath refers to a simple type definition." ); } XSParticle particle = ( (XSComplexTypeDefinition) typeDef ).getParticle(); if ( particle == null ) { throw new IllegalArgumentException( "XPath refers to an empty type definition." ); } return getTargetElementTerm( new Pair<XSTerm, Boolean>( particle.getTerm(), null ), elName, num ); }
public Collection getSimpleTypeProperties(XSElementDeclaration element) { List properties = new ArrayList(); if (isFeature(element)) { XSComplexTypeDefinition complexType = (XSComplexTypeDefinition) element .getTypeDefinition(); if (complexType == null) { complexType = element.getEnclosingCTDefinition(); } setSimpleTypeProperties(properties, element, complexType.getParticle()); } return properties; }
List<PropertyDeclaration> getProperties( XSElementDeclaration elementDecl ) { List<PropertyDeclaration> properties = new ArrayList<PropertyDeclaration>(); XSComplexTypeDefinition complexType = (XSComplexTypeDefinition) elementDecl.getTypeDefinition(); switch ( complexType.getContentType() ) { case XSComplexTypeDefinition.CONTENTTYPE_MIXED: case XSComplexTypeDefinition.CONTENTTYPE_ELEMENT: { XSParticle particle = complexType.getParticle(); collectProperties( particle, properties ); break; } case XSComplexTypeDefinition.CONTENTTYPE_EMPTY: case XSComplexTypeDefinition.CONTENTTYPE_SIMPLE: { break; } default: { // cannot happen } } return properties; }
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 XSParticle getEnclosingParticle( XSElementDeclaration elDecl ) { XSComplexTypeDefinition enclosingDef = elDecl.getEnclosingCTDefinition(); if ( enclosingDef != null ) { List<XSParticle> particles = getAllElementParticles( enclosingDef.getParticle() ); for ( XSParticle xp : particles ) { XSTerm term = xp.getTerm(); if ( term.getType() == ELEMENT_DECLARATION ) { XSElementDeclaration currentElDecl = (XSElementDeclaration) term; if ( elDecl.equals( currentElDecl ) ) { return xp; } } } } return null; }
private List<Schema.Field> createFields(XSComplexTypeDefinition type) { final Map<String, Schema.Field> fields = new LinkedHashMap<>(); XSObjectList attrUses = type.getAttributeUses(); for (int i = 0; i < attrUses.getLength(); i++) { XSAttributeUse attrUse = (XSAttributeUse) attrUses.item(i); XSAttributeDeclaration attrDecl = attrUse.getAttrDeclaration(); boolean optional = !attrUse.getRequired(); Schema.Field field = createField(fields.values(), attrDecl, attrDecl.getTypeDefinition(), optional, false); fields.put(field.getProp(Source.SOURCE), field); } XSParticle particle = type.getParticle(); if (particle == null) return new ArrayList<>(fields.values()); XSTerm term = particle.getTerm(); if (term.getType() != XSConstants.MODEL_GROUP) throw new ConverterException("Unsupported term type " + term.getType()); XSModelGroup group = (XSModelGroup) term; createGroupFields(group, fields, false); return new ArrayList<>(fields.values()); }
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); } } }
public JBossXSComplexTypeDefinition(XSComplexTypeDefinition xc) { super(xc.getName(),xc.getNamespace()); setAnonymous(xc.getAnonymous()); xspart = xc.getParticle(); xsSimple = xc.getSimpleType(); deriveMethod = xc.getDerivationMethod(); this.baseType = new JBossXSTypeDefinition(xc.getBaseType()); }
public boolean validateFeature(XSElementDeclaration featureElement) { boolean featureValid = true; if (!isFeature(featureElement)) { reportError(featureElement.getNamespace(), featureElement.getName(), "A feature's type definition must extend from gml:AbstractFeatureType."); featureValid = false; } XSComplexTypeDefinition complexType = (XSComplexTypeDefinition) featureElement .getTypeDefinition(); if (complexType == null) { complexType = featureElement.getEnclosingCTDefinition(); } if (!containsOnlyProperties(featureElement, complexType.getParticle())) { featureValid = false; } return featureValid; }
public static XSElementDeclaration unwrapArrayType(XSTypeDefinition xst) { if (xst instanceof XSComplexTypeDefinition == false) return null; XSComplexTypeDefinition xc = (XSComplexTypeDefinition)xst; if (xc.getContentType() == XSComplexTypeDefinition.CONTENTTYPE_EMPTY) return null; XSParticle xsp = xc.getParticle(); if (xsp == null) return null; XSTerm xsterm = xsp.getTerm(); if (xsterm instanceof XSModelGroup == false) return null; XSModelGroup xm = (XSModelGroup)xsterm; XSObjectList xo = xm.getParticles(); if (xo.getLength() != 1) return null; XSParticle xp = (XSParticle)xo.item(0); XSTerm term = xp.getTerm(); if ((xp.getMaxOccursUnbounded() || xp.getMaxOccurs() > 1) == false || term instanceof XSElementDeclaration == false) return null; return (XSElementDeclaration)term; }