本文整理汇总了Java中org.apache.xerces.xs.XSParticle.getMaxOccurs方法的典型用法代码示例。如果您正苦于以下问题:Java XSParticle.getMaxOccurs方法的具体用法?Java XSParticle.getMaxOccurs怎么用?Java XSParticle.getMaxOccurs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.xerces.xs.XSParticle
的用法示例。
在下文中一共展示了XSParticle.getMaxOccurs方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOccurances
import org.apache.xerces.xs.XSParticle; //导入方法依赖的package包/类
/**
* Gets the number of occurrences for a particular node based on the XSParticle reference in the schema.
*
* @param particle the particle reference.
* @param parentElem the parent element.
* @return the actual no of calculated occurrences.
*/
public int getOccurances(XSParticle particle,
Element parentElem) {
if (null != particle && null != parentElem) {
int minOccurs = particle.getMinOccurs();
int maxOccurs = particle.getMaxOccurs();
String particleName = particle.getTerm().getName();
if (choiceListContains(particleName, parentElem)) {
int numOfSetValues = this.numberOfSetValues(particleName, parentElem);
return Math.max(1, numOfSetValues);
}
else if (0 == minOccurs) {
return 0;
}
else if (minOccurs >= maxOccurs) {
return minOccurs;
}
}
return DEFAULT_MAX_OCCURS;
}
示例2: appendCardinality
import org.apache.xerces.xs.XSParticle; //导入方法依赖的package包/类
private void appendCardinality(Path path){
path = path.getParentPath(XSParticle.class);
if(path!=null){
XSParticle particle = (XSParticle)path.getElement();
if(particle.getMinOccurs()==1 && particle.getMaxOccurs()==1)
return;
if(particle.getMinOccurs()==0 && particle.getMaxOccurs()==1)
buff.append("?");
else if(particle.getMinOccurs()==0 && particle.getMaxOccursUnbounded())
buff.append("*");
else if(particle.getMinOccurs()==1 && particle.getMaxOccursUnbounded())
buff.append("+");
else{
buff.append("[");
if(particle.getMaxOccursUnbounded())
buff.append(particle.getMinOccurs()).append("+");
else if(particle.getMinOccurs()==particle.getMaxOccurs())
buff.append(particle.getMinOccurs());
else
buff.append(particle.getMinOccurs()).append(",").append(particle.getMaxOccurs());
buff.append("]");
}
}
}
示例3: findMultipleOccurringChildElements
import org.apache.xerces.xs.XSParticle; //导入方法依赖的package包/类
protected Set<String> findMultipleOccurringChildElements(XSParticle particle) {
Set<String> result=new HashSet<String>();
if (particle==null) {
log.warn("findMultipleOccurringChildElements() typeDefinition particle is null, is this a problem?");
return result;
}
XSTerm term = particle.getTerm();
if (term==null) {
throw new IllegalStateException("findMultipleOccurringChildElements particle.term is null");
}
if (DEBUG) log.debug("findMultipleOccurringChildElements() term name ["+term.getName()+"] occurring unbounded ["+particle.getMaxOccursUnbounded()+"] max occur ["+particle.getMaxOccurs()+"] term ["+ToStringBuilder.reflectionToString(term)+"]");
if (particle.getMaxOccursUnbounded()||particle.getMaxOccurs()>1) {
collectChildElements(particle,result);
return result;
}
if (term instanceof XSModelGroup) {
XSModelGroup modelGroup = (XSModelGroup)term;
XSObjectList particles = modelGroup.getParticles();
if (DEBUG) log.debug("findMultipleOccurringChildElements() modelGroup particles ["+ToStringBuilder.reflectionToString(particles)+"]");
for (int i=0;i<particles.getLength();i++) {
XSParticle childParticle = (XSParticle)particles.item(i);
result.addAll(findMultipleOccurringChildElements(childParticle));
}
}
return result;
}
示例4: isMultiValued
import org.apache.xerces.xs.XSParticle; //导入方法依赖的package包/类
private boolean isMultiValued(XSParticle particle) {
return particle.getMaxOccursUnbounded() || particle.getMaxOccurs() > 1;
}
示例5: process
import org.apache.xerces.xs.XSParticle; //导入方法依赖的package包/类
protected boolean process(XSParticle particle){
return !(!particle.getMaxOccursUnbounded() && particle.getMinOccurs() == 1 && particle.getMaxOccurs() == 1);
}
示例6: isElementMultiWithin
import org.apache.xerces.xs.XSParticle; //导入方法依赖的package包/类
/**
* Test if the given element may appear multipe times within the given
* particle.
*
* @param xiDecl the declaration to search for
* @param xiMulti does the particle itself already occur multiple times?
* @param xiParticle the particle to search within
* @return true if it may appear multiple times, false if it may appear at
* most once, null if the element is not found within the particle.
*/
private static Boolean isElementMultiWithin(XSElementDeclaration xiDecl,
boolean xiMulti,
XSParticle xiParticle)
{
if (xiParticle == null)
{
return null;
}
// Determine context multiplicity: either we're already multiple, or this
// particle can appear multiple times.
boolean lOuter =
xiMulti ||
xiParticle.getMaxOccursUnbounded() ||
(xiParticle.getMaxOccurs() > 1);
Boolean lMulti;
XSTerm lTerm = xiParticle.getTerm();
if (lTerm instanceof XSModelGroup)
{
XSModelGroup lGroup = (XSModelGroup)lTerm;
XSObjectList lParticles = ((XSModelGroup)lTerm).getParticles();
lMulti = null;
for (Object lParticleObj : lParticles)
{
XSParticle lParticle = (XSParticle)lParticleObj;
Boolean lSub = isElementMultiWithin(xiDecl, lOuter, lParticle);
if (lSub != null)
{
if (lMulti == null)
{
// Normal case: we've found a single match
lMulti = lSub;
}
else
{
// Multiple matches for the element - that's not very sane
// (although we could just do lMulti = true).
throw new RuntimeException("Multiple separate occurrences of the same element: " + xiDecl.getName());
}
}
}
}
else if (lTerm instanceof XSElementDeclaration)
{
XSElementDeclaration lElementDecl = (XSElementDeclaration)lTerm;
if (isEqualName(lElementDecl, xiDecl))
{
// We have a match! Take the multiplicity we've determined for this
// context.
lMulti = lOuter;
}
else
{
lMulti = null;
}
}
else
{
throw new RuntimeException("Wildcard or other particle (complex type component) not supported: " + xiDecl.getName());
}
return lMulti;
}