FileDocCategorySizeDatePackage
XSParticleDecl.javaAPI DocApache Xerces 3.0.17847Fri Sep 14 20:33:54 BST 2007org.apache.xerces.impl.xs

XSParticleDecl

public class XSParticleDecl extends Object implements org.apache.xerces.xs.XSParticle
Store schema particle declaration.
xerces.internal
author
Sandy Gao, IBM
version
$Id: XSParticleDecl.java 446734 2006-09-15 20:51:23Z mrglavas $

Fields Summary
public static final short
PARTICLE_EMPTY
public static final short
PARTICLE_ELEMENT
public static final short
PARTICLE_WILDCARD
public static final short
PARTICLE_MODELGROUP
public static final short
PARTICLE_ZERO_OR_MORE
public static final short
PARTICLE_ZERO_OR_ONE
public static final short
PARTICLE_ONE_OR_MORE
public short
fType
public org.apache.xerces.xs.XSTerm
fValue
public int
fMinOccurs
public int
fMaxOccurs
public org.apache.xerces.xs.XSObjectList
fAnnotations
private String
fDescription
get the string description of this particle
Constructors Summary
Methods Summary
voidappendParticle(java.lang.StringBuffer buffer)
append the string description of this particle to the string buffer this is for error message.

        switch (fType) {
        case PARTICLE_EMPTY:
            buffer.append("EMPTY");
            break;
        case PARTICLE_ELEMENT:
            buffer.append(fValue.toString());
            break;
        case PARTICLE_WILDCARD:
            buffer.append('(");
            buffer.append(fValue.toString());
            buffer.append(')");
            break;
        case PARTICLE_MODELGROUP:
            buffer.append(fValue.toString());
            break;
        }
    
public booleanemptiable()
3.9.6 Schema Component Constraint: Particle Emptiable whether this particle is emptible

        return minEffectiveTotalRange() == 0;
    
public org.apache.xerces.xs.XSObjectListgetAnnotations()
Optional. Annotations.

        return (fAnnotations != null) ? fAnnotations : XSObjectListImpl.EMPTY_LIST;
    
public intgetMaxOccurs()
{max occurs} determines the maximum number of terms that can occur.

        return fMaxOccurs;
    
public booleangetMaxOccursUnbounded()
{max occurs} whether the maxOccurs value is unbounded.

        return fMaxOccurs == SchemaSymbols.OCCURRENCE_UNBOUNDED;
    
public intgetMinOccurs()
{min occurs} determines the minimum number of terms that can occur.

        return fMinOccurs;
    
public java.lang.StringgetName()
The name of this XSObject depending on the XSObject type.

        return null;
    
public java.lang.StringgetNamespace()
The namespace URI of this node, or null if it is unspecified. defines how a namespace URI is attached to schema components.

        return null;
    
public org.apache.xerces.xs.XSNamespaceItemgetNamespaceItem()

see
org.apache.xerces.xs.XSObject#getNamespaceItem()

		return null;
	
public org.apache.xerces.xs.XSTermgetTerm()
{term} One of a model group, a wildcard, or an element declaration.

        return fValue;
    
public shortgetType()
Get the type of the object, i.e ELEMENT_DECLARATION.

        return XSConstants.PARTICLE;
    
public booleanisEmpty()

        if (fType == PARTICLE_EMPTY)
             return true;
        if (fType == PARTICLE_ELEMENT || fType == PARTICLE_WILDCARD)
            return false; 

        return ((XSModelGroupImpl)fValue).isEmpty();
    
public org.apache.xerces.impl.xs.XSParticleDeclmakeClone()

  

    // clone this decl
       
        XSParticleDecl particle = new XSParticleDecl();
        particle.fType = fType;
        particle.fMinOccurs = fMinOccurs;
        particle.fMaxOccurs = fMaxOccurs;
        particle.fDescription = fDescription;
        particle.fValue = fValue;
        particle.fAnnotations = fAnnotations;
        return particle;
    
public intmaxEffectiveTotalRange()

        if (fType == XSParticleDecl.PARTICLE_EMPTY) {
            return 0;
        }
        if (fType == PARTICLE_MODELGROUP) {
            int max = ((XSModelGroupImpl)fValue).maxEffectiveTotalRange();
            if (max == SchemaSymbols.OCCURRENCE_UNBOUNDED)
                return SchemaSymbols.OCCURRENCE_UNBOUNDED;
            if (max != 0 && fMaxOccurs == SchemaSymbols.OCCURRENCE_UNBOUNDED)
                return SchemaSymbols.OCCURRENCE_UNBOUNDED;
            return max * fMaxOccurs;
        }
        return fMaxOccurs;
    
public intminEffectiveTotalRange()
3.8.6 Effective Total Range (all and sequence) and Effective Total Range (choice) The following methods are used to return min/max range for a particle. They are not exactly the same as it's described in the spec, but all the values from the spec are retrievable by these methods.

        if (fType == XSParticleDecl.PARTICLE_EMPTY) {
            return 0;
        }
        if (fType == PARTICLE_MODELGROUP) {
            return ((XSModelGroupImpl)fValue).minEffectiveTotalRange() * fMinOccurs;
        }
        return fMinOccurs;
    
public voidreset()

        fType = PARTICLE_EMPTY;
        fValue = null;
        fMinOccurs = 1;
        fMaxOccurs = 1;
        fDescription = null;
        fAnnotations = null;
    
public java.lang.StringtoString()

       
        if (fDescription == null) {
            StringBuffer buffer = new StringBuffer();
            appendParticle(buffer);
            if (!(fMinOccurs == 0 && fMaxOccurs == 0 ||
                  fMinOccurs == 1 && fMaxOccurs == 1)) {
                buffer.append("{").append(fMinOccurs);
                if (fMaxOccurs == SchemaSymbols.OCCURRENCE_UNBOUNDED)
                    buffer.append("-UNBOUNDED");
                else if (fMinOccurs != fMaxOccurs)
                    buffer.append("-").append(fMaxOccurs);
                buffer.append("}");
            }
            fDescription = buffer.toString();
        }
        return fDescription;