public class TypeBuilder extends Object
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( PropertyType )
- completly load settings from type
init( PropertyDescriptor )
- completly load settings from descriptor
init()
- 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()
Modifier and Type | Field and Description |
---|---|
protected Collection |
members
Members of a collection()
|
Constructor and Description |
---|
TypeBuilder(FeatureTypeFactory factory) |
Modifier and Type | Method and Description |
---|---|
TypeBuilder |
add(PropertyDescriptor descriptor)
Add provided descriptor to the type to be created.
|
void |
addAttribute(Name name,
AttributeType type) |
void |
addAttribute(Name name,
Class binding) |
void |
addAttribute(String name,
AttributeType type) |
void |
addAttribute(String name,
Class binding) |
void |
addAttribute(String name,
String namespaceURI,
AttributeType type) |
void |
addAttribute(String uri,
String name,
Class binding) |
void |
addBinding(Class binding,
AttributeType type)
Used to provide a specific type for provided binding.
|
void |
addMemberType(Name 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(String namespaceURI,
String name,
AssociationType memberType)
Creates a association descriptor and adds to collection members.
|
void |
addRestriction(Filter restriction) |
AssociationType |
association()
Create AssociationType
|
TypeBuilder |
association(Name name,
AssociationType type) |
TypeBuilder |
association(String name,
AssociationType type) |
TypeBuilder |
association(String namespaceURI,
String name,
AssociationType type) |
AssociationDescriptor |
associationDescriptor()
Create an AssociationDesctiptor, define relationships between ComplexAttribtues (in
particular FeatureCollection to members).
|
AttributeType |
attribute()
Creation method for AttributeType.
|
TypeBuilder |
attribute(Name name,
AttributeType type) |
TypeBuilder |
attribute(Name name,
Class binding) |
TypeBuilder |
attribute(String name,
AttributeType type) |
TypeBuilder |
attribute(String name,
Class binding)
Add a descriptor with a provided name, with the binding
|
TypeBuilder |
attribute(String name,
String namespaceURI,
AttributeType type) |
TypeBuilder |
attribute(String namespaceURI,
String name,
Class binding)
Add a descriptor with a provided name, with the binding
|
AttributeDescriptor |
attributeDescriptor()
Create an AttributeDesctiptor, useful for fine grain control.
|
TypeBuilder |
bind(Class<?> binding) |
protected Map |
bindings()
Accessor for bindings.
|
TypeBuilder |
cardinality(int min,
int max) |
void |
clear() |
ComplexType |
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.
|
protected List<Filter> |
createRestrictionSet()
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.
|
TypeBuilder |
crs(CoordinateReferenceSystem crs) |
TypeBuilder |
crs(String SRS)
Uses CRS utility class with buildres TypeFactory.getCRSFactory to look up a
CoordinateReferenceSystem based on the provied srs.
|
protected GeometryDescriptor |
defaultGeometry()
Convenience method for getting the descriptor of the default geometry type.
|
TypeBuilder |
defaultGeometry(String name) |
FeatureType |
feature()
Create feature.
|
GeometryType |
geometry()
Create GeometryType.
|
AssociationType |
getAssociationSuper() |
Class<?> |
getBinding() |
AttributeType |
getBinding(Class binding)
Used to lookup AttributeType for provided binding.
|
CoordinateReferenceSystem |
getCRS() |
Name |
getDefaultGeometry() |
InternationalString |
getDescription() |
int |
getMaxOccurs() |
Collection |
getMembers()
Access to members used by builder.
|
int |
getMinOccurs() |
String |
getName() |
String |
getNamespaceURI() |
Collection<PropertyDescriptor> |
getProperties()
Access to properties used by builder.
|
PropertyType |
getPropertyType() |
AttributeType |
getReferenceType() |
List<Filter> |
getRestrictions() |
AttributeType |
getSuper() |
FeatureTypeFactory |
getTypeFactory() |
void |
init()
Initialize this builder.
|
void |
init(PropertyDescriptor descriptor) |
void |
init(PropertyType type) |
boolean |
isAbstract() |
boolean |
isIdentified() |
boolean |
isNillable() |
void |
load(Schema schema)
Load the indicated schema to map Java class to your Type System.
|
TypeBuilder |
member(AssociationDescriptor memberOf) |
TypeBuilder |
member(Name name,
AssociationType type)
Creates a association descriptor and adds to collection members.
|
TypeBuilder |
member(String name,
AssociationType type)
Creates a association descriptor and adds to collection members.
|
protected Collection |
members()
Grab member collection as an argument to factory method.
|
TypeBuilder |
name(String name) |
protected Collection<PropertyDescriptor> |
newCollection()
Template method to enable subclasses to customize the collection implementation used by
"default".
|
protected Collection |
newCollection(Collection origional)
Provides an empty copy of the provided origional collection.
|
TypeBuilder |
nillable(boolean isNillable) |
protected Collection<PropertyDescriptor> |
properties()
Grab property collection as an argument to factory method.
|
TypeBuilder |
property(PropertyType type)
Used as a the target for attributeDescriptor or associatioDescriptor().
|
TypeBuilder |
referenceType(AttributeType reference) |
void |
reset()
Reset is called after creation a "new" type.
|
protected List<Filter> |
restrictions()
Accessor for restructions which does the null check and creation if necessary.
|
void |
setAbstract(boolean isAbstract) |
void |
setBinding(Class<?> binding) |
void |
setCRS(CoordinateReferenceSystem crs) |
void |
setDefaultGeometry(Name name) |
void |
setDefaultGeometry(String name) |
void |
setDefaultGeometry(String name,
String namespaceURI) |
void |
setDescription(InternationalString description) |
void |
setIdentified(boolean isIdentified) |
void |
setMaxOccurs(int maxOccurs) |
void |
setMembers(Collection members)
Provide collection class used organize collection members
|
void |
setMinOccurs(int minOccurs) |
void |
setName(String name) |
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:
If
typeName has been set, its value is returned. |
protected Collection members
public TypeBuilder(FeatureTypeFactory factory)
public FeatureTypeFactory getTypeFactory()
public void setTypeFactory(FeatureTypeFactory factory)
public void reset()
The following information is reset:
Note: type type of collection class is not reset, a new instanceof the existing collection class is used.
public void clear()
public void init()
This method cleans the builder of all contained state.
reset
public void init(PropertyDescriptor descriptor)
public void init(PropertyType type)
public AttributeType attribute()
Example:
AttributeType TEXT = builder.name("Text").bind(String.class).attribute();
Example:
builder.setName("Interger");
builder.setBinding(Integer.class);
AttributeType INTEGER = builder.attribute();
public AssociationType association()
public GeometryType geometry()
SFSQL Example JTS LineString.class:
AttributeType ROUTE = builder.name("Route").bind(LineString.class).crs("EPSG:4326").geometry();
Shape Example Java Rectangle2D:
builder.setName("Quad");
builder.setBinding(Rectangle2D.class);
builder.setCRS(crs);
AttributeType QUAD = builder.geometry();
Use of GeoAPI Geometry interfaces is encouraged as implementations are made avaiable.public ComplexType complex()
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();
public AttributeDescriptor attributeDescriptor()
Example:
AttributeDescriptor name = build.name("name").property(TEXT).cardinality(1, 5)
.attributeDescriptor();
public AssociationDescriptor associationDescriptor()
Example:
AttributeDescriptor contains = build.name("contains").property(ROAD).nillable(false).cardinality(0,
Interger.MAX_VALUE).associationDescriptor();
public FeatureType feature()
public void setNamespaceURI(String namespace)
public String getNamespaceURI()
public void setName(String name)
public TypeBuilder name(String name)
public String getName()
public void setBinding(Class<?> binding)
public TypeBuilder bind(Class<?> binding)
public PropertyType getPropertyType()
public void setPropertyType(PropertyType type)
public TypeBuilder property(PropertyType type)
type
- public Class<?> getBinding()
public InternationalString getDescription()
public void setDescription(InternationalString description)
public void setAbstract(boolean isAbstract)
public boolean isAbstract()
public TypeBuilder nillable(boolean isNillable)
public void setNillable(boolean isNillable)
public boolean isNillable()
public void setIdentified(boolean isIdentified)
public boolean isIdentified()
public void setSuper(PropertyType superType)
public AttributeType getSuper()
public AssociationType getAssociationSuper()
public void addRestriction(Filter restriction)
protected List<Filter> restrictions()
protected List<Filter> createRestrictionSet()
protected Name typeName()
typeName
has been set, its value is returned.
name
has been set, it + namespaceURI
are returned.
protected Name createTypeName(String ns, String local)
org.geotools.feature.iso.Types#typeName(String, String)
public AttributeType getBinding(Class binding)
binding
- IllegalArgumentExcception
- if class is not bound to a prototypepublic void addBinding(Class binding, AttributeType type)
You can use this method to map the AttributeType used when addAttribute( String name, Class binding ) is called.
binding
- type
- public void load(Schema schema)
schema
- public int getMinOccurs()
public TypeBuilder cardinality(int min, int max)
public void setMinOccurs(int minOccurs)
public int getMaxOccurs()
public void setMaxOccurs(int maxOccurs)
public TypeBuilder attribute(String name, Class binding)
name
- Name of descriptor (combined with uri for a Name)binding
- Used to look up a bound AttributeTypepublic TypeBuilder attribute(String namespaceURI, String name, Class binding)
namespaceURI
- name
- Name of descriptor (combined with uri for a Name)binding
- Used to look up a bound AttributeTypepublic TypeBuilder attribute(Name name, Class binding)
public TypeBuilder attribute(String name, String namespaceURI, AttributeType type)
public TypeBuilder attribute(String name, AttributeType type)
public TypeBuilder attribute(Name name, AttributeType type)
public void addAttribute(String name, AttributeType type)
public void addAttribute(String name, String namespaceURI, AttributeType type)
public void addAttribute(Name name, AttributeType type)
public void setReferenceType(AttributeType reference)
public TypeBuilder referenceType(AttributeType reference)
public AttributeType getReferenceType()
public TypeBuilder association(String name, AssociationType type)
public TypeBuilder association(String namespaceURI, String name, AssociationType type)
public TypeBuilder association(Name name, AssociationType type)
public TypeBuilder add(PropertyDescriptor descriptor)
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.
public static boolean contains(Collection collection, PropertyDescriptor descriptor)
public Collection<PropertyDescriptor> getProperties()
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.
public void setProperties(Collection<PropertyDescriptor> properties)
Examples of useful property collections:
getProperties() instanceof Set
indicates that
Features of that FeatureType should maintain a Set of properties where order is not
significant.properties
- Collection implementation used to organize propertiesprotected Collection<PropertyDescriptor> newCollection()
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.
protected Collection newCollection(Collection origional)
This method is used by reset for the following goals:
origional
- Origional collectionprotected Collection<PropertyDescriptor> properties()
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.
protected Map bindings()
protected Name createName(String ns, String local)
org.geotools.feature.Types#typeName(String, String)
public void setDefaultGeometry(String name)
public void setDefaultGeometry(Name name)
public TypeBuilder defaultGeometry(String name)
public Name getDefaultGeometry()
protected GeometryDescriptor defaultGeometry()
defaultGeom
property, if it cant find, it will
try to locate any added geometry.public void setCRS(CoordinateReferenceSystem crs)
public TypeBuilder crs(CoordinateReferenceSystem crs)
public TypeBuilder crs(String SRS)
A SpatialReferenceSystem can be one of the following:
srs
- IllegalArgumentException
- When SRS not understoodpublic CoordinateReferenceSystem getCRS()
public Collection getMembers()
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.
public void setMembers(Collection members)
protected Collection members()
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.
public void addMemberType(String name, AssociationType memberType)
Calls clear to reset cardinality after use.
name
- type
- public void addMemberType(String namespaceURI, String name, AssociationType memberType)
Calls clear to reset cardinality after use.
name
- type
- public void addMemberType(Name name, AssociationType memberType)
Calls clear to reset cardinality after use.
name
- type
- public TypeBuilder member(String name, AssociationType type)
Calls clear to reset cardinality after use.
name
- type
- public TypeBuilder member(Name name, AssociationType type)
Calls clear to reset cardinality after use.
name
- type
- public TypeBuilder member(AssociationDescriptor memberOf)
Copyright © 1996–2019 Geotools. All rights reserved.