private List types(XSDTypeDefinition base) { List types = (List) cache.get(base); if (types == null) { types = new ArrayList(); XSDTypeDefinition type = base; while (type != null) { types.add(type); // get the next type if (type.equals(type.getBaseType())) { break; } type = type.getBaseType(); } cache.put(base, types); } return types; }
/** * Determines if the type of an element is a sub-type of another element. * * @param e1 The element. * @param e2 The element to be tested as a base type. * @since 2.5 */ public static final boolean isBaseType(XSDElementDeclaration e1, XSDElementDeclaration e2) { XSDTypeDefinition type = e1.getType(); while (type != null) { if (type.equals(e2.getType())) { return true; } if (type.equals(type.getBaseType())) { break; } type = type.getBaseType(); } return false; } /**
private static void visitElements( XSDComplexTypeDefinition cType, ElementVisitor visitor, boolean includeParents) { if (includeParents) { LinkedList baseTypes = new LinkedList(); XSDTypeDefinition baseType = cType.getBaseType(); while ((baseType != null) && (baseType != baseType.getBaseType())) { if (baseType instanceof XSDComplexTypeDefinition) { baseTypes.addLast(baseType); } baseType = baseType.getBaseType(); } for (Iterator it = baseTypes.iterator(); it.hasNext(); ) { baseType = (XSDTypeDefinition) it.next(); visitElements((XSDComplexTypeDefinition) baseType, visitor); } } visitElements(cType, visitor); }
/** * Returns true if the <code>typeDefinition</code> is based on provided <code>superNS</code>. * * @param typeDefinition * @param superNS * @return */ private static boolean isBasedOn(XSDTypeDefinition typeDefinition, final String superNS) { XSDTypeDefinition baseType; String targetNamespace; String name; while ((baseType = typeDefinition.getBaseType()) != null) { targetNamespace = baseType.getTargetNamespace(); name = baseType.getName(); if (XS.NAMESPACE.equals(targetNamespace) && XS.ANYTYPE.getLocalPart().equals(name)) { // break the loop or this goes forever return false; } if (superNS.equals(targetNamespace)) { return true; } typeDefinition = baseType; } return false; }
/** * Returns a list of all top level elements that are of a type derived from the type of the * specified element. * * @param element The element. * @return All elements which are of a type derived from the type of the specified element. */ public static final List getDerivedElementDeclarations(XSDElementDeclaration element) { List elements = element.getSchema().getElementDeclarations(); List derived = new ArrayList(); for (Iterator itr = elements.iterator(); itr.hasNext(); ) { XSDElementDeclaration derivee = (XSDElementDeclaration) itr.next(); if (derivee.equals(element)) { continue; // same element } XSDTypeDefinition type = derivee.getType(); while (true) { if (type.equals(element.getType())) { derived.add(derivee); break; } if (type.equals(type.getBaseType())) { break; } type = type.getBaseType(); } } return derived; }
if (type.equals(type.getBaseType())) { break; type = type.getBaseType();
/** * Returns <code>true</code> if <code>typeDefinition</code> is derived from a type named <code> * superTypeName</code> * * @param typeDefinition * @param superTypeName * @return */ private static boolean isDerivedFrom( XSDTypeDefinition typeDefinition, final Name superTypeName) { XSDTypeDefinition baseType; final String superNS = superTypeName.getNamespaceURI(); final String superName = superTypeName.getLocalPart(); String targetNamespace; String name; while ((baseType = typeDefinition.getBaseType()) != null) { targetNamespace = baseType.getTargetNamespace(); name = baseType.getName(); if (XS.NAMESPACE.equals(targetNamespace) && XS.ANYTYPE.getLocalPart().equals(name)) { return false; } if (superNS.equals(targetNamespace) && superName.equals(name)) { return true; } typeDefinition = baseType; } return false; }
XSDTypeDefinition baseType = contentType.getBaseType(); if (contentType.equals(baseType)) { contentType = null;
/** * Uses EMF reflection to create an instance of the EMF model object this binding maps to. * * <p>The properties of the resulting object are set using the the contents of * <param>node</param>. In the case that the name of a child element or attributes does not * match the name of a property on the object, subclasses may wish to extend this method and set * the property explicitly. */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { // does this binding actually map to an eObject? if (EObject.class.isAssignableFrom(getType()) && (factory != null)) { EObject eObject = createEObject(value); if (eObject == null) { return value; } setProperties(eObject, node, false); setProperties(eObject, node, true); // check for a complex type with simpleContent, in this case use // the string value (if any) to set the value property if (instance.getElementDeclaration().getTypeDefinition().getBaseType() instanceof XSDTypeDefinition) { if ((value != null) && EMFUtils.has(eObject, "value")) { setProperty(eObject, "value", value, false); } } return eObject; } // could not do it, just return whatever was passed in return value; }
final XSDTypeDefinition baseType = typeDefinition.getBaseType();
&& type.getBaseType() instanceof XSDSimpleTypeDefinition) {
private List types( XSDTypeDefinition base ) { List types = (List) cache.get( base ); if ( types == null ) { types = new ArrayList(); XSDTypeDefinition type = base; while (type != null) { types.add( type ); //get the next type if (type.equals(type.getBaseType())) { break; } type = type.getBaseType(); } cache.put( base, types ); } return types; }
private List types(XSDTypeDefinition base) { List types = (List) cache.get(base); if (types == null) { types = new ArrayList(); XSDTypeDefinition type = base; while (type != null) { types.add(type); //get the next type if (type.equals(type.getBaseType())) { break; } type = type.getBaseType(); } cache.put(base, types); } return types; }
private List types(XSDTypeDefinition base) { List types = (List) cache.get(base); if (types == null) { types = new ArrayList(); XSDTypeDefinition type = base; while (type != null) { types.add(type); //get the next type if (type.equals(type.getBaseType())) { break; } type = type.getBaseType(); } cache.put(base, types); } return types; }
public XSDTypeDefinition getRootTypeDefinition() { XSDTypeDefinition result = this; if (!isCircular()) { for (XSDTypeDefinition theBaseType= result.getBaseType(); theBaseType!= null && !XSDConstants.isURType(theBaseType); theBaseType = theBaseType.getBaseType()) { result = theBaseType; } } return result; }
public XSDTypeDefinition getRootTypeDefinition() { XSDTypeDefinition result = this; if (!isCircular()) { for (XSDTypeDefinition theBaseType= result.getBaseType(); theBaseType!= null && !XSDConstants.isURType(theBaseType); theBaseType = theBaseType.getBaseType()) { result = theBaseType; } } return result; }
public Object caseXSDTypeDefinition(XSDTypeDefinition typeDefinition) { XSDConcreteComponent target = null; XSDTypeDefinition baseType = typeDefinition.getBaseType(); if (baseType != null) { target = baseType; } // Avoid navigating to built in data types. if (isFromSchemaForSchema(target)) { target = null; } return target; }
private static void visitElements(XSDComplexTypeDefinition cType, ElementVisitor visitor, boolean includeParents) { if(includeParents){ LinkedList baseTypes = new LinkedList(); XSDTypeDefinition baseType = cType.getBaseType(); while(baseType != null && baseType != baseType.getBaseType()){ if(baseType instanceof XSDComplexTypeDefinition){ baseTypes.addLast(baseType); } baseType = baseType.getBaseType(); } for(Iterator it = baseTypes.iterator(); it.hasNext();){ baseType = (XSDTypeDefinition) it.next(); visitElements((XSDComplexTypeDefinition) baseType, visitor); } } visitElements(cType, visitor); }
public IType getSuperType() { XSDTypeDefinition td = getXSDTypeDefinition().getBaseType(); return td != null ? (IType)XSDAdapterFactory.getInstance().adapt(td) : null; }
public IType getSuperType() { XSDTypeDefinition td = getXSDTypeDefinition().getBaseType(); // test to filter out the 'anyType' type ... don't want to see that // if (td != null && !td.getName().equals("anyType")) //$NON-NLS-1$ { return (IType) XSDAdapterFactory.getInstance().adapt(td); } return null; }