org.exolab.castor.xml.schema

Class AttributeDecl

Implemented Interfaces:
java.io.Serializable

public final class AttributeDecl
extends Annotated

An XML Schema Attribute Definition

Version:
$Revision: 1.2 $ $Date: 2003/03/03 09:57:19 $

Author:
Keith Visco

See Also:
Serialized Form

Field Summary

static String
USE_OPTIONAL
The use attribute value for optional
static String
USE_PROHIBITED
The use attribute value for prohibited
static String
USE_REQUIRED
The use attribute value for required

Fields 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

AttributeDecl(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

String
getDefaultValue()
Returns the default value of this element definition.
String
getFixedValue()
Returns the fixed value of this element definition.
Form
getForm()
Returns the Form for this attribute declaration.
String
getId()
Returns the Id for this attribute declaration
String
getName()
Returns the name of attributes defined by this AttributeDecl.
String
getName(boolean ignoreRef)
Returns the name of this Attribute declaration.
Structure
getParent()
Returns the parent of this AttributeDecl, this value may be null if no parent has been set.
AttributeDecl
getReference()
Returns the AttributeDecl that this attribute definition references.
String
getReferenceName()
Returns the actual reference name of this AttributeDecl, or null if this AttributeDecl is not a reference.
Schema
getSchema()
Returns the Schema that this AttributeGroupDecl belongs to.
SimpleType
getSimpleType()
Returns the data type associated with this AttributeDecl.
short
getStructureType()
Returns the type of this Schema Structure
String
getUse()
Returns the value of the use attribute for this attribute declaration or attribute reference.
boolean
isDefault()
Returns true if the "default" flag is set.
boolean
isFixed()
Returns true if the use attribute is equal to "optional".
boolean
isOptional()
Returns true if the use attribute is equal to "optional".
boolean
isProhibited()
Returns true if the use attribute is equal to "prohibited".
boolean
isReference()
Returns true if this attribute definition simply references another attribute Definition
boolean
isRequired()
Returns true if the 'use' attribute is equal to REQUIRED and there is no specified value.
void
setDefaultValue(String value)
Sets the DEFAULT value
void
setFixedValue(String value)
Sets the FIXED value.
void
setForm(Form form)
Sets the Form for this attribute declaration.
void
setId(String id)
Sets the Id for this attribute declaration
void
setName(String name)
Sets the name of attributes defined by this attribute definition
protected void
setParent(Structure parent)
Sets the parent for this AttributeDecl
void
setReference(String reference)
Sets the reference for this attribute definition
void
setReference(AttributeDecl reference)
Sets the reference for this attribute definition
void
setSimpleType(SimpleType simpleType)
Sets the SimpleType for this attribute declaration
void
setSimpleTypeReference(String name)
Sets the simple type of this attribute to be a reference.
void
setUse(String value)
Sets the 'use' attribute of this attribute declaration Note: this should not be used to set the flag to FIXED or DEFAULT
void
validate()
Checks the validity of this Attribute declaration

Methods inherited from class org.exolab.castor.xml.schema.Annotated

addAnnotation, getAnnotations, removeAnnotation

Methods inherited from class org.exolab.castor.xml.schema.Structure

getStructureType, isValid, validate

Field Details

USE_OPTIONAL

public static final String USE_OPTIONAL
The use attribute value for optional


USE_PROHIBITED

public static final String USE_PROHIBITED
The use attribute value for prohibited


USE_REQUIRED

public static final String USE_REQUIRED
The use attribute value for required

Constructor Details

AttributeDecl

public AttributeDecl(Schema schema)
Creates a new AttrDecl in the given schema.

Parameters:
schema - the schema that contains the new attrDecl


AttributeDecl

public AttributeDecl(Schema schema,
                     String name)
Creates a new AttrDecl with the given name

Parameters:
schema - the schema that contains the new attrDecl
name - of the Attribute defined by this attribute declaration

Method Details

getDefaultValue

public String 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

public String getFixedValue()
Returns the fixed value of this element definition.

Returns:
the fixed value of this element definition, or null if no default was specified.


getForm

public Form 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

public String getId()
Returns the Id for this attribute declaration

Returns:
the Id for this attribute declaration


getName

public String 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

public String getName(boolean ignoreRef)
Returns the name of this Attribute declaration. The name will always be an NCName, no namespace prefix will be included.

Parameters:

Returns:
the name of this attribute declaration


getParent

public Structure 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.


getReference

public 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

public String 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

public Schema getSchema()
Returns the Schema that this AttributeGroupDecl belongs to.

Returns:
the Schema that this AttributeGroupDecl belongs to.


getSimpleType

public SimpleType getSimpleType()
Returns the data type associated with this AttributeDecl.

Returns:
the data type associated with this AttributeDecl.


getStructureType

public short getStructureType()
Returns the type of this Schema Structure
Overrides:
getStructureType in interface Structure

Returns:
the type of this Schema Structure


getUse

public String 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


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".


isReference

public boolean isReference()
Returns true if this attribute definition simply references another attribute Definition

Returns:
true if this attribute definition is a reference


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


setDefaultValue

public void setDefaultValue(String value)
Sets the DEFAULT value


setFixedValue

public void setFixedValue(String value)
Sets the FIXED value.


setForm

public void setForm(Form form)
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

public void setId(String id)
Sets the Id for this attribute declaration

Parameters:
id - the Id for this attribute declaration


setName

public void setName(String name)
Sets the name of attributes defined by this attribute definition

Parameters:
name - the name of the this AttributeDecl. Must be a valid NCName.


setParent

protected void setParent(Structure parent)
Sets the parent for this AttributeDecl

Parameters:
parent - the parent Structure for this AttributeDecl


setReference

public void setReference(String reference)
Sets the reference for this attribute definition

Parameters:
reference - the name of the attribute definition that this definition references


setReference

public void setReference(AttributeDecl reference)
Sets the reference for this attribute definition

Parameters:
reference - the Attribute definition that this definition references


setSimpleType

public void setSimpleType(SimpleType simpleType)
Sets the SimpleType for this attribute declaration

Parameters:
simpleType - the SimpleType for this attribute declaration


setSimpleTypeReference

public void setSimpleTypeReference(String name)
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

public void setUse(String value)
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:
USE_PROHIBITED, USE_OPTIONAL, USE_REQUIRED


validate

public void validate()
            throws ValidationException
Checks the validity of this Attribute declaration
Overrides:
validate in interface Structure

Throws:
ValidationException - when this Attribute declaration is invalid


Intalio Inc. (C) 1999-2003. All rights reserved http://www.intalio.com