Class TypeBuilder
For reference the builder captures the following state:
State | Property | Complex | Feature | Builder | |||||||
---|---|---|---|---|---|---|---|---|---|---|---|
scope | state | descriptor() | attribute() | geometry() | association() | complex() | feature() | collection() | init() | reset() | clear() |
naming | namespace | x | x | x | x | x | x | x | x | ||
name | x | x | x | x | x | x | x | x | x | ||
isIdentified | x | x | x | x | x | x | x | ||||
description | x | x | x | x | x | x | x | x | |||
type | isAbstract | x | x | x | x | x | x | x | |||
superType | x | x | x | x | x | x | x | ||||
restriction* | x | x | x | x | x | x | x | ||||
association | referenceType | x | x | ||||||||
descriptor | minOccurs | x | x | x | |||||||
maxOccurs | x | x | x | ||||||||
isNillable | x | x | x | ||||||||
propertyType | x | x | |||||||||
atomic | binding | x | x | x | |||||||
complex | properties* | x | x | x | x | x | |||||
spatial | crs | x | x | x | x | ||||||
defaultGeom | x | x | x | x | |||||||
collection | members* | x | x | x |
There are five state control methods:
init(org.geotools.api.feature.type.PropertyType)
- completly load settings from typeinit(org.geotools.api.feature.type.PropertyDescriptor)
- completly load settings from descriptorinit()
- completly replace settings with builder defaults
For examples of using this class please see the following type creation methods:
attribute()
geometry()
association()
complex()
feature()
collection()
- Author:
- Justin Deoliveira, Jody Garnett
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Collection<PropertyDescriptor>
Members of a collection() -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd
(PropertyDescriptor descriptor) Add provided descriptor to the type to be created.void
addAttribute
(String name, Class binding) void
addAttribute
(String uri, String name, Class binding) void
addAttribute
(String name, String namespaceURI, AttributeType type) void
addAttribute
(String name, AttributeType type) void
addAttribute
(Name name, Class binding) void
addAttribute
(Name name, AttributeType type) void
addBinding
(Class binding, AttributeType type) Used to provide a specific type for provided binding.void
addMemberType
(String namespaceURI, String name, AssociationType memberType) Creates a association descriptor and adds to collection members.void
addMemberType
(String name, AssociationType memberType) Creates a association descriptor and adds to collection members.void
addMemberType
(Name name, AssociationType memberType) Creates a association descriptor and adds to collection members.void
addRestriction
(Filter restriction) Create AssociationTypeassociation
(String namespaceURI, String name, AssociationType type) association
(String name, AssociationType type) association
(Name name, AssociationType type) Create an AssociationDesctiptor, define relationships between ComplexAttribtues (in particular FeatureCollection to members).Creation method for AttributeType.Add a descriptor with a provided name, with the bindingAdd a descriptor with a provided name, with the bindingattribute
(String name, String namespaceURI, AttributeType type) attribute
(String name, AttributeType type) attribute
(Name name, AttributeType type) Create an AttributeDesctiptor, useful for fine grain control.protected Map<Class<?>,
AttributeType> bindings()
Accessor for bindings.cardinality
(int min, int max) void
clear()
complex()
Create a complex attribute, made up of other attributes.static boolean
contains
(Collection collection, PropertyDescriptor descriptor) protected Name
createName
(String ns, String local) Template method for creating an attribute name.Template method to enable subclasses to customize the set implementation used for restrictions.protected Name
createTypeName
(String ns, String local) Template method for creating a type name.Uses CRS utility class with buildres TypeFactory.getCRSFactory to look up a CoordinateReferenceSystem based on the provied srs.protected GeometryDescriptor
Convenience method for getting the descriptor of the default geometry type.defaultGeometry
(String name) feature()
Create feature.geometry()
Create GeometryType.Class<?>
getBinding
(Class binding) Used to lookup AttributeType for provided binding.getCRS()
int
Access to members used by builder.int
getName()
Access to properties used by builder.getSuper()
void
init()
Initialize this builder.void
init
(PropertyDescriptor descriptor) void
init
(PropertyType type) boolean
boolean
boolean
void
Load the indicated schema to map Java class to your Type System.member
(String name, AssociationType type) Creates a association descriptor and adds to collection members.member
(AssociationDescriptor memberOf) member
(Name name, AssociationType type) Creates a association descriptor and adds to collection members.protected Collection<PropertyDescriptor>
members()
Grab member collection as an argument to factory method.protected <T> Collection<T>
Template method to enable subclasses to customize the collection implementation used by "default".protected <T> Collection<T>
newCollection
(Collection<T> origional) Provides an empty copy of the provided origional collection.nillable
(boolean isNillable) protected Collection<PropertyDescriptor>
Grab property collection as an argument to factory method.property
(PropertyType type) Used as a the target for attributeDescriptor or associatioDescriptor().referenceType
(AttributeType reference) void
reset()
Reset is called after creation a "new" type.Accessor for restructions which does the null check and creation if necessary.void
setAbstract
(boolean isAbstract) void
setBinding
(Class<?> binding) void
void
setDefaultGeometry
(String name) void
setDefaultGeometry
(String name, String namespaceURI) void
setDefaultGeometry
(Name name) void
setDescription
(InternationalString description) void
setIdentified
(boolean isIdentified) void
setMaxOccurs
(int maxOccurs) void
setMembers
(Collection<PropertyDescriptor> members) Provide collection class used organize collection membersvoid
setMinOccurs
(int minOccurs) void
void
setNamespaceURI
(String namespace) void
setNillable
(boolean isNillable) void
setProperties
(Collection<PropertyDescriptor> properties) Allow for user supplied collection implementaion used for properties.void
setPropertyType
(PropertyType type) void
setReferenceType
(AttributeType reference) Allows you to indicate the reference type to be used with Association to be created.void
setRestrictions
(List<Filter> restrictions) void
setSuper
(PropertyType superType) void
setTypeFactory
(FeatureTypeFactory factory) protected Name
typeName()
Accessor which returns type banme as follows: IftypeName
has been set, its value is returned.
-
Field Details
-
members
Members of a collection()
-
-
Constructor Details
-
TypeBuilder
-
-
Method Details
-
getTypeFactory
-
setTypeFactory
-
reset
public void reset()Reset is called after creation a "new" type.The following information is reset:
- name
- properties: structural properties (attributes and associations)
- members: collection members
- default geometry
- minOccurs
- maxOccurs
Note: type type of collection class is not reset, a new instanceof the existing collection class is used.
-
clear
public void clear() -
init
public void init()Initialize this builder.This method cleans the builder of all contained state.
- See Also:
-
init
-
init
-
attribute
Creation method for AttributeType.Example:
AttributeType TEXT = builder.name("Text").bind(String.class).attribute();
Example:
builder.setName("Interger"); builder.setBinding(Integer.class); AttributeType INTEGER = builder.attribute();
- Returns:
- AttributeType created
-
association
Create AssociationType -
geometry
Create GeometryType.SFSQL Example JTS LineString.class:
Shape Example Java Rectangle2D:AttributeType ROUTE = builder.name("Route").bind(LineString.class).crs("EPSG:4326").geometry();
Use of GeoAPI Geometry interfaces is encouraged as implementations are made avaiable.builder.setName("Quad"); builder.setBinding(Rectangle2D.class); builder.setCRS(crs); AttributeType QUAD = builder.geometry();
-
complex
Create a complex attribute, made up of other attributes.Example using Set:
builder.setName("FullName"); builder.setProperties(new HasSet()); builder.addAttribute("first", TEXT); builder.setMinOccurs(0); builder.setMaxOccurs(Integer.MAX_VALUE); builder.addAttribute("middle", TEXT); builder.addAttribute("last", TEXT); ComplexType FULLNAME = builder.complex();
Example using chaining:
ComplexType FULLNAME = builder.name("FullName").attribute("first", TEXT).cardinality(0, Integer.MAX_VALUE).attribute("middle", TEXT).attribute("last", TEXT).complex();
- Returns:
- ComplexType
-
attributeDescriptor
Create an AttributeDesctiptor, useful for fine grain control.Example:
AttributeDescriptor name = build.name("name").property(TEXT).cardinality(1, 5) .attributeDescriptor();
- Returns:
- AttributeDescriptor used to define sturcture of ComplexAttribtues
-
associationDescriptor
Create an AssociationDesctiptor, define relationships between ComplexAttribtues (in particular FeatureCollection to members).Example:
AttributeDescriptor contains = build.name("contains").property(ROAD).nillable(false).cardinality(0, Interger.MAX_VALUE).associationDescriptor();
- Returns:
- AttributeDescriptor used to define sturcture of ComplexAttribtues
-
feature
Create feature.- Returns:
- FeatureType
-
setNamespaceURI
-
getNamespaceURI
-
setName
-
name
-
getName
-
setBinding
-
bind
-
getPropertyType
-
setPropertyType
-
property
Used as a the target for attributeDescriptor or associatioDescriptor().- Returns:
- TypeBuilder (for chaining).
-
getBinding
-
getDescription
-
setDescription
-
setAbstract
public void setAbstract(boolean isAbstract) -
isAbstract
public boolean isAbstract() -
nillable
-
setNillable
public void setNillable(boolean isNillable) -
isNillable
public boolean isNillable() -
setIdentified
public void setIdentified(boolean isIdentified) -
isIdentified
public boolean isIdentified() -
setSuper
-
getSuper
-
getAssociationSuper
-
addRestriction
-
getRestrictions
-
setRestrictions
-
restrictions
Accessor for restructions which does the null check and creation if necessary. -
createRestrictionSet
Template method to enable subclasses to customize the set implementation used for restrictions.- Returns:
- A HashSet.
-
typeName
Accessor which returns type banme as follows:- If
typeName
has been set, its value is returned. - If
name
has been set, it +namespaceURI
are returned.
- If
-
createTypeName
Template method for creating a type name.- Returns:
org.geotools.feature.iso.Types#typeName(String, String)
-
getBinding
Used to lookup AttributeType for provided binding.- Returns:
- AttributeType
- Throws:
IllegalArgumentExcception
- if class is not bound to a prototype
-
addBinding
Used to provide a specific type for provided binding.You can use this method to map the AttributeType used when addAttribute( String name, Class binding ) is called.
-
load
Load the indicated schema to map Java class to your Type System. (please us a profile to prevent binding conflicts). -
getMinOccurs
public int getMinOccurs() -
cardinality
-
setMinOccurs
public void setMinOccurs(int minOccurs) -
getMaxOccurs
public int getMaxOccurs() -
setMaxOccurs
public void setMaxOccurs(int maxOccurs) -
attribute
Add a descriptor with a provided name, with the binding- Parameters:
name
- Name of descriptor (combined with uri for a Name)binding
- Used to look up a bound AttributeType- Returns:
- this builder for additional chaining
-
attribute
Add a descriptor with a provided name, with the binding- Parameters:
name
- Name of descriptor (combined with uri for a Name)binding
- Used to look up a bound AttributeType- Returns:
- this builder for additional chaining
-
attribute
-
attribute
-
attribute
-
attribute
-
addAttribute
-
addAttribute
-
addAttribute
-
addAttribute
-
addAttribute
-
addAttribute
-
setReferenceType
Allows you to indicate the reference type to be used with Association to be created. -
referenceType
-
getReferenceType
-
association
-
association
-
association
-
add
Add provided descriptor to the type to be created.Please note that you may not have two types with the same name, depending on the factory being used the order of the structural content may be signficant - this builder will preserve order although the factory may or may not make use of this fact.
-
contains
-
getProperties
Access to properties used by builder.You can use this method to perform collection opperations before construction. This is most useful when initializing the builder with a known type, performing modifications, and then creating a derrived type.
-
setProperties
Allow for user supplied collection implementaion used for properties.Examples of useful property collections:
- List - structured properties maintained in order
- Set - order of structured properties insignificant
- etc...
getProperties() instanceof Set
indicates that Features of that FeatureType should maintain a Set of properties where order is not significant.- Parameters:
properties
- Collection implementation used to organize properties
-
newCollection
Template method to enable subclasses to customize the collection implementation used by "default".Considered moving this to the type interface but it would be in appropriate as the user may need to specifiy different collections for seperate types in the same schema.
- Returns:
- Collection (subclass may override)
-
newCollection
Provides an empty copy of the provided origional collection.This method is used by reset for the following goals:
- use the user supplied collection directly by the TypeFactory,
- remember the user supplied collection type for subsequent builder use
- Parameters:
origional
- Origional collection- Returns:
- New instance of the originoal Collection
-
properties
Grab property collection as an argument to factory method.This may return a copy as needed, since most calls to a factory method end up with a reset this seems not be needed at present.
-
bindings
Accessor for bindings. -
createName
Template method for creating an attribute name.- Returns:
org.geotools.feature.Types#typeName(String, String)
-
setDefaultGeometry
-
setDefaultGeometry
-
setDefaultGeometry
-
defaultGeometry
-
getDefaultGeometry
-
defaultGeometry
Convenience method for getting the descriptor of the default geometry type. This method will first try to look up the supplieddefaultGeom
property, if it cant find, it will try to locate any added geometry. -
setCRS
-
crs
-
crs
Uses CRS utility class with buildres TypeFactory.getCRSFactory to look up a CoordinateReferenceSystem based on the provied srs.A SpatialReferenceSystem can be one of the following:
- "AUTHORITY:CODE"
- Well Known Text
- Returns:
- TypeBuilder ready for chaining
- Throws:
IllegalArgumentException
- When SRS not understood
-
getCRS
-
getMembers
Access to members used by builder.You can use this method to perform collection opperations before construction. This is most useful when initializing the builder with a known type, performing modifications, and then creating a derrived type.
-
setMembers
Provide collection class used organize collection members -
members
Grab member collection as an argument to factory method.This may return a copy as needed, since most calls to a factory method end up with a reset this seems not be needed at present.
-
addMemberType
Creates a association descriptor and adds to collection members.Calls clear to reset cardinality after use.
-
addMemberType
Creates a association descriptor and adds to collection members.Calls clear to reset cardinality after use.
-
addMemberType
Creates a association descriptor and adds to collection members.Calls clear to reset cardinality after use.
-
member
Creates a association descriptor and adds to collection members.Calls clear to reset cardinality after use.
- Returns:
- TypeBuilder for operation chaining
-
member
Creates a association descriptor and adds to collection members.Calls clear to reset cardinality after use.
- Returns:
- TypeBuilder for operation chaining
-
member
-