org.geotools.feature
Class AttributeBuilder

Object
  extended by AttributeBuilder
Direct Known Subclasses:
AppSchemaAttributeBuilder

public class AttributeBuilder
extends Object

Builder for attributes.

Author:
Justin Deoliveira (The Open Planning Project)

Field Summary
protected static ComplexType ANYTYPE_TYPE
           
 
Constructor Summary
AttributeBuilder(FeatureFactory attributeFactory)
           
 
Method Summary
 Attribute add(Object value, Name name)
          Adds an attribute to the complex attribute being built.
 Attribute add(Object value, String name)
          Adds an attribute to the complex attribute being built.
 Attribute add(Object value, String name, String namespaceURI)
          Adds an attribute to the complex attribute being built.
 Attribute add(String id, Object value, Name name)
          Adds an attribute to the complex attribute being built.
 Attribute add(String id, Object value, String name)
          Adds an attribute to the complex attribute being built.
 Attribute add(String id, Object value, String name, String namespaceURI)
          Adds an attribute to the complex attribute being built.
 Attribute addAnyTypeValue(Object value, AttributeType type, AttributeDescriptor descriptor, String id)
          Special case for any type.
 Attribute addComplexAnyTypeAttribute(Object value, AttributeDescriptor descriptor, String id)
          Create a complex attribute for XS.AnyType, since it's defined as a simple type.
 void associate(Attribute value, Name name)
          Adds an association to the complex attribute being built.
 void associate(Attribute value, String name)
          Adds an association to the complex attribute being built.
 void associate(Attribute attribute, String name, String namespaceURI)
          Adds an association to the complex attribute being built.
protected  AssociationDescriptor associationDescriptor(Name name)
           
protected  AttributeDescriptor attributeDescriptor(Name name)
           
 Attribute build()
          Builds the attribute.
 Attribute build(String id)
          Builds the attribute.
 Attribute buildSimple(String id, Object value)
           
protected  Attribute create(Object value, AttributeType type, AttributeDescriptor descriptor, String id)
          Factors out attribute creation code, needs to be called with either one of type or descriptor null.
 ComplexAttribute createComplexAttribute(Object value, ComplexType type, AttributeDescriptor descriptor, String id)
          Create complex attribute
 CoordinateReferenceSystem getCRS()
           
 CoordinateReferenceSystem getCRS(Object geom)
           
 Object getDefaultGeometry()
           
 AttributeDescriptor getDescriptor()
           
 FeatureFactory getFeatureFactory()
          Returns the underlying attribute factory.
 String getNamespaceURI()
          This namespace will be used when constructing attribute names.
protected  List getProperties()
          Convenience accessor for properties list which does the null check.
 AttributeType getType()
           
 void init()
          Initializes the builder to its initial state, the same state it is in directly after being instantiated.
 void init(Attribute attribute)
          Initializes the state of the builder based on a previously built attribute.
protected  List properties()
          Convenience accessor for properties list which does the null check.
 void setCRS(CoordinateReferenceSystem crs)
          Sets the coordinate reference system of the built feature.
 void setDefaultGeometry(Object defaultGeometry)
          Sets the default geometry of the feature.
 void setDescriptor(AttributeDescriptor descriptor)
          Sets the descriptor of the attribute being built.
 void setFeatureFactory(FeatureFactory attributeFactory)
          Sets the underlying attribute factory.
 void setNamespaceURI(String namespace)
          This namespace will be used when constructing attribute names.
 void setType(AttributeType type)
          Sets the type of the attribute being built.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ANYTYPE_TYPE

protected static final ComplexType ANYTYPE_TYPE
Constructor Detail

AttributeBuilder

public AttributeBuilder(FeatureFactory attributeFactory)
Method Detail

getFeatureFactory

public FeatureFactory getFeatureFactory()
Returns the underlying attribute factory.


setFeatureFactory

public void setFeatureFactory(FeatureFactory attributeFactory)
Sets the underlying attribute factory.


init

public void init()
Initializes the builder to its initial state, the same state it is in directly after being instantiated.


init

public void init(Attribute attribute)
Initializes the state of the builder based on a previously built attribute.

This method is useful when copying another attribute.


setNamespaceURI

public void setNamespaceURI(String namespace)
This namespace will be used when constructing attribute names.


getNamespaceURI

public String getNamespaceURI()
This namespace will be used when constructing attribute names.

Returns:
namespace will be used when constructing attribute names.

setType

public void setType(AttributeType type)
Sets the type of the attribute being built.

When building a complex attribute, this type is used a reference to obtain the types of contained attributes.


setDescriptor

public void setDescriptor(AttributeDescriptor descriptor)
Sets the descriptor of the attribute being built.

When building a complex attribute, this type is used a reference to obtain the types of contained attributes.


getType

public AttributeType getType()
Returns:
The type of the attribute being built.

setCRS

public void setCRS(CoordinateReferenceSystem crs)
Sets the coordinate reference system of the built feature.


getCRS

public CoordinateReferenceSystem getCRS(Object geom)
Returns:
The coordinate reference system of the feature, or null if not set.

setDefaultGeometry

public void setDefaultGeometry(Object defaultGeometry)
Sets the default geometry of the feature.


getDefaultGeometry

public Object getDefaultGeometry()
Returns:
The default geometry of the feature.

add

public Attribute add(Object value,
                     String name)
Adds an attribute to the complex attribute being built.

This method uses the result of getNamespaceURI() to build a qualified attribute name.

This method uses the type supplied in setType(AttributeType) in order to determine the attribute type.

Parameters:
name - The name of the attribute.
value - The value of the attribute.

associate

public void associate(Attribute value,
                      String name)
Adds an association to the complex attribute being built.

This method uses the result of getNamespaceURI() to build a qualified attribute name.

This method uses the type supplied in setType(AttributeType) in order to determine the association type.

Parameters:
value - The value of the association, an attribute.
name - The name of the association.

add

public Attribute add(Object value,
                     String name,
                     String namespaceURI)
Adds an attribute to the complex attribute being built.

This method uses the type supplied in setType(AttributeType) in order to determine the attribute type.

Parameters:
value - The value of the attribute.
name - The name of the attribute.
namespaceURI - The namespace of the attribute.

associate

public void associate(Attribute attribute,
                      String name,
                      String namespaceURI)
Adds an association to the complex attribute being built.

This method uses the type supplied in setType(AttributeType) in order to determine the association type.

Parameters:
value - The value of the association, an attribute.
name - The name of the association.
namespaceURI - The namespace of the association

add

public Attribute add(Object value,
                     Name name)
Adds an attribute to the complex attribute being built.

This method uses the type supplied in setType(AttributeType) in order to determine the attribute type.

Parameters:
name - The name of the attribute.
value - The value of the attribute.

associate

public void associate(Attribute value,
                      Name name)
Adds an association to the complex attribute being built.

This method uses the type supplied in setType(AttributeType) in order to determine the association type.

Parameters:
value - The value of the association, an attribute.
name - The name of the association.
namespaceURI - The namespace of the association

add

public Attribute add(String id,
                     Object value,
                     String name)
Adds an attribute to the complex attribute being built.

The result of getNamespaceURI() to build a qualified attribute name.

This method uses the type supplied in setType(AttributeType) in order to determine the attribute type.

Parameters:
id - The id of the attribute.
name - The name of the attribute.
value - The value of the attribute.

add

public Attribute add(String id,
                     Object value,
                     String name,
                     String namespaceURI)
Adds an attribute to the complex attribute being built.

This method uses the type supplied in setType(AttributeType) in order to determine the attribute type.

Parameters:
id - The id of the attribute.
value - The value of the attribute.
name - The name of the attribute.
namespaceURI - The namespace of the attribute.

add

public Attribute add(String id,
                     Object value,
                     Name name)
Adds an attribute to the complex attribute being built.

This method uses the type supplied in setType(AttributeType) in order to determine the attribute type.

Parameters:
id - The id of the attribute.
name - The name of the attribute.
value - The value of the attribute.

properties

protected List properties()
Convenience accessor for properties list which does the null check.


associationDescriptor

protected AssociationDescriptor associationDescriptor(Name name)

attributeDescriptor

protected AttributeDescriptor attributeDescriptor(Name name)

create

protected Attribute create(Object value,
                           AttributeType type,
                           AttributeDescriptor descriptor,
                           String id)
Factors out attribute creation code, needs to be called with either one of type or descriptor null.


createComplexAttribute

public ComplexAttribute createComplexAttribute(Object value,
                                               ComplexType type,
                                               AttributeDescriptor descriptor,
                                               String id)
Create complex attribute

Parameters:
value -
type -
descriptor -
id -
Returns:

build

public Attribute build()
Builds the attribute.

The class of the attribute built is determined from its type set with setType(AttributeType).

Returns:
The build attribute.

build

public Attribute build(String id)
Builds the attribute.

The class of the attribute built is determined from its type set with setType(AttributeType).

Parameters:
id - The id of the attribute, or null.
Returns:
The build attribute.

addAnyTypeValue

public Attribute addAnyTypeValue(Object value,
                                 AttributeType type,
                                 AttributeDescriptor descriptor,
                                 String id)
Special case for any type. Skip validating existence in the schema, since anyType legally can be casted into anything.

Parameters:
value - the value to be set
type - the type of the value
descriptor - the attribute descriptor of anyType type
id -
Returns:

addComplexAnyTypeAttribute

public Attribute addComplexAnyTypeAttribute(Object value,
                                            AttributeDescriptor descriptor,
                                            String id)
Create a complex attribute for XS.AnyType, since it's defined as a simple type. We need a complex attribute so we can set xlink:href in it.

Parameters:
value -
descriptor -
id -
Returns:

getDescriptor

public AttributeDescriptor getDescriptor()
Returns:
The descriptor of the attribute being built or null there is no descriptor (this occurs if setType() was used).

getCRS

public CoordinateReferenceSystem getCRS()
Returns:
The coordinate reference system of the feature, or null if not set.

getProperties

protected List getProperties()
Convenience accessor for properties list which does the null check.


buildSimple

public Attribute buildSimple(String id,
                             Object value)


Copyright © 1996-2014 Geotools. All Rights Reserved.