org.geotools.feature
Class AttributeBuilder

java.lang.Object
  extended by org.geotools.feature.AttributeBuilder

public class AttributeBuilder
extends java.lang.Object

Builder for attributes.

Author:
Justin Deoliveira, The Open Planning Project, jdeolive@openplans.org

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

Constructor Detail

AttributeBuilder

public AttributeBuilder(org.opengis.feature.FeatureFactory attributeFactory)
Method Detail

getFeatureFactory

public org.opengis.feature.FeatureFactory getFeatureFactory()
Returns the underlying attribute factory.


setFeatureFactory

public void setFeatureFactory(org.opengis.feature.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(org.opengis.feature.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(java.lang.String namespace)
This namespace will be used when constructing attribute names.


getNamespaceURI

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

Returns:
namespace will be used when constructing attribute names.

setType

public void setType(org.opengis.feature.type.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(org.opengis.feature.type.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 org.opengis.feature.type.AttributeType getType()
Returns:
The type of the attribute being built.

setCRS

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


getCRS

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

setDefaultGeometry

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


getDefaultGeometry

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

add

public org.opengis.feature.Attribute add(java.lang.Object value,
                                         java.lang.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(org.opengis.feature.Attribute value,
                      java.lang.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 org.opengis.feature.Attribute add(java.lang.Object value,
                                         java.lang.String name,
                                         java.lang.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(org.opengis.feature.Attribute attribute,
                      java.lang.String name,
                      java.lang.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 org.opengis.feature.Attribute add(java.lang.String id,
                                         java.lang.Object value,
                                         org.opengis.feature.type.Name name,
                                         org.opengis.feature.type.AttributeType type)
Adds an attribute to the complex attribute being built overriding the type of the declared attribute descriptor by a subtype of it.

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

Parameters:
id - the attribtue id
value - The value of the attribute.
name - The name of the attribute.
type - the actual type of the attribute, which might be the same as the declared type for the given AttributeDescriptor or a derived type.

add

public org.opengis.feature.Attribute add(java.lang.Object value,
                                         org.opengis.feature.type.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(org.opengis.feature.Attribute value,
                      org.opengis.feature.type.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 org.opengis.feature.Attribute add(java.lang.String id,
                                         java.lang.Object value,
                                         java.lang.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 org.opengis.feature.Attribute add(java.lang.String id,
                                         java.lang.Object value,
                                         java.lang.String name,
                                         java.lang.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 org.opengis.feature.Attribute add(java.lang.String id,
                                         java.lang.Object value,
                                         org.opengis.feature.type.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 java.util.List properties()
Convenience accessor for properties list which does the null check.


associationDescriptor

protected org.opengis.feature.type.AssociationDescriptor associationDescriptor(org.opengis.feature.type.Name name)

attributeDescriptor

protected org.opengis.feature.type.AttributeDescriptor attributeDescriptor(org.opengis.feature.type.Name name)

attributeDescriptor

protected org.opengis.feature.type.AttributeDescriptor attributeDescriptor(org.opengis.feature.type.Name name,
                                                                           org.opengis.feature.type.AttributeType actualType)

create

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


createComplexAttribute

public org.opengis.feature.ComplexAttribute createComplexAttribute(java.lang.Object value,
                                                                   org.opengis.feature.type.ComplexType type,
                                                                   org.opengis.feature.type.AttributeDescriptor descriptor,
                                                                   java.lang.String id)
Create complex attribute

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

build

public org.opengis.feature.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 org.opengis.feature.Attribute build(java.lang.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 org.opengis.feature.Attribute addAnyTypeValue(java.lang.Object value,
                                                     org.opengis.feature.type.AttributeType type,
                                                     org.opengis.feature.type.AttributeDescriptor descriptor,
                                                     java.lang.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 org.opengis.feature.Attribute addComplexAnyTypeAttribute(java.lang.Object value,
                                                                org.opengis.feature.type.AttributeDescriptor descriptor,
                                                                java.lang.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:


Copyright © 1996-2010 Geotools. All Rights Reserved.