Java源码示例:com.sun.xml.xsom.XSParticle

示例1
private void groupProcessing(
	Value value,
	XSElementDecl xsDecl,
	SOAPElement element,
	SOAPEnvelope envelope,
	boolean first,
	XSModelGroup modelGroup,
	XSSchemaSet sSet,
	String messageNamespace )
	throws SOAPException {

	XSParticle[] children = modelGroup.getChildren();
	XSTerm currTerm;
	for( XSParticle child : children ) {
		currTerm = child.getTerm();
		if( currTerm.isModelGroup() ) {
			groupProcessing( value, xsDecl, element, envelope, first, currTerm.asModelGroup(), sSet,
				messageNamespace );
		} else {
			termProcessing( value, element, envelope, first, currTerm, child.getMaxOccurs(), sSet,
				messageNamespace );
		}
	}
}
 
示例2
private void groupProcessing( XSModelGroup modelGroup, XSParticle particle, TypeInlineDefinition jolieType )
	throws ConversionException {
	XSModelGroup.Compositor compositor = modelGroup.getCompositor();
	// We handle "all" and "sequence", but not "choice"
	if( compositor.equals( XSModelGroup.ALL ) || compositor.equals( XSModelGroup.SEQUENCE ) ) {
		if( compositor.equals( XSModelGroup.SEQUENCE ) ) {
			log( Level.WARNING, WARNING_SEQUENCE );
		}

		for( XSParticle currParticle : modelGroup.getChildren() ) {
			XSTerm currTerm = currParticle.getTerm();
			if( currTerm.isModelGroup() ) {
				groupProcessing( currTerm.asModelGroup(), particle, jolieType );
			} else {
				// Create the new complex type for root types
				navigateSubTypes( currParticle, jolieType );
			}
		}
	} else if( compositor.equals( XSModelGroup.CHOICE ) ) {
		throw new ConversionException( ERROR_CHOICE );
	}

}
 
示例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
public Multiplicity modelGroup(XSModelGroup group) {
	boolean isChoice = group.getCompositor() == XSModelGroup.CHOICE;

	Multiplicity r = null;

	for (XSParticle p : group.getChildren()) {
		Multiplicity m = particle(p);

		if (r == null) {
			r = m;
			continue;
		}
		if (isChoice) {
			r = Multiplicity.choice(r, m);
		} else {
			r = Multiplicity.group(r, m);
		}
	}
	if (r == null)
	{
		return ZERO;
	}
	return r;
}
 
示例5
@Override
public Multiplicity particle(XSParticle p) {

	Multiplicity m = p.getTerm().apply(this.counter);

	BigInteger max;
	if (m.max == null
			|| (BigInteger.valueOf(XSParticle.UNBOUNDED).equals(p
					.getMaxOccurs())))
		max = null;
	else
		max = p.getMaxOccurs();

	return Multiplicity.multiply(m,
			Multiplicity.create(p.getMinOccurs(), max));
}
 
示例6
private void termProcessing( Value value, SOAPElement element, SOAPEnvelope envelope, boolean first,
	XSTerm currTerm, int getMaxOccur,
	XSSchemaSet sSet, String messageNamespace )
	throws SOAPException {
	Value currValue = value.clone();
	if( currTerm.isElementDecl() ) {
		ValueVector vec;
		XSElementDecl currElementDecl = currTerm.asElementDecl();
		String name = currElementDecl.getName();
		String prefix = (first) ? getPrefix( currElementDecl ) : getPrefixOrNull( currElementDecl );
		SOAPElement childElement;
		if( (vec = currValue.children().get( name )) != null ) {
			int k = 0;
			while( vec.size() > 0 && (getMaxOccur > k || getMaxOccur == XSParticle.UNBOUNDED) ) {
				if( prefix == null ) {
					childElement = element.addChildElement( name );
				} else {
					childElement = element.addChildElement( name, prefix );
				}
				Value v = vec.remove( 0 );
				valueToTypedSOAP(
					v,
					currElementDecl,
					childElement,
					envelope,
					false,
					sSet,
					messageNamespace );
				k++;
			}
		}
	}

}
 
示例7
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 );
			}
		}
	}
}
 
示例8
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;


}
 
示例9
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 ) );
	}
}
 
示例10
private Range getRange( XSParticle part ) {
	int min = 1;
	int max = Integer.MAX_VALUE;

	if( part.getMinOccurs() != -1 ) {
		min = part.getMinOccurs();
	}

	if( part.getMaxOccurs() != -1 ) {
		max = part.getMaxOccurs();
	}

	return new Range( min, max );
}
 
示例11
public Iterator<T> complexType(XSComplexType type) {
    // compensate particle
    XSParticle p = type.getContentType().asParticle();
    if(p!=null)
        return particle(p);
    else
        return empty();
}
 
示例12
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);
        }
    };
}
 
示例13
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);
    }
}
 
示例14
private static List<XSModelGroupDecl> findModelGroups(final Iterable<XSParticle> modelGroup) {
	final List<XSModelGroupDecl> elementDecls = new ArrayList<>();
	for (final XSParticle child : modelGroup) {
		if (!child.isRepeated() && (child.getTerm() instanceof XSModelGroupDecl)) {
			elementDecls.add((XSModelGroupDecl) child.getTerm());
		}
	}
	return elementDecls;
}
 
示例15
private List<PropertyUse> findElementDecls(final XSModelGroupDecl modelGroup) {
	final List<PropertyUse> elementDecls = new ArrayList<>();
	for (final XSParticle child : modelGroup.getModelGroup()) {
		XSTerm term = child.getTerm();
		if (term instanceof XSElementDecl) {
			elementDecls.add(new PropertyUse(term));
		} else if (term instanceof XSModelGroupDecl && ((XSModelGroupDecl)term).getName().equals(modelGroup.getName())) {
			elementDecls.addAll(findElementDecls((XSModelGroupDecl)term));
		}
	}
	return elementDecls;
}
 
示例16
public Multiplicity particle(XSParticle p) {
	Multiplicity m = p.getTerm().apply(this);

	BigInteger max;
	if (m == null
			|| m.max == null
			|| (BigInteger.valueOf(XSParticle.UNBOUNDED).equals(p
					.getMaxOccurs())))
		max = null;
	else
		max = p.getMaxOccurs();

	return Multiplicity.multiply(m,
			Multiplicity.create(p.getMinOccurs(), max));
}
 
示例17
private void createGroup(XSModelGroupDecl modelGroupDecl) {
	EClass eClass = ecoreFactory.createEClass();
	eClass.setName(modelGroupDecl.getName());
	ePackage.getEClassifiers().add(eClass);
	for (XSParticle particle : modelGroupDecl.getModelGroup().getChildren()) {
		XSTerm term = particle.getTerm();
		if (term.isElementDecl()) {
			String name = term.asElementDecl().getName();
			EClassifier subClass = ePackage.getEClassifier(name);
			if (subClass != null && subClass instanceof EClass) {
				((EClass) subClass).getESuperTypes().add(eClass);
			}
		}
	}
}
 
示例18
public Iterator<XSParticle> iterator() {
    return Arrays.asList((XSParticle[])children).iterator();
}
 
示例19
public void modelGroup(XSModelGroup group) {
	for (XSParticle child : group.getChildren()) {
		child.visit(this);
	}
}
 
示例20
public void modelGroup(XSModelGroup group) {
	for (XSParticle child : group.getChildren()) {
		child.visit(this);
	}
}
 
示例21
private void traverseChilds(XSTerm rfTerm) {

		if (rfTerm.isModelGroupDecl()) {

			XSModelGroupDecl rfmodelGD = rfTerm.asModelGroupDecl();

			XSModelGroup rfmodelG = rfmodelGD.getModelGroup();
			XSParticle[] rfparrs = rfmodelG.getChildren();
			for (XSParticle rfpar : rfparrs) {
				XSTerm rfsterm = rfpar.getTerm();
				if (rfsterm.isElementDecl()) {
					XSComplexType rfcomp = rfsterm.asElementDecl().getType()
							.asComplexType();
					if (rfcomp != null) {
						traverseChilds(rfsterm);
					}

				} else {
					traverseChilds(rfsterm);
				}
			}
		} else if (rfTerm.isModelGroup()) {
			XSModelGroup rmodel = rfTerm.asModelGroup();
			XSParticle[] rparrs = rmodel.getChildren();
			for (XSParticle rpar : rparrs) {
				if (rpar != null) {
					XSTerm rterm = rpar.getTerm();
					if (rterm.isElementDecl()) {
						childelements.add(rterm.asElementDecl());
						XSComplexType rcomp = rterm.asElementDecl().getType()
								.asComplexType();
						if (rcomp != null) {
							traverseChilds(rterm);
						}
					} else {
						traverseChilds(rterm);
					}

				}
			}
		} else {
			XSComplexType rtcomp = rfTerm.asElementDecl().getType()
					.asComplexType();
			XSContentType rfxscont = rtcomp.getContentType();
			XSParticle rfparticle = rfxscont.asParticle();
			if (rfparticle != null) {
				XSTerm rsterm = rfparticle.getTerm();
				traverseChilds(rsterm);
			} else {
				childelements.add(rfTerm.asElementDecl());
			}
		}
	}
 
示例22
public void modelGroup(XSModelGroup group) {
	for (XSParticle child : group.getChildren()) {
		child.visit(this);
	}
}
 
示例23
public void modelGroup(XSModelGroup group) {
	for (XSParticle child : group.getChildren()) {
		child.visit(this);
	}
}
 
示例24
public void modelGroup(XSModelGroup group) {
	for (XSParticle p : group.getChildren())
		if (shouldWalk && visited.add(p))
			particle(p);
}
 
示例25
public XSParticle asParticle() { return null; } 
示例26
public XSParticle asParticle()      { return this; } 
示例27
public final XSParticle asParticle()      { return null; } 
示例28
public XSParticle asParticle()      { return null; }