FileDocCategorySizeDatePackage
XSParticleDecl.javaAPI DocJava SE 5 API9067Fri Aug 26 14:55:50 BST 2005com.sun.org.apache.xerces.internal.impl.xs

XSParticleDecl

public class XSParticleDecl extends Object implements XSParticle
Store schema particle declaration.
author
Sandy Gao, IBM
version
$Id: XSParticleDecl.java,v 1.12 2003/11/11 20:14:58 sandygao Exp $

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 XSTerm
fValue
public int
fMinOccurs
public int
fMaxOccurs
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:
        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 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 com.sun.org.apache.xerces.internal.xs.XSNamespaceItemgetNamespaceItem()

see
com.sun.org.apache.xerces.internal.xs.XSObject#getNamespaceItem()

		return null;
	
public com.sun.org.apache.xerces.internal.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 com.sun.org.apache.xerces.internal.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;
        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;
    
public java.lang.StringtoString()

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