Java源码示例:com.sun.xml.xsom.XSComplexType
示例1
/**
* Implements
* <code>Validation Rule: Schema-Validity Assessment (Element) 1.2.1.2.4</code>
*/
private static boolean isSubstitutable( XSType _base, XSType derived ) {
// too ugly to the point that it's almost unbearable.
// I mean, it's not even transitive. Thus we end up calling this method
// for each candidate
if( _base.isComplexType() ) {
XSComplexType base = _base.asComplexType();
for( ; base!=derived; derived=derived.getBaseType() ) {
if( base.isSubstitutionProhibited( derived.getDerivationMethod() ) )
return false; // Type Derivation OK (Complex)-1
}
return true;
} else {
// simple type don't have any @block
return true;
}
}
示例2
public Iterator<XSAttributeUse> iterateAttributeUses() {
XSComplexType baseType = getBaseType().asComplexType();
if( baseType==null ) return super.iterateAttributeUses();
return new Iterators.Union<XSAttributeUse>(
new Iterators.Filter<XSAttributeUse>(baseType.iterateAttributeUses()) {
protected boolean matches(XSAttributeUse value) {
XSAttributeDecl u = value.getDecl();
UName n = new UName(u.getTargetNamespace(),u.getName());
return !prohibitedAtts.contains(n);
}
},
super.iterateAttributeUses() );
}
示例3
private static Collection<? extends XSDeclaration> findModelGroups(final XSComplexType complexType) {
XSContentType contentType = complexType.getExplicitContent();
if (contentType == null) {
contentType = complexType.getContentType();
}
final XSParticle particle = contentType.asParticle();
if (particle != null && !particle.isRepeated()) {
final XSTerm term = particle.getTerm();
if (term instanceof XSModelGroupDecl) {
return Collections.singletonList((XSModelGroupDecl)term);
} else {
final XSModelGroup modelGroup = term.asModelGroup();
return modelGroup != null ? findModelGroups(modelGroup) : Collections.<XSModelGroupDecl>emptyList();
}
} else {
return Collections.emptyList();
}
}
示例4
private static void _valueToDocument( Value value, Element element, Document doc, XSType type ) {
addForcedAttribute( value, element );
if( type.isSimpleType() ) {
element.appendChild( doc.createTextNode( value.strValue() ) );
} else if( type.isComplexType() ) {
String name;
Value currValue;
XSComplexType complexType = type.asComplexType();
// Iterate over attributes
Collection< ? extends XSAttributeUse > attributeUses = complexType.getAttributeUses();
for( XSAttributeUse attrUse : attributeUses ) {
name = attrUse.getDecl().getName();
if( (currValue = getAttributeOrNull( value, name )) != null ) {
element.setAttribute( name, currValue.strValue() );
}
}
XSContentType contentType = complexType.getContentType();
XSParticle particle = contentType.asParticle();
if( contentType.asSimpleType() != null ) {
element.appendChild( doc.createTextNode( value.strValue() ) );
} else if( particle != null ) {
XSTerm term = particle.getTerm();
XSModelGroupDecl modelGroupDecl;
XSModelGroup modelGroup = null;
if( (modelGroupDecl = term.asModelGroupDecl()) != null ) {
modelGroup = modelGroupDecl.getModelGroup();
} else if( term.isModelGroup() ) {
modelGroup = term.asModelGroup();
}
if( modelGroup != null ) {
_valueToDocument( value, element, doc, modelGroup );
}
}
}
}
示例5
private TypeDefinition loadComplexType( XSComplexType complexType, boolean lazy, TypeDefinition lazyType )
throws ConversionException {
XSParticle particle;
XSContentType contentType;
contentType = complexType.getContentType();
if( (particle = contentType.asParticle()) == null ) {
return null;// createAnyOrUndefined( complexType.getName(), complexType );
}
TypeInlineDefinition jolieType;
if( lazy ) {
jolieType = (TypeInlineDefinition) lazyType;
} else {
jolieType =
createComplexType( complexType, complexType.getName().replace( "-", "_" ) + TYPE_SUFFIX, particle );
}
if( contentType.asSimpleType() != null ) {
checkStrictModeForSimpleType( contentType );
} else if( (particle = contentType.asParticle()) != null ) {
XSTerm term = particle.getTerm();
XSModelGroup modelGroup = getModelGroup( term );
if( modelGroup != null ) {
groupProcessing( modelGroup, particle, jolieType );
}
}
return jolieType;
}
示例6
private TypeInlineDefinition createAnyOrUndefined( String typeName, XSComplexType complexType ) {
TypeInlineDefinition jolieType =
new TypeInlineDefinition( PARSING_CONTEXT, typeName, NativeType.ANY, Constants.RANGE_ONE_TO_ONE );
if( !complexType.isMixed() ) {
jolieType.setUntypedSubTypes( true );
}
return jolieType;
}
示例7
private TypeInlineDefinition createComplexType( XSComplexType complexType, String typeName, XSParticle particle ) {
if( complexType.isMixed() ) {
return new TypeInlineDefinition( PARSING_CONTEXT, typeName, NativeType.ANY, getRange( particle ) );
} else {
return new TypeInlineDefinition( PARSING_CONTEXT, typeName, NativeType.VOID, getRange( particle ) );
}
}
示例8
public Iterator<XSComplexType> iterateComplexTypes() {
return new Iterators.Map<XSComplexType,XSSchema>(iterateSchema()) {
protected Iterator<XSComplexType> apply(XSSchema u) {
return u.iterateComplexTypes();
}
};
}
示例9
public void schema(XSSchema s) {
// QUICK HACK: don't print the built-in components
if (s.getTargetNamespace().equals(Const.schemaNamespace)) {
return;
}
SchemaTreeNode newNode = new SchemaTreeNode("Schema "
+ s.getLocator().getSystemId(), s.getLocator());
this.currNode = newNode;
this.model.addSchemaNode(newNode);
for (XSAttGroupDecl groupDecl : s.getAttGroupDecls().values()) {
attGroupDecl(groupDecl);
}
for (XSAttributeDecl attrDecl : s.getAttributeDecls().values()) {
attributeDecl(attrDecl);
}
for (XSComplexType complexType : s.getComplexTypes().values()) {
complexType(complexType);
}
for (XSElementDecl elementDecl : s.getElementDecls().values()) {
elementDecl(elementDecl);
}
for (XSModelGroupDecl modelGroupDecl : s.getModelGroupDecls().values()) {
modelGroupDecl(modelGroupDecl);
}
for (XSSimpleType simpleType : s.getSimpleTypes().values()) {
simpleType(simpleType);
}
}
示例10
/**
* Creates node for complex type.
*
* @param type Complex type.
*/
private void dumpComplexTypeAttribute(XSComplexType type) {
Iterator itr;
itr = type.iterateAttGroups();
while (itr.hasNext()) {
dumpRef((XSAttGroupDecl) itr.next());
}
itr = type.iterateDeclaredAttributeUses();
while (itr.hasNext()) {
attributeUse((XSAttributeUse) itr.next());
}
}
示例11
private void dumpComplexTypeAttribute( XSComplexType type ) {
Iterator itr;
itr = type.iterateAttGroups();
while(itr.hasNext())
dumpRef( (XSAttGroupDecl)itr.next() );
itr = type.iterateDeclaredAttributeUses();
while(itr.hasNext())
attributeUse( (XSAttributeUse)itr.next() );
}
示例12
public Iterator<T> complexType(XSComplexType type) {
// compensate particle
XSParticle p = type.getContentType().asParticle();
if(p!=null)
return particle(p);
else
return empty();
}
示例13
public Iterator<XSComponent> elementDecl(XSElementDecl decl) {
XSComplexType ct = decl.getType().asComplexType();
if(ct==null)
return empty();
else {
// also pick up model groups inside this complex type
return new Iterators.Union<XSComponent>(singleton(ct),complexType(ct));
}
}
示例14
private void dumpComplexTypeAttribute( XSComplexType type ) {
Iterator<?> itr;
itr = type.iterateAttGroups();
while(itr.hasNext())
dumpRef( (XSAttGroupDecl)itr.next() );
itr = type.iterateDeclaredAttributeUses();
while(itr.hasNext())
attributeUse( (XSAttributeUse)itr.next() );
XSWildcard awc = type.getAttributeWildcard();
if(awc!=null)
wildcard("anyAttribute",awc,"");
}
示例15
private static XSComplexType getTypeDefinition(final XSComponent xsTypeComponent) {
if (xsTypeComponent instanceof XSAttContainer) {
return (XSComplexType) xsTypeComponent;
} else if (xsTypeComponent instanceof XSElementDecl) {
return ((XSElementDecl) xsTypeComponent).getType().asComplexType();
} else {
return null;
}
}
示例16
@Override
public QName complexType(final XSComplexType type) {
if (type.getName() == null) {
return new QName(type.getTargetNamespace(), "anonymousComplexType");
} else {
return new QName(type.getTargetNamespace(), type.getName());
}
}
示例17
@Override
public QName complexType(final XSComplexType type) {
if (type.getName() == null) {
return new QName(type.getTargetNamespace(), "anonymousComplexType");
} else {
return new QName(type.getTargetNamespace(), type.getName());
}
}
示例18
public void complexType(XSComplexType type) {
if (shouldWalk && visited.add(type.getContentType())) {
type.getContentType().visit(this);
for (XSAttributeUse u : type.getAttributeUses())
if (shouldWalk && visited.add(u))
attributeUse(u);
}
}
示例19
public void schema( XSSchema s ) {
// QUICK HACK: don't print the built-in components
if(s.getTargetNamespace().equals(Const.schemaNamespace))
return;
println(MessageFormat.format("<schema targetNamespace=\"{0}\">", s.getTargetNamespace()));
indent++;
Iterator<?> itr;
itr = s.iterateAttGroupDecls();
while(itr.hasNext())
attGroupDecl( (XSAttGroupDecl)itr.next() );
itr = s.iterateAttributeDecls();
while(itr.hasNext())
attributeDecl( (XSAttributeDecl)itr.next() );
itr = s.iterateComplexTypes();
while(itr.hasNext())
complexType( (XSComplexType)itr.next() );
itr = s.iterateElementDecls();
while(itr.hasNext())
elementDecl( (XSElementDecl)itr.next() );
itr = s.iterateModelGroupDecls();
while(itr.hasNext())
modelGroupDecl( (XSModelGroupDecl)itr.next() );
itr = s.iterateSimpleTypes();
while(itr.hasNext())
simpleType( (XSSimpleType)itr.next() );
indent--;
println("</schema>");
}
示例20
private void dumpComplexTypeAttribute( XSComplexType type ) {
Iterator<?> itr;
itr = type.iterateAttGroups();
while(itr.hasNext())
dumpRef( (XSAttGroupDecl)itr.next() );
itr = type.iterateDeclaredAttributeUses();
while(itr.hasNext())
attributeUse( (XSAttributeUse)itr.next() );
XSWildcard awc = type.getAttributeWildcard();
if(awc!=null)
wildcard("anyAttribute",awc,"");
}
示例21
private String getPrefix( XSComplexType compType ) {
return namespacePrefixMap.get( compType.getOwnerSchema().getTargetNamespace() );
}
示例22
/**
* @see com.sun.xml.xsom.visitor.XSFunction#complexType(com.sun.xml.xsom.XSComplexType)
*/
public Boolean complexType(XSComplexType type) {
return Boolean.FALSE;
}
示例23
public T complexType(XSComplexType type) {
return core.complexType(type);
}
示例24
public String complexType(XSComplexType type) {
return localize("complexType");
}
示例25
/**
* @see com.sun.xml.xsom.visitor.XSFunction#complexType(XSComplexType)
*/
public String complexType(XSComplexType type) {
String name = type.getName();
if( name == null ) name = "anonymous";
return name + " " + nameGetter.complexType( type );
}
示例26
public XSComplexType getComplexType( String ns, String localName ) {
XSSchema schema = getSchema(ns);
if(schema==null) return null;
return schema.getComplexType(localName);
}
示例27
public void addComplexType(XSComplexType newDecl, boolean overwrite) {
if(overwrite || !complexTypes.containsKey(newDecl.getName())) {
complexTypes.put(newDecl.getName(), newDecl);
allTypes.put(newDecl.getName(), newDecl);
}
}
示例28
public Map<String,XSComplexType> getComplexTypes() {
return complexTypesView;
}
示例29
public XSComplexType getComplexType(String name) {
return complexTypes.get(name);
}
示例30
public Iterator<XSComplexType> iterateComplexTypes() {
return complexTypes.values().iterator();
}