FileDocCategorySizeDatePackage
XSElementDecl.javaAPI DocApache Xerces 3.0.112266Fri Sep 14 20:33:52 BST 2007org.apache.xerces.impl.xs

XSElementDecl

public class XSElementDecl extends Object implements org.apache.xerces.xs.XSElementDeclaration
The XML representation for an element declaration schema component is an <element> element information item
xerces.internal
author
Elena Litani, IBM
author
Sandy Gao, IBM
version
$Id: XSElementDecl.java 449424 2006-09-24 16:22:30Z mrglavas $

Fields Summary
public static final short
SCOPE_ABSENT
public static final short
SCOPE_GLOBAL
public static final short
SCOPE_LOCAL
public String
fName
public String
fTargetNamespace
public org.apache.xerces.xs.XSTypeDefinition
fType
short
fMiscFlags
public short
fScope
XSComplexTypeDecl
fEnclosingCT
public short
fBlock
public short
fFinal
public org.apache.xerces.xs.XSObjectList
fAnnotations
public org.apache.xerces.impl.dv.ValidatedInfo
fDefault
public XSElementDecl
fSubGroup
static final int
INITIAL_SIZE
int
fIDCPos
org.apache.xerces.impl.xs.identity.IdentityConstraint[]
fIDConstraints
private static final short
CONSTRAINT_MASK
private static final short
NILLABLE
private static final short
ABSTRACT
private String
fDescription
get the string description of this element
Constructors Summary
Methods Summary
public voidaddIDConstraint(org.apache.xerces.impl.xs.identity.IdentityConstraint idc)

        if (fIDCPos == fIDConstraints.length) {
            fIDConstraints = resize(fIDConstraints, fIDCPos*2);
        }
        fIDConstraints[fIDCPos++] = idc;
    
public booleanequals(java.lang.Object o)
whether two decls are the same

        return o == this;
    
public booleangetAbstract()
{abstract} A boolean.

        return ((fMiscFlags & ABSTRACT) != 0);
    
public java.lang.ObjectgetActualVC()

        return getConstraintType() == XSConstants.VC_NONE ?
               null :
               fDefault.actualValue;
    
public shortgetActualVCType()

        return getConstraintType() == XSConstants.VC_NONE ?
               XSConstants.UNAVAILABLE_DT :
               fDefault.actualValueType;
    
public org.apache.xerces.xs.XSAnnotationgetAnnotation()
Optional. Annotation.

        return (fAnnotations != null) ? (XSAnnotation) fAnnotations.item(0) : null;
    
public org.apache.xerces.xs.XSObjectListgetAnnotations()
Optional. Annotations.

        return (fAnnotations != null) ? fAnnotations : XSObjectListImpl.EMPTY_LIST;
    
public shortgetConstraintType()
A value constraint: one of default, fixed.

        return (short)(fMiscFlags & CONSTRAINT_MASK);
    
public java.lang.StringgetConstraintValue()
A value constraint: The actual value (with respect to the {type definition})

        // REVISIT: SCAPI: what's the proper representation
        return getConstraintType() == XSConstants.VC_NONE ?
               null :
               fDefault.stringValue();
    
public shortgetDisallowedSubstitutions()
The supplied values for {disallowed substitutions}

return
A bit flag representing {substitution, extension, restriction} or NONE.

        return fBlock;
    
public org.apache.xerces.xs.XSComplexTypeDefinitiongetEnclosingCTDefinition()
Locally scoped declarations are available for use only within the complex type definition identified by the scope property.

        return fEnclosingCT;
    
public org.apache.xerces.impl.xs.identity.IdentityConstraint[]getIDConstraints()

        if (fIDCPos == 0) {
            return null;
        }
        if (fIDCPos < fIDConstraints.length) {
            fIDConstraints = resize(fIDConstraints, fIDCPos);
        }
        return fIDConstraints;
    
public org.apache.xerces.xs.XSNamedMapgetIdentityConstraints()
{identity-constraint definitions} A set of constraint definitions.

        return new XSNamedMapImpl(fIDConstraints, fIDCPos);
    
public org.apache.xerces.xs.ShortListgetItemValueTypes()

        return getConstraintType() == XSConstants.VC_NONE ?
               null :
               fDefault.itemValueTypes;
    
public java.lang.StringgetName()
The name of this XSObject depending on the XSObject type.

        return fName;
    
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 fTargetNamespace;
    
public org.apache.xerces.xs.XSNamespaceItemgetNamespaceItem()

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

        // REVISIT: implement
        return null;
    
public booleangetNillable()
If {nillable} is true, then an element may also be valid if it carries the namespace qualified attribute with [local name] nil from namespace http://www.w3.org/2001/XMLSchema-instance and value true (see xsi:nil (2.6.2)) even if it has no text or element content despite a {content type} which would otherwise require content.

        return ((fMiscFlags & NILLABLE) != 0);
    
public shortgetScope()
Optional. Either global or a complex type definition ( ctDefinition). This property is absent in the case of declarations within named model groups: their scope will be determined when they are used in the construction of complex type definitions.

        return fScope;
    
public org.apache.xerces.xs.XSElementDeclarationgetSubstitutionGroupAffiliation()
{substitution group affiliation} Optional. A top-level element definition.

        return fSubGroup;
    
public shortgetSubstitutionGroupExclusions()
Specifies if this declaration can be nominated as the {substitution group affiliation} of other element declarations having the same {type definition} or types derived therefrom.

return
A bit flag representing {extension, restriction} or NONE.

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

        return XSConstants.ELEMENT_DECLARATION;
    
public org.apache.xerces.xs.XSTypeDefinitiongetTypeDefinition()
Either a simple type definition or a complex type definition.

        return fType;
    
public inthashCode()
get the hash code

        int code = fName.hashCode();
        if (fTargetNamespace != null)
            code = (code<<16)+fTargetNamespace.hashCode();
        return code;
    
public booleanisDisallowedSubstitution(short disallowed)
Convenience method. Check if disallowed is a disallowed substitution for this element declaration.

param
disallowed Substitution, extension, restriction or none. Represents a block set for the element.
return
True if disallowed is a part of the substitution group exclusion subset.

        return (fBlock & disallowed) != 0;
    
public booleanisSubstitutionGroupExclusion(short exclusion)
Convenience method. Check if exclusion is a substitution group exclusion for this element declaration.

param
exclusion Extension, restriction or none. Represents final set for the element.
return
True if exclusion is a part of the substitution group exclusion subset.

        return (fFinal & exclusion) != 0;
    
public voidreset()
Reset current element declaration


        fName = null;
        fTargetNamespace = null;
        fType = null;
        fMiscFlags = 0;
        fBlock = XSConstants.DERIVATION_NONE;
        fFinal = XSConstants.DERIVATION_NONE;
        fDefault = null;
        fAnnotations = null;
        fSubGroup = null;
        // reset identity constraints
        for (int i=0;i<fIDCPos;i++) {
            fIDConstraints[i] = null;
        }

        fIDCPos = 0;
    
static final org.apache.xerces.impl.xs.identity.IdentityConstraint[]resize(org.apache.xerces.impl.xs.identity.IdentityConstraint[] oldArray, int newSize)

        IdentityConstraint[] newArray = new IdentityConstraint[newSize];
        System.arraycopy(oldArray, 0, newArray, 0, Math.min(oldArray.length, newSize));
        return newArray;
    
public voidsetConstraintType(short constraintType)


    // methods to get/set misc flag
        
        // first clear the bits
        fMiscFlags ^= (fMiscFlags & CONSTRAINT_MASK);
        // then set the proper one
        fMiscFlags |= (constraintType & CONSTRAINT_MASK);
    
public voidsetIsAbstract()

        fMiscFlags |= ABSTRACT;
    
public voidsetIsGlobal()

        fScope = SCOPE_GLOBAL;
    
public voidsetIsLocal(XSComplexTypeDecl enclosingCT)

        fScope = SCOPE_LOCAL;
        fEnclosingCT = enclosingCT;
    
public voidsetIsNillable()

        fMiscFlags |= NILLABLE;
    
public java.lang.StringtoString()

       
        if (fDescription == null) {
            if (fTargetNamespace != null) {
                StringBuffer buffer = new StringBuffer(
                    fTargetNamespace.length() + 
                    ((fName != null) ? fName.length() : 4) + 3);
                buffer.append('"");
                buffer.append(fTargetNamespace);
                buffer.append('"");
                buffer.append(':");
                buffer.append(fName);
                fDescription = buffer.toString();
            }
            else {
                fDescription = fName;
            }
        }
        return fDescription;