org.geotools.feature.type
Class ChoiceAttributeType

Object
  extended by PropertyDescriptorImpl
      extended by AttributeDescriptorImpl
          extended by ChoiceAttributeType
All Implemented Interfaces:
AttributeType, AttributeDescriptor, PropertyDescriptor
Direct Known Subclasses:
ChoiceAttributeType.Geometric

Deprecated. Will be removed in geotools 2.6.

public class ChoiceAttributeType
extends AttributeDescriptorImpl
implements AttributeType

This represents a Choice of AttributeTypes. That means, an Attribute of this type may be one of any of this AttributeType's children. This attribute is not valid for Simple Features, and maps to the Choice construct in GML.

Another way to think about the ChoiceAttributeType is as a Union construction from C - it can store a number of different types of value, but it only stores the one value. The parse and validate methods try out each of the choices to see if one of them might work, since all are valid. The order that the child attributeTypes (the choices you can use) are specified is important, because some objects can parse and validate against several types. The first choice that returns true is the one that will

Author:
dzwiers, Chris Holmes, TOPP
Module:
modules/library/legacy (gt-legacy.jar)

Nested Class Summary
static class ChoiceAttributeType.Geometric
          Deprecated. A special class that is made so a Choice can serve as the Default Geometry in a FeatureType, by implementing GeometryAttributeType.
 
Field Summary
 
Fields inherited from class AttributeDescriptorImpl
defaultValue
 
Fields inherited from class PropertyDescriptorImpl
isNillable, maxOccurs, minOccurs, name, type
 
Fields inherited from interface AttributeType
UNBOUNDED
 
Constructor Summary
ChoiceAttributeType(ChoiceAttributeType copy)
          Deprecated. DOCUMENT ME!
ChoiceAttributeType(String name, AttributeType[] children)
          Deprecated.  
ChoiceAttributeType(String name, int min, int max, AttributeType[] children, Filter restriction)
          Deprecated.  
 
Method Summary
 boolean calculateNillable(AttributeType[] children)
          Deprecated.  
protected  AttributeType[] copyChildren(AttributeType[] attributes)
          Deprecated.  
 Object createDefaultValue()
          Deprecated. Returns the default value for the first child which does not throw an exception, null otherwise.
 Object duplicate(Object src)
          Deprecated. Goes through the children, and searches for a duplicator that works.
 boolean equals(Object other)
          Deprecated.  
 int find(AttributeType type)
          Deprecated. Find the position of a given AttributeType.
 int find(String attName)
          Deprecated. Find the position of an AttributeType which matches the given String.
 int getAttributeCount()
          Deprecated. Returns the number of attributes at the first 'level' of the schema.
 AttributeType getAttributeType(int position)
          Deprecated. Gets the attributeType at the specified index.
 AttributeType getAttributeType(String xPath)
          Deprecated. Gets the attributeType at this xPath, if the specified attributeType does not exist then null is returned.
 AttributeType[] getAttributeTypes()
          Deprecated.  
 Class getBinding()
          Deprecated. Gets the class of the object.
 String getLocalName()
          Deprecated. Returns the unqualified name of this attribute.
 Filter getRestriction()
          Deprecated. This represents a Facet in XML schema ... for example can be used to represent the max length of 20 for a string.
 boolean hasAttributeType(String xPath)
          Deprecated. This is only used twice in the whole geotools code base, and one of those is for a test, so we're removing it from the interface.
 int hashCode()
          Deprecated. Override of hashCode.
 boolean isGeometry()
          Deprecated.  
 Object parse(Object value)
          Deprecated. Goes through the children, and searches for a parser that works.
 String toString()
          Deprecated. Gets a representation of this object as a string.
 void validate(Object obj)
          Deprecated. Goes through the children, and searches for a validator that works.
 
Methods inherited from class AttributeDescriptorImpl
getDefaultValue, getType
 
Methods inherited from class PropertyDescriptorImpl
getMaxOccurs, getMinOccurs, getName, getUserData, isNillable
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface AttributeType
getMaxOccurs, getMinOccurs, isNillable
 
Methods inherited from interface AttributeDescriptor
getDefaultValue, getType
 
Methods inherited from interface PropertyDescriptor
getName, getUserData
 

Constructor Detail

ChoiceAttributeType

public ChoiceAttributeType(ChoiceAttributeType copy)
Deprecated. 
DOCUMENT ME!

Parameters:
copy -

ChoiceAttributeType

public ChoiceAttributeType(String name,
                           int min,
                           int max,
                           AttributeType[] children,
                           Filter restriction)
Deprecated. 

ChoiceAttributeType

public ChoiceAttributeType(String name,
                           AttributeType[] children)
Deprecated. 
Method Detail

getRestriction

public Filter getRestriction()
Deprecated. 
Description copied from interface: AttributeType
This represents a Facet in XML schema ... for example can be used to represent the max length of 20 for a string.

Specified by:
getRestriction in interface AttributeType
Returns:
Filter, or Filter.INCLUDE if no restriction is needed.

copyChildren

protected AttributeType[] copyChildren(AttributeType[] attributes)
Deprecated. 

getLocalName

public String getLocalName()
Deprecated. 
Returns the unqualified name of this attribute.

This method is a replacement for PropertyDescriptor.getName() in order to resolve a naming conflict with the geoapi feature model.

Specified by:
getLocalName in interface AttributeType
Specified by:
getLocalName in interface AttributeDescriptor
Overrides:
getLocalName in class AttributeDescriptorImpl
See Also:
PropertyDescriptor.getName()

getBinding

public Class getBinding()
Deprecated. 
Gets the class of the object. For a choice this is fairly useless, as it just returns Object, since we can not tell more than that.

Specified by:
getBinding in interface AttributeType
Returns:
currently always returns Object.class, since we can't tell more.
See Also:
AttributeType.getBinding()
TODO:
REVISIT: Perhaps we should add a getTypes() method that returns an array of classes, that would represent the classes that you can choose from., REVISIT: Would also be good if this could dynamically figure out the broadest class - like Number if the choices were Double and Integer.

calculateNillable

public boolean calculateNillable(AttributeType[] children)
Deprecated. 

isGeometry

public boolean isGeometry()
Deprecated. 

parse

public Object parse(Object value)
             throws IllegalArgumentException
Deprecated. 
Goes through the children, and searches for a parser that works. This method searches in the order in which the children are specified ... please keep this in mind when creating these objects if you care about precedence.

Specified by:
parse in interface AttributeType
Parameters:
value - The object to parse.
Returns:
The object parsed into the appropriate form for the Attribute.
Throws:
IllegalArgumentException - If the object could not be parsed by any of the child attribute Types.

validate

public void validate(Object obj)
              throws IllegalArgumentException
Deprecated. 
Goes through the children, and searches for a validator that works. This method searches in the order in which the children are specified ... please keep this in mind when creating these objects if you care about precedence.

Specified by:
validate in interface AttributeType
Parameters:
obj - The object to validate.
Throws:
IllegalArgumentException - If none of the children can validate.

duplicate

public Object duplicate(Object src)
                 throws IllegalAttributeException
Deprecated. 
Goes through the children, and searches for a duplicator that works. This method searches in the order in which the children are specified ... please keep this in mind when creating these objects if you care about precedence.

Specified by:
duplicate in interface AttributeType
Parameters:
src - The object to be duplicated.
Returns:
A deep copy of the original object.
Throws:
IllegalAttributeException - For any attribute errors.
IllegalArgumentException - If the object could not be duplicated.

createDefaultValue

public Object createDefaultValue()
Deprecated. 
Returns the default value for the first child which does not throw an exception, null otherwise.

Specified by:
createDefaultValue in interface AttributeType
Returns:
The default value of the first choice that does not throw an exception.

hasAttributeType

public boolean hasAttributeType(String xPath)
Deprecated. 
This is only used twice in the whole geotools code base, and one of those is for a test, so we're removing it from the interface. If getAttributeType does not have the AttributeType it will just return null. Gets the number of occurrences of this attribute.

Parameters:
xPath - XPath pointer to attribute type.
Returns:
Number of occurrences.

getAttributeCount

public int getAttributeCount()
Deprecated. 
Returns the number of attributes at the first 'level' of the schema.

Returns:
equivalent value to getAttributeTypes().length

getAttributeType

public AttributeType getAttributeType(String xPath)
Deprecated. 
Gets the attributeType at this xPath, if the specified attributeType does not exist then null is returned.

Parameters:
xPath - XPath pointer to attribute type.
Returns:
True if attribute exists.

find

public int find(AttributeType type)
Deprecated. 
Find the position of a given AttributeType.

Parameters:
type - The type to search for.
Returns:
-1 if not found, a zero-based index if found.

find

public int find(String attName)
Deprecated. 
Find the position of an AttributeType which matches the given String.

Parameters:
attName - the name to look for
Returns:
-1 if not found, zero-based index otherwise

getAttributeType

public AttributeType getAttributeType(int position)
Deprecated. 
Gets the attributeType at the specified index.

Parameters:
position - the position of the attribute to check.
Returns:
The attribute type at the specified position.

getAttributeTypes

public AttributeType[] getAttributeTypes()
Deprecated. 

equals

public boolean equals(Object other)
Deprecated. 
Overrides:
equals in class AttributeDescriptorImpl

hashCode

public int hashCode()
Deprecated. 
Override of hashCode.

Overrides:
hashCode in class AttributeDescriptorImpl
Returns:
hashCode for this object.

toString

public String toString()
Deprecated. 
Gets a representation of this object as a string.

Overrides:
toString in class AttributeDescriptorImpl
Returns:
A representation of this object as a string


Copyright © 1996-2010 Geotools. All Rights Reserved.