Java源码示例:com.sun.xml.internal.xsom.XSModelGroup
示例1
public boolean isApplicable(XSComplexType ct) {
if( !bgmBuilder.getGlobalBinding().isChoiceContentPropertyEnabled() )
return false;
if( ct.getBaseType()!=schemas.getAnyType() )
// My reading of the spec is that if a complex type is
// derived from another complex type by extension,
// its top level model group is always a sequence
// that combines the base type content model and
// the extension defined in the new complex type.
return false;
XSParticle p = ct.getContentType().asParticle();
if(p==null)
return false;
XSModelGroup mg = getTopLevelModelGroup(p);
if( mg.getCompositor()!=XSModelGroup.CHOICE )
return false;
if( p.isRepeated() )
return false;
return true;
}
示例2
public boolean isApplicable(XSComplexType ct) {
if( !bgmBuilder.getGlobalBinding().isChoiceContentPropertyEnabled() )
return false;
if( ct.getBaseType()!=schemas.getAnyType() )
// My reading of the spec is that if a complex type is
// derived from another complex type by extension,
// its top level model group is always a sequence
// that combines the base type content model and
// the extension defined in the new complex type.
return false;
XSParticle p = ct.getContentType().asParticle();
if(p==null)
return false;
XSModelGroup mg = getTopLevelModelGroup(p);
if( mg.getCompositor()!=XSModelGroup.CHOICE )
return false;
if( p.isRepeated() )
return false;
return true;
}
示例3
private boolean containingChoice(CClassInfo typeBean) {
XSComponent component = typeBean.getSchemaComponent();
if (component instanceof XSComplexType) {
XSContentType contentType = ((XSComplexType) component).getContentType();
XSParticle particle = contentType.asParticle();
if (particle != null) {
XSTerm term = particle.getTerm();
XSModelGroup modelGroup = term.asModelGroup();
if (modelGroup != null) {
return (modelGroup.getCompositor() == XSModelGroup.Compositor.CHOICE);
}
}
}
return false;
}
示例4
public boolean isApplicable(XSComplexType ct) {
if( !bgmBuilder.getGlobalBinding().isChoiceContentPropertyEnabled() )
return false;
if( ct.getBaseType()!=schemas.getAnyType() )
// My reading of the spec is that if a complex type is
// derived from another complex type by extension,
// its top level model group is always a sequence
// that combines the base type content model and
// the extension defined in the new complex type.
return false;
XSParticle p = ct.getContentType().asParticle();
if(p==null)
return false;
XSModelGroup mg = getTopLevelModelGroup(p);
if( mg.getCompositor()!=XSModelGroup.CHOICE )
return false;
if( p.isRepeated() )
return false;
return true;
}
示例5
/**
* Transforms the default name produced from XML name
* by following the customization.
*
* This shouldn't be applied to a class name specified
* by a customization.
*
* @param cmp
* The schema component from which the default name is derived.
*/
public String mangleClassName( String name, XSComponent cmp ) {
if( cmp instanceof XSType )
return nameXmlTransform.typeName.mangle(name);
if( cmp instanceof XSElementDecl )
return nameXmlTransform.elementName.mangle(name);
if( cmp instanceof XSAttributeDecl )
return nameXmlTransform.attributeName.mangle(name);
if( cmp instanceof XSModelGroup || cmp instanceof XSModelGroupDecl )
return nameXmlTransform.modelGroupName.mangle(name);
// otherwise no modification
return name;
}
示例6
public Iterator<T> modelGroup(XSModelGroup group) {
// compensate for particles that are ignored in SCD
return new Iterators.Map<T,XSParticle>(group.iterator()) {
protected Iterator<? extends T> apply(XSParticle p) {
return particle(p);
}
};
}
示例7
public Iterator<T> modelGroup(XSModelGroup group) {
// compensate for particles that are ignored in SCD
return new Iterators.Map<T,XSParticle>(group.iterator()) {
protected Iterator<? extends T> apply(XSParticle p) {
return particle(p);
}
};
}
示例8
public void modelGroup( XSModelGroup mg ) {
boolean oldIOP = insideOptionalParticle;
insideOptionalParticle |= mg.getCompositor()==XSModelGroup.CHOICE;
for( XSParticle p : mg.getChildren())
particle(p);
insideOptionalParticle = oldIOP;
}
示例9
public void modelGroup( XSModelGroup mg ) {
boolean oldIOP = insideOptionalParticle;
insideOptionalParticle |= mg.getCompositor()==XSModelGroup.CHOICE;
for( XSParticle p : mg.getChildren())
particle(p);
insideOptionalParticle = oldIOP;
}
示例10
private void visit(XSModelGroup mg, List<XSComponent> r) {
// since model groups never form a cycle, no cycle check is needed
r.add(mg);
for (XSParticle p : mg) {
XSModelGroup child = p.getTerm().asModelGroup();
if(child!=null)
visit(child,r);
}
}
示例11
private void modelGroup( XSModelGroup group, String extraAtts ) {
println(MessageFormat.format("<{0}{1}>", group.getCompositor(), extraAtts));
indent++;
final int len = group.getSize();
for( int i=0; i<len; i++ )
particle(group.getChild(i));
indent--;
println(MessageFormat.format("</{0}>", group.getCompositor()));
}
示例12
public void modelGroup(XSModelGroup group) {
if(!visited.add(group)) return;
for (XSParticle p : group.getChildren()) {
particle(p);
}
}
示例13
private Iterator<XSModelGroup> filter(XSModelGroup mg) {
if(mg==null)
return empty();
if(mg.getCompositor() == compositor || compositor == null)
return singleton(mg);
else
return empty();
}
示例14
/**
* Iterate all descendant model groups of the given model group, including itself.
*/
private Iterator<XSComponent> descendants(XSModelGroup mg) {
// TODO: write a tree iterator
// for now, we do it eagerly because I'm lazy
List<XSComponent> r = new ArrayList<XSComponent>();
visit(mg,r);
return r.iterator();
}
示例15
public Iterator<T> modelGroup(XSModelGroup group) {
// compensate for particles that are ignored in SCD
return new Iterators.Map<T,XSParticle>(group.iterator()) {
protected Iterator<? extends T> apply(XSParticle p) {
return particle(p);
}
};
}
示例16
public void modelGroup(XSModelGroup group) {
if(!visited.add(group)) return;
for (XSParticle p : group.getChildren()) {
particle(p);
}
}
示例17
private void modelGroup( XSModelGroup group, String extraAtts ) {
println(MessageFormat.format("<{0}{1}>", group.getCompositor(), extraAtts));
indent++;
final int len = group.getSize();
for( int i=0; i<len; i++ )
particle(group.getChild(i));
indent--;
println(MessageFormat.format("</{0}>", group.getCompositor()));
}
示例18
/**
* Transforms the default name produced from XML name
* by following the customization.
*
* This shouldn't be applied to a class name specified
* by a customization.
*
* @param cmp
* The schema component from which the default name is derived.
*/
public String mangleClassName( String name, XSComponent cmp ) {
if( cmp instanceof XSType )
return nameXmlTransform.typeName.mangle(name);
if( cmp instanceof XSElementDecl )
return nameXmlTransform.elementName.mangle(name);
if( cmp instanceof XSAttributeDecl )
return nameXmlTransform.attributeName.mangle(name);
if( cmp instanceof XSModelGroup || cmp instanceof XSModelGroupDecl )
return nameXmlTransform.modelGroupName.mangle(name);
// otherwise no modification
return name;
}
示例19
public Iterator<T> modelGroup(XSModelGroup group) {
// compensate for particles that are ignored in SCD
return new Iterators.Map<T,XSParticle>(group.iterator()) {
protected Iterator<? extends T> apply(XSParticle p) {
return particle(p);
}
};
}
示例20
/**
* Iterate all descendant model groups of the given model group, including itself.
*/
private Iterator<XSComponent> descendants(XSModelGroup mg) {
// TODO: write a tree iterator
// for now, we do it eagerly because I'm lazy
List<XSComponent> r = new ArrayList<XSComponent>();
visit(mg,r);
return r.iterator();
}
示例21
/**
* Iterate all descendant model groups of the given model group, including itself.
*/
private Iterator<XSComponent> descendants(XSModelGroup mg) {
// TODO: write a tree iterator
// for now, we do it eagerly because I'm lazy
List<XSComponent> r = new ArrayList<XSComponent>();
visit(mg,r);
return r.iterator();
}
示例22
private Iterator<XSModelGroup> filter(XSModelGroup mg) {
if(mg==null)
return empty();
if(mg.getCompositor() == compositor || compositor == null)
return singleton(mg);
else
return empty();
}
示例23
/**
* Creates node for model group with additional attributes.
*
* @param group Model group.
* @param extraAtts Additional attributes.
*/
private void modelGroup(XSModelGroup group, String extraAtts) {
SchemaTreeNode newNode = new SchemaTreeNode(MessageFormat.format(
"{0}{1}", new Object[]{group.getCompositor(), extraAtts}),
group.getLocator());
this.currNode.add(newNode);
this.currNode = newNode;
final int len = group.getSize();
for (int i = 0; i < len; i++) {
particle(group.getChild(i));
}
this.currNode = (SchemaTreeNode) this.currNode.getParent();
}
示例24
/**
* Creates node for model group with additional attributes.
*
* @param group Model group.
* @param extraAtts Additional attributes.
*/
private void modelGroup(XSModelGroup group, String extraAtts) {
SchemaTreeNode newNode = new SchemaTreeNode(MessageFormat.format(
"{0}{1}", new Object[]{group.getCompositor(), extraAtts}),
group.getLocator());
this.currNode.add(newNode);
this.currNode = newNode;
final int len = group.getSize();
for (int i = 0; i < len; i++) {
particle(group.getChild(i));
}
this.currNode = (SchemaTreeNode) this.currNode.getParent();
}
示例25
/**
* Transforms the default name produced from XML name
* by following the customization.
*
* This shouldn't be applied to a class name specified
* by a customization.
*
* @param cmp
* The schema component from which the default name is derived.
*/
public String mangleClassName( String name, XSComponent cmp ) {
if( cmp instanceof XSType )
return nameXmlTransform.typeName.mangle(name);
if( cmp instanceof XSElementDecl )
return nameXmlTransform.elementName.mangle(name);
if( cmp instanceof XSAttributeDecl )
return nameXmlTransform.attributeName.mangle(name);
if( cmp instanceof XSModelGroup || cmp instanceof XSModelGroupDecl )
return nameXmlTransform.modelGroupName.mangle(name);
// otherwise no modification
return name;
}
示例26
private void modelGroup( XSModelGroup group, String extraAtts ) {
println(MessageFormat.format("<{0}{1}>", group.getCompositor(), extraAtts));
indent++;
final int len = group.getSize();
for( int i=0; i<len; i++ )
particle(group.getChild(i));
indent--;
println(MessageFormat.format("</{0}>", group.getCompositor()));
}
示例27
public void modelGroup(XSModelGroup group) {
if(!visited.add(group)) return;
for (XSParticle p : group.getChildren()) {
particle(p);
}
}
示例28
public void modelGroup(XSModelGroup group) {
if(!visited.add(group)) return;
for (XSParticle p : group.getChildren()) {
particle(p);
}
}
示例29
private void visit(XSModelGroup mg, List<XSComponent> r) {
// since model groups never form a cycle, no cycle check is needed
r.add(mg);
for (XSParticle p : mg) {
XSModelGroup child = p.getTerm().asModelGroup();
if(child!=null)
visit(child,r);
}
}
示例30
public void modelGroup(XSModelGroup group) {
if(check(group)) {
for( int i=0; i<group.getSize(); i++ )
group.getChild(i).visit(this);
}
}