org.geotools.feature.type
Class SetAttributeType

java.lang.Object
  extended byorg.geotools.feature.type.SetAttributeType
All Implemented Interfaces:
AttributeType

public class SetAttributeType
extends java.lang.Object
implements AttributeType

Represents an un-ordered Set of AttributeTypes. For SFS this should not be used. For GML this is the same as an element whose complexType contains a All of Attributes. NOTE: Some of the methods in this class has nasty order-dependant assumptions, please fix.

Author:
dzwiers

Field Summary
 
Fields inherited from interface org.geotools.feature.AttributeType
UNBOUNDED
 
Constructor Summary
SetAttributeType(SetAttributeType copy)
           
SetAttributeType(java.lang.String name, boolean nillable, AttributeType[] children)
           
SetAttributeType(java.lang.String name, boolean nillable, int min, int max, AttributeType[] children, Filter restriction)
           
 
Method Summary
 java.lang.Object createDefaultValue()
          This method is unstable ... and does not yet check validity well.
 java.lang.Object duplicate(java.lang.Object src)
          This method is unstable ... and does not yet check validity well.
 int find(AttributeType type)
          Find the position of a given AttributeType.
 int find(java.lang.String attName)
          Find the position of an AttributeType which matches the given String.
 int getAttributeCount()
          Returns the number of attributes at the first 'level' of the schema.
 AttributeType getAttributeType(int position)
          Gets the attributeType at the specified index.
 AttributeType getAttributeType(java.lang.String xPath)
          Gets the attributeType at this xPath, if the specified attributeType does not exist then null is returned.
 AttributeType[] getAttributeTypes()
           
 int getMaxOccurs()
          Returns the Max number of occurences ...
 int getMinOccurs()
          Returns the Min number of occurences ...
 java.lang.String getName()
          Gets the name of this attribute.
 Filter getRestriction()
          This represents a Facet in XML schema ... for example can be used to represent the max length of 20 for a string.
 java.lang.Class getType()
          Gets the type of this attribute.
 boolean hasAttributeType(java.lang.String xPath)
          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.
 boolean isGeometry()
           
 boolean isNillable()
          Returns whether nulls are allowed for this attribute.
 java.lang.Object parse(java.lang.Object value)
          This method is unstable ... and does not yet check validity well.
 void validate(java.lang.Object obj)
          This method is unstable ... and does not yet check validity well.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SetAttributeType

public SetAttributeType(SetAttributeType copy)
Parameters:
copy -

SetAttributeType

public SetAttributeType(java.lang.String name,
                        boolean nillable,
                        int min,
                        int max,
                        AttributeType[] children,
                        Filter restriction)

SetAttributeType

public SetAttributeType(java.lang.String name,
                        boolean nillable,
                        AttributeType[] children)
Method Detail

getRestriction

public Filter getRestriction()
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.NONE if no restriction is needed.

getName

public java.lang.String getName()
Description copied from interface: AttributeType
Gets the name of this attribute.

Specified by:
getName in interface AttributeType
Returns:
Name.

getType

public java.lang.Class getType()
Description copied from interface: AttributeType
Gets the type of this attribute.

Specified by:
getType in interface AttributeType
Returns:
Type.

isNillable

public boolean isNillable()
Description copied from interface: AttributeType
Returns whether nulls are allowed for this attribute.

Specified by:
isNillable in interface AttributeType
Returns:
true if nulls are permitted, false otherwise.

getMinOccurs

public int getMinOccurs()
Description copied from interface: AttributeType
Returns the Min number of occurences ...

Specified by:
getMinOccurs in interface AttributeType
Returns:

getMaxOccurs

public int getMaxOccurs()
Description copied from interface: AttributeType
Returns the Max number of occurences ...

Specified by:
getMaxOccurs in interface AttributeType
Returns:

isGeometry

public boolean isGeometry()

parse

public java.lang.Object parse(java.lang.Object value)
                       throws java.lang.IllegalArgumentException
This method is unstable ... and does not yet check validity well. TODO make this method robust This method assumes the Objects are in the order of the attributes. In the future, this should be implemented with a bubble sort type algorithm for testing each object vs each child. Bubble sort is recommended as the sample size is typically less than 25 elements, and the operation takes O(n*n) time.

Specified by:
parse in interface AttributeType
Parameters:
value - the object to attempt parsing of.
Returns:
value converted to the preferred storage of this AttributeType. If no parsing was possible then the same object is returned.
Throws:
java.lang.IllegalArgumentException - if parsing is attempted and is unsuccessful.

validate

public void validate(java.lang.Object obj)
              throws java.lang.IllegalArgumentException
This method is unstable ... and does not yet check validity well. TODO make this method robust This method assumes the Objects are in the order of the attributes. In the future, this should be implemented with a bubble sort type algorithm for testing each object vs each child. Bubble sort is recommended as the sample size is typically less than 25 elements, and the operation takes O(n*n) time. Note that on the Attribute side of the fence ... this is acutally an unordered List (a Set of elements, where each element has multiplicity ...)

Specified by:
validate in interface AttributeType
Parameters:
obj - The object to be tested for validity.
Throws:
java.lang.IllegalArgumentException - if the object does not validate.

duplicate

public java.lang.Object duplicate(java.lang.Object src)
                           throws IllegalAttributeException
This method is unstable ... and does not yet check validity well. TODO make this method robust This method assumes the Objects are in the order of the attributes. In the future, this should be implemented with a bubble sort type algorithm for testing each object vs each child. Bubble sort is recommended as the sample size is typically less than 25 elements, and the operation takes O(n*n) time.

Specified by:
duplicate in interface AttributeType
Parameters:
src - The Object to duplicate.
Returns:
Duplicate of provided object
Throws:
IllegalAttributeException - If the src Object is not the correct type.

createDefaultValue

public java.lang.Object createDefaultValue()
This method is unstable ... and does not yet check validity well. TODO make this method robust This method assumes the Objects are in the order of the attributes. In the future, this should be implemented with a bubble sort type algorithm for testing each object vs each child. Bubble sort is recommended as the sample size is typically less than 25 elements, and the operation takes O(n*n) time.

Specified by:
createDefaultValue in interface AttributeType
Returns:
Default value, note may be null if isNillable is true

hasAttributeType

public boolean hasAttributeType(java.lang.String xPath)
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()
Returns the number of attributes at the first 'level' of the schema.

Returns:
equivalent value to getAttributeTypes().length

getAttributeType

public AttributeType getAttributeType(java.lang.String xPath)
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)
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(java.lang.String attName)
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)
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()


Copyright © GeoTools. All Rights Reserved.