Class AttributeTypeBuilder
- Object
-
- AttributeTypeBuilder
-
public class AttributeTypeBuilder extends Object
Builder for attribute types and descriptors.Building an attribute type:
//create the builder AttributeTypeBuilder builder = new AttributeTypeBuilder(); //set type information builder.setName( "intType" ): builder.setBinding( Integer.class ); builder.setNillable( false ); //build the type AttributeType type = builder.buildType();Building an attribute descriptor:
//create the builder AttributeTypeBuilder builder = new AttributeTypeBuilder(); //set type information builder.setName( "intType" ): builder.setBinding( Integer.class ); builder.setNillable( false ); //set descriptor information builder.setMinOccurs(0); builder.setMaxOccurs(1); builder.setNillable(true); //build the descriptor AttributeDescriptor descriptor = builder.buildDescriptor("intProperty");This class maintains state and is not thread safe.
- Author:
- Justin Deoliveira, The Open Planning Project, jdeolive@openplans.org
-
-
Field Summary
Fields Modifier and Type Field Description protected Class<?>bindingbound java classprotected CoordinateReferenceSystemcrsprotected ObjectdefaultValuedefault valueprotected InternationalStringdescriptionstring descriptionprotected FeatureTypeFactoryfactoryfactoryprotected FilterFactoryfffilter factoryprotected booleanisAbstractabstract flagprotected booleanisCrsSetprotected booleanisDefaultValueSetprotected booleanisIdentifiableidentifiable flagprotected booleanisNillableTrue if value is allowed to be null.protected IntegerlengthIf this value is set an additional restriction will be added based on the length function.protected IntegermaxOccursMaximum number of occurrences allowed.protected IntegerminOccursMinimum number of occurrences allowed.protected StringnameLocal name used to name a descriptor; or combined with namespaceURI to name a type.protected StringnamespaceURInamespace used to distingish between otherwise identical type names.protected List<Filter>restrictionsrestrictionsprotected AttributeTypesuperTypesuper typeprotected Map<Object,Object>userDataUser data for the attribute.
-
Constructor Summary
Constructors Constructor Description AttributeTypeBuilder()Constructs the builder.AttributeTypeBuilder(FeatureTypeFactory factory)Constructs the builder specifying the factory used to build attribute types.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AttributeTypeBuilderabstrct(boolean isAbstract)voidaddRestriction(Filter restriction)voidaddUserData(Object key, Object value)AttributeTypeBuilderbinding(Class<?> binding)AttributeDescriptorbuildDescriptor(String name)Builds an attribute descriptor first building an attribute type from internal state.AttributeDescriptorbuildDescriptor(String name, AttributeType type)Builds an attribute descriptor specifying its attribute type.GeometryDescriptorbuildDescriptor(String name, GeometryType type)Builds a geometry descriptor specifying its attribute type.AttributeDescriptorbuildDescriptor(Name name, AttributeType type)GeometryDescriptorbuildDescriptor(Name name, GeometryType type)GeometryTypebuildGeometryType()Builds the geometry attribute type.AttributeTypebuildType()Builds the attribute type.AttributeTypeBuildercrs(CoordinateReferenceSystem crs)AttributeTypeBuilderdefaultValue(Object defaultValue)AttributeTypeBuilderdescription(String description)AttributeTypeBuilderidentifiable(boolean isIdentifiable)protected voidinit()Resets all internal state.voidinit(AttributeDescriptor descriptor)Initializes builder state from another attribute descriptor.AttributeTypeBuilderinit(AttributeType type)Initializes builder state from another attribute type.booleanisCRSSet()AttributeTypeBuilderlength(int length)protected FilterlengthRestriction(int length)Helper method to create a "length" filter.AttributeTypeBuildermaxOccurs(int maxOccurs)AttributeTypeBuilderminOccurs(int minOccurs)AttributeTypeBuildername(String name)AttributeTypeBuildernamespaceURI(String namespaceURI)AttributeTypeBuildernillable(boolean isNillable)AttributeTypeBuilderoptions(List<?> options)Sets a list of possible valid values for the attribute type being built, and returns a reference to the builder itselfAttributeTypeBuilderrange(NumberRange<? extends Number> range)Sets a range to which the attribute value should be contained in and returns a reference to the builder itselfprotected voidresetDescriptorState()protected voidresetTypeState()Resets all builder state used to build the attribute type.AttributeTypeBuilderrestriction(Filter restriction)protected List<Filter>restrictions()voidsetAbstract(boolean isAbstract)voidsetBinding(Class<?> binding)voidsetCRS(CoordinateReferenceSystem crs)voidsetDefaultValue(Object defaultValue)voidsetDescription(String description)voidsetDescription(InternationalString description)AttributeTypeBuildersetFactory(FeatureTypeFactory factory)voidsetIdentifiable(boolean isIdentifiable)voidsetLength(int length)voidsetMaxOccurs(int maxOccurs)voidsetMinOccurs(int minOccurs)voidsetName(String name)voidsetNamespaceURI(String namespaceURI)voidsetNillable(boolean isNillable)voidsetOptions(List<?> options)Sets a list of possible valid values for the attribute type being builtvoidsetRange(NumberRange<? extends Number> range)Sets a range to which the attribute value should be contained in.AttributeTypeBuildersuperType(AttributeType superType)AttributeTypeBuilderuserData(Object key, Object value)
-
-
-
Field Detail
-
factory
protected FeatureTypeFactory factory
factory
-
name
protected String name
Local name used to name a descriptor; or combined with namespaceURI to name a type.
-
namespaceURI
protected String namespaceURI
namespace used to distingish between otherwise identical type names.
-
isAbstract
protected boolean isAbstract
abstract flag
-
description
protected InternationalString description
string description
-
isIdentifiable
protected boolean isIdentifiable
identifiable flag
-
binding
protected Class<?> binding
bound java class
-
superType
protected AttributeType superType
super type
-
defaultValue
protected Object defaultValue
default value
-
isDefaultValueSet
protected boolean isDefaultValueSet
-
crs
protected CoordinateReferenceSystem crs
-
isCrsSet
protected boolean isCrsSet
-
minOccurs
protected Integer minOccurs
Minimum number of occurrences allowed. See minOccurs() function for the default value based on nillable if not explicitly set.
-
maxOccurs
protected Integer maxOccurs
Maximum number of occurrences allowed. See maxOccurs() function for the default value (of 1).
-
isNillable
protected boolean isNillable
True if value is allowed to be null.Depending on this value minOccurs, maxOccurs and defaultValue() will return different results.
The default value is
true.
-
length
protected Integer length
If this value is set an additional restriction will be added based on the length function.
-
ff
protected FilterFactory ff
filter factory
-
-
Constructor Detail
-
AttributeTypeBuilder
public AttributeTypeBuilder()
Constructs the builder.
-
AttributeTypeBuilder
public AttributeTypeBuilder(FeatureTypeFactory factory)
Constructs the builder specifying the factory used to build attribute types.
-
-
Method Detail
-
init
protected void init()
Resets all internal state.
-
resetTypeState
protected void resetTypeState()
Resets all builder state used to build the attribute type.This method is called automatically after
buildType()andbuildGeometryType().
-
resetDescriptorState
protected void resetDescriptorState()
-
setFactory
public AttributeTypeBuilder setFactory(FeatureTypeFactory factory)
-
init
public AttributeTypeBuilder init(AttributeType type)
Initializes builder state from another attribute type.
-
init
public void init(AttributeDescriptor descriptor)
Initializes builder state from another attribute descriptor.
-
setBinding
public void setBinding(Class<?> binding)
-
setName
public void setName(String name)
-
setNamespaceURI
public void setNamespaceURI(String namespaceURI)
-
setCRS
public void setCRS(CoordinateReferenceSystem crs)
-
isCRSSet
public boolean isCRSSet()
-
setDescription
public void setDescription(String description)
-
setDescription
public void setDescription(InternationalString description)
-
setAbstract
public void setAbstract(boolean isAbstract)
-
setIdentifiable
public void setIdentifiable(boolean isIdentifiable)
-
setLength
public void setLength(int length)
-
addRestriction
public void addRestriction(Filter restriction)
-
setNillable
public void setNillable(boolean isNillable)
-
setMaxOccurs
public void setMaxOccurs(int maxOccurs)
-
setMinOccurs
public void setMinOccurs(int minOccurs)
-
setDefaultValue
public void setDefaultValue(Object defaultValue)
-
binding
public AttributeTypeBuilder binding(Class<?> binding)
-
name
public AttributeTypeBuilder name(String name)
-
namespaceURI
public AttributeTypeBuilder namespaceURI(String namespaceURI)
-
crs
public AttributeTypeBuilder crs(CoordinateReferenceSystem crs)
-
description
public AttributeTypeBuilder description(String description)
-
abstrct
public AttributeTypeBuilder abstrct(boolean isAbstract)
-
identifiable
public AttributeTypeBuilder identifiable(boolean isIdentifiable)
-
length
public AttributeTypeBuilder length(int length)
-
options
public AttributeTypeBuilder options(List<?> options)
Sets a list of possible valid values for the attribute type being built, and returns a reference to the builder itself
-
setOptions
public void setOptions(List<?> options)
Sets a list of possible valid values for the attribute type being built
-
range
public AttributeTypeBuilder range(NumberRange<? extends Number> range)
Sets a range to which the attribute value should be contained in and returns a reference to the builder itself
-
setRange
public void setRange(NumberRange<? extends Number> range)
Sets a range to which the attribute value should be contained in.
-
restriction
public AttributeTypeBuilder restriction(Filter restriction)
-
nillable
public AttributeTypeBuilder nillable(boolean isNillable)
-
maxOccurs
public AttributeTypeBuilder maxOccurs(int maxOccurs)
-
minOccurs
public AttributeTypeBuilder minOccurs(int minOccurs)
-
defaultValue
public AttributeTypeBuilder defaultValue(Object defaultValue)
-
userData
public AttributeTypeBuilder userData(Object key, Object value)
-
superType
public AttributeTypeBuilder superType(AttributeType superType)
-
buildType
public AttributeType buildType()
Builds the attribute type.This method resets all state after the attribute is built.
-
buildGeometryType
public GeometryType buildGeometryType()
Builds the geometry attribute type.This method resets all state after the attribute is built.
-
buildDescriptor
public AttributeDescriptor buildDescriptor(String name)
Builds an attribute descriptor first building an attribute type from internal state.If
crshas been set viasetCRS(CoordinateReferenceSystem), orbindingis of Geometry. The internal attribute type will be built viabuildGeometryType(), andbuildDescriptor(String, GeometryType)will be called.Otherwise it will be built via
buildType(), andbuildDescriptor(String, AttributeType)will be called.- Parameters:
name- The name of the descriptor.- Throws:
IllegalStateException- If no binding is set- See Also:
buildDescriptor(String, AttributeType)
-
buildDescriptor
public AttributeDescriptor buildDescriptor(String name, AttributeType type)
Builds an attribute descriptor specifying its attribute type.Internal state is reset after the descriptor is built.
- Parameters:
name- The name of the descriptor.type- The type referenced by the descriptor.
-
buildDescriptor
public GeometryDescriptor buildDescriptor(String name, GeometryType type)
Builds a geometry descriptor specifying its attribute type.Internal state is reset after the descriptor is built.
- Parameters:
name- The name of the descriptor.type- The geometry type referenced by the descriptor.
-
buildDescriptor
public AttributeDescriptor buildDescriptor(Name name, AttributeType type)
-
buildDescriptor
public GeometryDescriptor buildDescriptor(Name name, GeometryType type)
-
lengthRestriction
protected Filter lengthRestriction(int length)
Helper method to create a "length" filter.
-
-