private final boolean comparable_value_spaces(SchemaType t1, SchemaType t2) { assert(t1.getSimpleVariety() != SchemaType.UNION && t2.getSimpleVariety() != SchemaType.UNION); if (!t1.isSimpleType() && !t2.isSimpleType()) return (t1.getContentType() == t2.getContentType()); if (!t1.isSimpleType() || !t2.isSimpleType()) return false; if (t1.getSimpleVariety() == SchemaType.LIST && t2.getSimpleVariety() == SchemaType.LIST) return true; if (t1.getSimpleVariety() == SchemaType.LIST || t2.getSimpleVariety() == SchemaType.LIST) return false; return (t1.getPrimitiveType().equals(t2.getPrimitiveType())); }
private static boolean isStringType(SchemaType type) { if (type == null || type.getSimpleVariety() != SchemaType.ATOMIC) return false; return (type.getPrimitiveType().getBuiltinTypeCode() == SchemaType.BTC_STRING); }
static boolean xmlTypeForPropertyIsUnion(SchemaProperty sProp) { SchemaType sType = sProp.javaBasedOnType(); return (sType.isSimpleType() && sType.getSimpleVariety() == SchemaType.UNION); }
synchronized XmlAnySimpleType get() { if (_obj == null) { SchemaType type = _typeref.get(); if (type.getSimpleVariety() != SchemaType.LIST) _obj = type.newValue(_initVal); else { List actualVals = new ArrayList(); for (Iterator i = ((List)_initVal).iterator(); i.hasNext(); ) { XmlValueRef ref = (XmlValueRef)i.next(); actualVals.add(ref.get()); } _obj = type.newValue(actualVals); } } return _obj; } }
public boolean isInstanceOf(SchemaType type) { SchemaType myType; if (type.getSimpleVariety() != SchemaType.UNION) { for (myType = instanceType(); myType != null; myType = myType.getBaseType()) if (type == myType) return true; return false; } else { Set ctypes = new HashSet(Arrays.asList(type.getUnionConstituentTypes())); for (myType = instanceType(); myType != null; myType = myType.getBaseType()) if (ctypes.contains(myType)) return true; return false; } }
void startClass(SchemaType sType, boolean isInner) throws IOException { String shortName = sType.getShortJavaImplName(); String baseClass = getBaseClass(sType); StringBuffer interfaces = new StringBuffer(); interfaces.append(sType.getFullJavaName().replace('$', '.')); if (sType.getSimpleVariety() == SchemaType.UNION) { SchemaType[] memberTypes = sType.getUnionMemberTypes(); for (int i = 0 ; i < memberTypes.length ; i++) interfaces.append(", " + memberTypes[i].getFullJavaName().replace('$', '.')); } emit("public " + ( isInner ? "static ": "" ) + "class " + shortName + " extends " + baseClass + " implements " + interfaces.toString()); startBlock(); emit("private static final long serialVersionUID = 1L;"); }
private static boolean logical_overlap(SchemaType type, int javacode) assert(type.getSimpleVariety() != SchemaType.UNION); if (type.getSimpleVariety() != SchemaType.ATOMIC) return false; if (type.getSimpleVariety() != SchemaType.ATOMIC) return false; if (type.getSimpleVariety() != SchemaType.ATOMIC) return false; if (type.getSimpleVariety() != SchemaType.ATOMIC) return false; if (type.getSimpleVariety() != SchemaType.ATOMIC) return false; return (type.getSimpleVariety() == SchemaType.LIST);
private boolean validateSimpleType ( SchemaType type, String value, Event event ) { if (!type.isSimpleType() && type.getContentType() != SchemaType.SIMPLE_CONTENT) { assert false; throw new RuntimeException( "Not a simple type" ); } int retState = _errorState; switch ( type.getSimpleVariety() ) { case SchemaType.ATOMIC : validateAtomicType( type, value, event );break; case SchemaType.UNION : validateUnionType( type, value, event );break; case SchemaType.LIST : validateListType( type, value, event );break; default : throw new RuntimeException( "Unexpected simple variety" ); } return retState == _errorState; }
private static boolean checkAllDerivationsForRestriction(SchemaType baseType, SchemaType derivedType, Collection errors, XmlObject context) { boolean allDerivationsAreRestrictions = true; SchemaType currentType = derivedType; // XMLBEANS-66: if baseType is a union, check restriction is of one of the constituant types Set possibleTypes = null; if (baseType.getSimpleVariety() == SchemaType.UNION) possibleTypes = new HashSet(Arrays.asList(baseType.getUnionConstituentTypes())); // run up the types hierarchy from derived Type to base Type and make sure that all are derived by // restriction. If any are not then this is not a valid restriction. while (!baseType.equals(currentType) && possibleTypes != null && !possibleTypes.contains(currentType)) { if (currentType.getDerivationType() == SchemaType.DT_RESTRICTION) { currentType = currentType.getBaseType(); } else { allDerivationsAreRestrictions = false; errors.add(XmlError.forObject(XmlErrorCodes.PARTICLE_RESTRICTION_NAME_AND_TYPE$TYPE_RESTRICTED, new Object[] { printType(derivedType), printType(baseType), printType(currentType) }, context)); break; } } return allDerivationsAreRestrictions; }
String getBaseClass(SchemaType sType) { SchemaType baseType = findBaseType(sType.getBaseType()); switch (sType.getSimpleVariety()) { case SchemaType.NOT_SIMPLE: // non-simple-content: inherit from base type impl if (!XmlObject.type.equals(baseType)) return baseType.getFullJavaImplName(); return "org.apache.xmlbeans.impl.values.XmlComplexContentImpl"; case SchemaType.ATOMIC: // We should only get called for restrictions assert(! sType.isBuiltinType()); return getAtomicRestrictionType(sType); case SchemaType.LIST: return "org.apache.xmlbeans.impl.values.XmlListImpl"; case SchemaType.UNION: return "org.apache.xmlbeans.impl.values.XmlUnionImpl"; default: throw new IllegalStateException(); } }
private static String notes(SchemaType sType) { if (sType.isBuiltinType()) return " (builtin)"; if (sType.isSimpleType()) { switch (sType.getSimpleVariety()) { case SchemaType.LIST: return " (list)"; case SchemaType.UNION: return " (union)"; default: if (sType.getEnumerationValues() != null) return " (enumeration)"; return ""; } } switch (sType.getContentType()) { case SchemaType.MIXED_CONTENT: return " (mixed)"; case SchemaType.SIMPLE_CONTENT: return " (complex)"; default: return ""; } }
void printConstructor(SchemaType sType, String shortName) throws IOException { emit(""); emit("public " + shortName + "(org.apache.xmlbeans.SchemaType sType)"); startBlock(); emit("super(sType" + (sType.getSimpleVariety() == SchemaType.NOT_SIMPLE ? "": ", " + !sType.isSimpleType()) + ");"); endBlock(); if (sType.getSimpleVariety() != SchemaType.NOT_SIMPLE) { emit(""); emit("protected " + shortName + "(org.apache.xmlbeans.SchemaType sType, boolean b)"); startBlock(); emit("super(sType, b);"); endBlock(); } }
private final boolean valueEqualsImpl(XmlObject xmlobj) { check_dated(); SchemaType typethis = instanceType(); SchemaType typeother = ((SimpleValue)xmlobj).instanceType(); if (typethis == null && typeother == null) // detects nil return true; if (typethis == null || typeother == null) return false; if (!comparable_value_spaces(typethis, typeother)) return false; if (xmlobj.schemaType().getSimpleVariety() == SchemaType.UNION) return (underlying(xmlobj)).equal_to(this); return equal_to(xmlobj); }
if (sType.getSimpleVariety() == SchemaType.UNION) sType = sType.getUnionCommonBaseType(); assert sType.getBaseEnumType() != null;
if (instanceType.getSimpleVariety() == SchemaType.LIST) return ((SimpleValue)obj).getListValue();
else if (getOuterType().getContentBasedOnType() == this) prefix = "S="; else if (getOuterType().getSimpleVariety() == SchemaType.LIST) prefix = "I="; else if (getOuterType().getSimpleVariety() == SchemaType.UNION) prefix = "M=" + getAnonymousUnionMemberOrdinal(); else
else if (iType.getSimpleVariety() == SchemaType.LIST)
else if (outerType.getSimpleVariety() == SchemaType.LIST) return "item type of " + readable(outerType, nsPrefix); else if (outerType.getSimpleVariety() == SchemaType.UNION) return "member type " + sType.getAnonymousUnionMemberOrdinal() + " of " + readable(outerType, nsPrefix); else
sImpl.setComplexTypeVariety(SchemaType.SIMPLE_CONTENT); sImpl.setContentModel(null, attrModel, null, attributePropertyModel, false); sImpl.setSimpleTypeVariety(baseType.getSimpleVariety()); sImpl.setPrimitiveTypeRef(baseType.getPrimitiveType() == null ? null : baseType.getPrimitiveType().getRef()); switch (sImpl.getSimpleVariety())
emit(" * An anonymous inner XML type."); emit(" *"); switch (sType.getSimpleVariety())