本文整理汇总了Java中com.sun.org.apache.xerces.internal.impl.xs.XSParticleDecl.PARTICLE_MODELGROUP属性的典型用法代码示例。如果您正苦于以下问题:Java XSParticleDecl.PARTICLE_MODELGROUP属性的具体用法?Java XSParticleDecl.PARTICLE_MODELGROUP怎么用?Java XSParticleDecl.PARTICLE_MODELGROUP使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.sun.org.apache.xerces.internal.impl.xs.XSParticleDecl
的用法示例。
在下文中一共展示了XSParticleDecl.PARTICLE_MODELGROUP属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeParticle
private boolean removeParticle(XSModelGroupImpl group, XSParticleDecl particle) {
XSParticleDecl member;
for (int i = 0; i < group.fParticleCount; i++) {
member = group.fParticles[i];
if (member == particle) {
for (int j = i; j < group.fParticleCount-1; j++)
group.fParticles[j] = group.fParticles[j+1];
group.fParticleCount--;
return true;
}
if (member.fType == XSParticleDecl.PARTICLE_MODELGROUP) {
if (removeParticle((XSModelGroupImpl)member.fValue, particle))
return true;
}
}
return false;
}
示例2: getErrorContent
private static XSParticleDecl getErrorContent() {
if (fErrorContent == null) {
XSParticleDecl particle = new XSParticleDecl();
particle.fType = XSParticleDecl.PARTICLE_WILDCARD;
particle.fValue = getErrorWildcard();
particle.fMinOccurs = 0;
particle.fMaxOccurs = SchemaSymbols.OCCURRENCE_UNBOUNDED;
XSModelGroupImpl group = new XSModelGroupImpl();
group.fCompositor = XSModelGroupImpl.MODELGROUP_SEQUENCE;
group.fParticleCount = 1;
group.fParticles = new XSParticleDecl[1];
group.fParticles[0] = particle;
XSParticleDecl errorContent = new XSParticleDecl();
errorContent.fType = XSParticleDecl.PARTICLE_MODELGROUP;
errorContent.fValue = group;
fErrorContent = errorContent;
}
return fErrorContent;
}
示例3: useRepeatingLeafNodes
private boolean useRepeatingLeafNodes(XSParticleDecl particle) {
int maxOccurs = particle.fMaxOccurs;
int minOccurs = particle.fMinOccurs;
short type = particle.fType;
if (type == XSParticleDecl.PARTICLE_MODELGROUP) {
XSModelGroupImpl group = (XSModelGroupImpl) particle.fValue;
if (minOccurs != 1 || maxOccurs != 1) {
if (group.fParticleCount == 1) {
XSParticleDecl particle2 = (XSParticleDecl) group.fParticles[0];
short type2 = particle2.fType;
return ((type2 == XSParticleDecl.PARTICLE_ELEMENT ||
type2 == XSParticleDecl.PARTICLE_WILDCARD) &&
particle2.fMinOccurs == 1 &&
particle2.fMaxOccurs == 1);
}
return (group.fParticleCount == 0);
}
for (int i = 0; i < group.fParticleCount; ++i) {
if (!useRepeatingLeafNodes(group.fParticles[i])) {
return false;
}
}
}
return true;
}
示例4: hasAllContent
protected boolean hasAllContent(XSParticleDecl particle) {
// If the content is not empty, is the top node ALL?
if (particle != null && particle.fType == XSParticleDecl.PARTICLE_MODELGROUP) {
return ((XSModelGroupImpl)particle.fValue).fCompositor == XSModelGroupImpl.MODELGROUP_ALL;
}
return false;
}
示例5: getContentModel
/**
* Get content model for the a given type
*
* @param typeDecl get content model for which complex type
* @return a content model validator
*/
public XSCMValidator getContentModel(XSComplexTypeDecl typeDecl) {
// for complex type with empty or simple content,
// there is no content model validator
short contentType = typeDecl.getContentType();
if (contentType == XSComplexTypeDecl.CONTENTTYPE_SIMPLE ||
contentType == XSComplexTypeDecl.CONTENTTYPE_EMPTY) {
return null;
}
XSParticleDecl particle = (XSParticleDecl)typeDecl.getParticle();
// if the content is element only or mixed, but no particle
// is defined, return the empty content model
if (particle == null)
return fEmptyCM;
// if the content model contains "all" model group,
// we create an "all" content model, otherwise a DFA content model
XSCMValidator cmValidator = null;
if (particle.fType == XSParticleDecl.PARTICLE_MODELGROUP &&
((XSModelGroupImpl)particle.fValue).fCompositor == XSModelGroupImpl.MODELGROUP_ALL) {
cmValidator = createAllCM(particle);
}
else {
cmValidator = createDFACM(particle);
}
//now we are throught building content model and have passed sucessfully of the nodecount check
//if set by the application
fNodeFactory.resetNodeCount() ;
// if the validator returned is null, it means there is nothing in
// the content model, so we return the empty content model.
if (cmValidator == null)
cmValidator = fEmptyCM;
return cmValidator;
}
示例6: getContentModel
/**
* Get content model for the a given type
*
* @param typeDecl get content model for which complex type
* @param forUPA a flag indicating whether it is for UPA
* @return a content model validator
*/
public XSCMValidator getContentModel(XSComplexTypeDecl typeDecl, boolean forUPA) {
// for complex type with empty or simple content,
// there is no content model validator
short contentType = typeDecl.getContentType();
if (contentType == XSComplexTypeDecl.CONTENTTYPE_SIMPLE ||
contentType == XSComplexTypeDecl.CONTENTTYPE_EMPTY) {
return null;
}
XSParticleDecl particle = (XSParticleDecl)typeDecl.getParticle();
// if the content is element only or mixed, but no particle
// is defined, return the empty content model
if (particle == null)
return fEmptyCM;
// if the content model contains "all" model group,
// we create an "all" content model, otherwise a DFA content model
XSCMValidator cmValidator = null;
if (particle.fType == XSParticleDecl.PARTICLE_MODELGROUP &&
((XSModelGroupImpl)particle.fValue).fCompositor == XSModelGroupImpl.MODELGROUP_ALL) {
cmValidator = createAllCM(particle);
}
else {
cmValidator = createDFACM(particle, forUPA);
}
//now we are throught building content model and have passed sucessfully of the nodecount check
//if set by the application
fNodeFactory.resetNodeCount() ;
// if the validator returned is null, it means there is nothing in
// the content model, so we return the empty content model.
if (cmValidator == null)
cmValidator = fEmptyCM;
return cmValidator;
}
示例7: buildSyntaxTree
private CMNode buildSyntaxTree(XSParticleDecl particle, boolean optimize) {
int maxOccurs = particle.fMaxOccurs;
int minOccurs = particle.fMinOccurs;
short type = particle.fType;
CMNode nodeRet = null;
if ((type == XSParticleDecl.PARTICLE_WILDCARD) ||
(type == XSParticleDecl.PARTICLE_ELEMENT)) {
// (task 1) element and wildcard particles should be converted to
// leaf nodes
// REVISIT: Make a clone of the leaf particle, so that if there
// are two references to the same group, we have two different
// leaf particles for the same element or wildcard decl.
// This is useful for checking UPA.
nodeRet = fNodeFactory.getCMLeafNode(particle.fType, particle.fValue, fParticleCount++, fLeafCount++);
// (task 2) expand occurrence values
nodeRet = expandContentModel(nodeRet, minOccurs, maxOccurs, optimize);
}
else if (type == XSParticleDecl.PARTICLE_MODELGROUP) {
// (task 1,3) convert model groups to binary trees
XSModelGroupImpl group = (XSModelGroupImpl)particle.fValue;
CMNode temp = null;
// when the model group is a choice of more than one particles, but
// only one of the particle is not empty, (for example
// <choice>
// <sequence/>
// <element name="e"/>
// </choice>
// ) we can't not return that one particle ("e"). instead, we should
// treat such particle as optional ("e?").
// the following boolean variable is true when there are at least
// 2 non-empty children.
boolean twoChildren = false;
for (int i = 0; i < group.fParticleCount; i++) {
// first convert each child to a CM tree
temp = buildSyntaxTree(group.fParticles[i],
optimize &&
minOccurs == 1 && maxOccurs == 1 &&
(group.fCompositor == XSModelGroupImpl.MODELGROUP_SEQUENCE ||
group.fParticleCount == 1));
// then combine them using binary operation
if (temp != null) {
if (nodeRet == null) {
nodeRet = temp;
}
else {
nodeRet = fNodeFactory.getCMBinOpNode(group.fCompositor, nodeRet, temp);
// record the fact that there are at least 2 children
twoChildren = true;
}
}
}
// (task 2) expand occurrence values
if (nodeRet != null) {
// when the group is "choice", there is only one non-empty
// child, and the group had more than one children, we need
// to create a zero-or-one (optional) node for the non-empty
// particle.
if (group.fCompositor == XSModelGroupImpl.MODELGROUP_CHOICE &&
!twoChildren && group.fParticleCount > 1) {
nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_ONE, nodeRet);
}
nodeRet = expandContentModel(nodeRet, minOccurs, maxOccurs, false);
}
}
return nodeRet;
}
示例8: buildCompactSyntaxTree
private CMNode buildCompactSyntaxTree(XSParticleDecl particle) {
int maxOccurs = particle.fMaxOccurs;
int minOccurs = particle.fMinOccurs;
short type = particle.fType;
CMNode nodeRet = null;
if ((type == XSParticleDecl.PARTICLE_WILDCARD) ||
(type == XSParticleDecl.PARTICLE_ELEMENT)) {
return buildCompactSyntaxTree2(particle, minOccurs, maxOccurs);
}
else if (type == XSParticleDecl.PARTICLE_MODELGROUP) {
XSModelGroupImpl group = (XSModelGroupImpl)particle.fValue;
if (group.fParticleCount == 1 && (minOccurs != 1 || maxOccurs != 1)) {
return buildCompactSyntaxTree2(group.fParticles[0], minOccurs, maxOccurs);
}
else {
CMNode temp = null;
// when the model group is a choice of more than one particles, but
// only one of the particle is not empty, (for example
// <choice>
// <sequence/>
// <element name="e"/>
// </choice>
// ) we can't not return that one particle ("e"). instead, we should
// treat such particle as optional ("e?").
// the following int variable keeps track of the number of non-empty children
int count = 0;
for (int i = 0; i < group.fParticleCount; i++) {
// first convert each child to a CM tree
temp = buildCompactSyntaxTree(group.fParticles[i]);
// then combine them using binary operation
if (temp != null) {
++count;
if (nodeRet == null) {
nodeRet = temp;
}
else {
nodeRet = fNodeFactory.getCMBinOpNode(group.fCompositor, nodeRet, temp);
}
}
}
if (nodeRet != null) {
// when the group is "choice" and the group has one or more empty children,
// we need to create a zero-or-one (optional) node for the non-empty particles.
if (group.fCompositor == XSModelGroupImpl.MODELGROUP_CHOICE && count < group.fParticleCount) {
nodeRet = fNodeFactory.getCMUniOpNode(XSParticleDecl.PARTICLE_ZERO_OR_ONE, nodeRet);
}
}
}
}
return nodeRet;
}