Package org.exolab.castor.xml.schema
Class AttributeDecl
java.lang.Object
org.exolab.castor.xml.schema.Structure
org.exolab.castor.xml.schema.Annotated
org.exolab.castor.xml.schema.AttributeDecl
- All Implemented Interfaces:
Serializable
An XML Schema Attribute Definition
- Version:
- $Revision: 7372 $ $Date: 2006-04-14 04:14:43 -0600 (Fri, 14 Apr 2006) $
- Author:
- Keith Visco
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
The use attribute value for optionalstatic final String
The use attribute value for prohibitedstatic final String
The use attribute value for requiredFields inherited from class org.exolab.castor.xml.schema.Structure
ANNOTATION, ANYTYPE, APPINFO, ATTRIBUTE, ATTRIBUTE_GROUP, COMPLEX_CONTENT, COMPLEX_TYPE, DOCUMENTATION, ELEMENT, FACET, GROUP, IDENTITY_FIELD, IDENTITY_SELECTOR, KEY, KEYREF, LIST, MODELGROUP, MODELGROUP_REF, REDEFINE, SCHEMA, SIMPLE_CONTENT, SIMPLE_TYPE, UNION, UNIQUE, UNKNOWN, WILDCARD
-
Constructor Summary
ConstructorsConstructorDescriptionAttributeDecl
(Schema schema) Creates a new AttrDecl in the given schema.AttributeDecl
(Schema schema, String name) Creates a new AttrDecl with the given name -
Method Summary
Modifier and TypeMethodDescriptionReturns the default value of this element definition.Returns the fixed value of this element definition.getForm()
Returns the Form for this attribute declaration.getId()
Returns the Id for this attribute declarationgetName()
Returns the name of attributes defined by this AttributeDecl.getName
(boolean ignoreRef) Returns the name of this Attribute declaration.Returns the parent of this AttributeDecl, this value may be null if no parent has been set.Returns the AttributeDecl that this attribute definition references.Returns the actual reference name of this AttributeDecl, or null if this AttributeDecl is not a reference.Returns the Schema that this AttributeGroupDecl belongs to.Returns the data type associated with this AttributeDecl.short
Returns the type of this Schema StructuregetUse()
Returns the value of the use attribute for this attribute declaration or attribute reference.boolean
Indicates whether a type is set for this element definiion.boolean
Returns true if the "default" flag is set.boolean
isFixed()
Returns true if the use attribute is equal to "optional".boolean
Returns true if the use attribute is equal to "optional".boolean
Returns true if the use attribute is equal to "prohibited".boolean
Returns true if this attribute definition simply references another attribute Definitionboolean
Returns true if the 'use' attribute is equal to REQUIRED and there is no specified value.void
setDefaultValue
(String value) Sets the DEFAULT valuevoid
setFixedValue
(String value) Sets the FIXED value.void
Sets the Form for this attribute declaration.void
Sets the Id for this attribute declarationvoid
Sets the name of attributes defined by this attribute definitionprotected void
Sets the parent for this AttributeDeclvoid
setReference
(String reference) Sets the reference for this attribute definitionvoid
setReference
(AttributeDecl reference) Sets the reference for this attribute definitionprotected void
Set the parent schema of the current ElementDecl.void
setSimpleType
(SimpleType simpleType) Sets the SimpleType for this attribute declarationvoid
setSimpleTypeReference
(String name) Sets the simple type of this attribute to be a reference.void
Sets the 'use' attribute of this attribute declaration Note: this should not be used to set the flag to FIXED or DEFAULTvoid
validate()
Checks the validity of this Attribute declarationMethods inherited from class org.exolab.castor.xml.schema.Annotated
addAnnotation, getAnnotations, removeAnnotation
-
Field Details
-
USE_OPTIONAL
The use attribute value for optional- See Also:
-
USE_PROHIBITED
The use attribute value for prohibited- See Also:
-
USE_REQUIRED
The use attribute value for required- See Also:
-
-
Constructor Details
-
AttributeDecl
Creates a new AttrDecl with the given name- Parameters:
name
- of the Attribute defined by this attribute declarationschema
- the schema that contains the new attrDecl
-
AttributeDecl
Creates a new AttrDecl in the given schema.- Parameters:
schema
- the schema that contains the new attrDecl
-
-
Method Details
-
getForm
Returns the Form for this attribute declaration. The Form object species whether or not names are qualified or unqualified for instances of this attribute declaration. If null, the Form should be obtained from the parent Schema.- Returns:
- the Form for this attribute declaration, or null if not set.
-
getId
Returns the Id for this attribute declaration- Returns:
- the Id for this attribute declaration
-
getName
Returns the name of attributes defined by this AttributeDecl. If this AttributeDecl is a reference to another AttributeDecl, the reference will be resolved and the name of the referenced AttributeDecl will be returned. The name will always be an NCName, no namespace prefix will be included.- Returns:
- the name of attributes defined by this AttributeDecl.
-
getName
Returns the name of this Attribute declaration. The name will always be an NCName, no namespace prefix will be included.- Parameters:
ignoreRef
- a boolean that when false, indicates that if this is an attribute reference to return the reference name. Otherwise the only the local name is used.- Returns:
- the name of this attribute declaration
-
getParent
Returns the parent of this AttributeDecl, this value may be null if no parent has been set.- Returns:
- the parent Structure of this AttributeDecl.
-
getSimpleType
Returns the data type associated with this AttributeDecl.- Returns:
- the data type associated with this AttributeDecl.
-
getReference
Returns the AttributeDecl that this attribute definition references. This will return null if this attribute definition does not reference a different attribute definition.- Returns:
- the AttributeDecl that this attribute definition references
-
getReferenceName
Returns the actual reference name of this AttributeDecl, or null if this AttributeDecl is not a reference. The name returned, if not null, will be a QName, possibly containing the namespace prefix.- Returns:
- the reference name
-
getSchema
Returns the Schema that this AttributeGroupDecl belongs to.- Returns:
- the Schema that this AttributeGroupDecl belongs to.
-
getUse
Returns the value of the use attribute for this attribute declaration or attribute reference. If this is a reference the value of the use attribute will *not* be obtained from the referenced attribute declaration as top-level attributes do not take into account the use attribute.- Returns:
- the value of the use attribute for this attribute declaration
-
getDefaultValue
Returns the default value of this element definition.- Returns:
- the default value of this element definition, or null if no default was specified.
-
getFixedValue
Returns the fixed value of this element definition.- Returns:
- the fixed value of this element definition, or null if no default was specified.
-
isDefault
public boolean isDefault()Returns true if the "default" flag is set.- Returns:
- true if the "default" flag is set.
-
isFixed
public boolean isFixed()Returns true if the use attribute is equal to "optional".- Returns:
- true if the use attribute is equal to "optional".
-
isOptional
public boolean isOptional()Returns true if the use attribute is equal to "optional".- Returns:
- true if the use attribute is equal to "optional".
-
isProhibited
public boolean isProhibited()Returns true if the use attribute is equal to "prohibited".- Returns:
- true if the use attribute is equal to "prohibited".
-
isRequired
public boolean isRequired()Returns true if the 'use' attribute is equal to REQUIRED and there is no specified value. If a value is specifed and the 'use' attribute is "required" then required is will return false, because the attribute value automatically becomes fixed.- Returns:
- true if the use attribute is equal to "required" and no default value has been specified, otherwise false
-
isReference
public boolean isReference()Returns true if this attribute definition simply references another attribute Definition- Returns:
- true if this attribute definition is a reference
-
setForm
Sets the Form for this attribute declaration. The Form object species whether or not names are qualified or unqualified for instances of this attribute declaration. If null, the Form is to be obtained from the parent Schema.- Parameters:
form
- the Form type for this attribute declaration.
-
setId
Sets the Id for this attribute declaration- Parameters:
id
- the Id for this attribute declaration
-
setName
Sets the name of attributes defined by this attribute definition- Parameters:
name
- the name of the this AttributeDecl. Must be a valid NCName.- Throws:
IllegalArgumentException
- when the name is not valid
-
setParent
Sets the parent for this AttributeDecl- Parameters:
parent
- the parent Structure for this AttributeDecl
-
setReference
Sets the reference for this attribute definition- Parameters:
reference
- the Attribute definition that this definition references
-
setReference
Sets the reference for this attribute definition- Parameters:
reference
- the name of the attribute definition that this definition references
-
setSimpleType
Sets the SimpleType for this attribute declaration- Parameters:
simpleType
- the SimpleType for this attribute declaration
-
setSimpleTypeReference
Sets the simple type of this attribute to be a reference.- Parameters:
name
- the name of the simpleType being referenced, must not be null.
-
setUse
Sets the 'use' attribute of this attribute declaration Note: this should not be used to set the flag to FIXED or DEFAULT- Parameters:
value
- one of the following: ("prohibited" | "optional" | "required")- See Also:
-
setDefaultValue
Sets the DEFAULT value -
setFixedValue
Sets the FIXED value. -
getStructureType
public short getStructureType()Returns the type of this Schema Structure- Specified by:
getStructureType
in classStructure
- Returns:
- the type of this Schema Structure
-
validate
Checks the validity of this Attribute declaration- Specified by:
validate
in classStructure
- Throws:
ValidationException
- when this Attribute declaration is invalid
-
setSchema
Set the parent schema of the current ElementDecl. The parent schema should at least have the same targetNamespace of the current schema. This method is protected since it is only meant to be used by the internal API to propagate the parent XML Schema in case of a redefinition for instance.- Parameters:
schema
-
-
hasXMLType
public boolean hasXMLType()Indicates whether a type is set for this element definiion.- Returns:
- True if a type is set.
-