001: package org.geotools.feature.iso.type;
002:
003: import java.util.Collection;
004: import java.util.Set;
005:
006: import org.opengis.feature.type.AssociationDescriptor;
007: import org.opengis.feature.type.AssociationType;
008: import org.opengis.feature.type.AttributeDescriptor;
009: import org.opengis.feature.type.AttributeType;
010: import org.opengis.feature.type.ComplexType;
011: import org.opengis.feature.type.FeatureCollectionType;
012: import org.opengis.feature.type.FeatureType;
013: import org.opengis.feature.type.GeometryType;
014: import org.opengis.feature.type.Name;
015: import org.opengis.feature.type.OperationDescriptor;
016: import org.opengis.feature.type.OperationType;
017: import org.opengis.feature.type.Schema;
018: import org.opengis.feature.type.TypeFactory;
019: import org.opengis.filter.FilterFactory;
020: import org.opengis.referencing.crs.CRSFactory;
021: import org.opengis.referencing.crs.CoordinateReferenceSystem;
022: import org.opengis.util.InternationalString;
023:
024: /**
025: * This implementation is capable of creating a good default implementation of
026: * the Types used in the feature model.
027: * <p>
028: * The implementation focus here is on corretness rather then efficiency or even
029: * strict error messages. The code serves as a good example, but is not
030: * optimized for any particular use.
031: * </p>
032: *
033: * @author Jody Garnett
034: */
035: public class TypeFactoryImpl implements TypeFactory {
036: /** Used for spatial content */
037: CRSFactory crsFactory;
038:
039: /** Used for type restricftions */
040: FilterFactory filterFactory;
041:
042: /** Rely on setter injection */
043: public TypeFactoryImpl() {
044: this .crsFactory = null;
045: this .filterFactory = null;
046: }
047:
048: /** Constructor injection */
049: public TypeFactoryImpl(CRSFactory crsFactory,
050: FilterFactory filterFactory) {
051: this .crsFactory = crsFactory;
052: this .filterFactory = filterFactory;
053: }
054:
055: public Schema createSchema(String uri) {
056: return new SchemaImpl(uri);
057: }
058:
059: public CRSFactory getCRSFactory() {
060: return crsFactory;
061: }
062:
063: public void setCRSFactory(CRSFactory crsFactory) {
064: this .crsFactory = crsFactory;
065: }
066:
067: public FilterFactory getFilterFactory() {
068: return filterFactory;
069: }
070:
071: public void setFilterFactory(FilterFactory filterFactory) {
072: this .filterFactory = filterFactory;
073: }
074:
075: public OperationDescriptor createOperationDescriptor(
076: OperationType type, boolean isImplemented) {
077: throw new UnsupportedOperationException("implement");
078: }
079:
080: public AssociationDescriptor createAssociationDescriptor(
081: AssociationType type, Name name, int minOccurs,
082: int maxOccurs) {
083: return new AssociationDescriptorImpl(type, name, minOccurs,
084: maxOccurs);
085: }
086:
087: public AttributeDescriptor createAttributeDescriptor(
088: AttributeType type, Name name, int minOccurs,
089: int maxOccurs, boolean isNillable, Object defaultValue) {
090: return new AttributeDescriptorImpl(type, name, minOccurs,
091: maxOccurs, isNillable, defaultValue);
092: }
093:
094: public AssociationType createAssociationType(Name name,
095: AttributeType referenceType, boolean isIdentifiable,
096: boolean isAbstract, Set restrictions,
097: AssociationType super Type, InternationalString description) {
098: return new AssociationTypeImpl(name, referenceType,
099: isIdentifiable, isAbstract, restrictions, super Type,
100: description);
101: }
102:
103: public AttributeType createAttributeType(Name name, Class binding,
104: boolean isIdentifiable, boolean isAbstract,
105: Set restrictions, AttributeType super Type,
106: InternationalString description) {
107:
108: return new AttributeTypeImpl(name, binding, isIdentifiable,
109: isAbstract, restrictions, super Type, description);
110: }
111:
112: public ComplexType createComplexType(Name name, Collection schema,
113: boolean isIdentifiable, boolean isAbstract,
114: Set restrictions, AttributeType super Type,
115: InternationalString description) {
116:
117: return new ComplexTypeImpl(name, schema, isIdentifiable,
118: isAbstract, restrictions, super Type, description);
119: }
120:
121: public GeometryType createGeometryType(Name name, Class binding,
122: CoordinateReferenceSystem crs, boolean isIdentifiable,
123: boolean isAbstract, Set restrictions,
124: AttributeType super Type, InternationalString description) {
125:
126: return new GeometryTypeImpl(name, binding, crs, isIdentifiable,
127: isAbstract, restrictions, super Type, description);
128: }
129:
130: public FeatureType createFeatureType(Name name, Collection schema,
131: AttributeDescriptor defaultGeometry,
132: CoordinateReferenceSystem crs, boolean isAbstract,
133: Set restrictions, AttributeType super Type,
134: InternationalString description) {
135:
136: return new FeatureTypeImpl(name, schema, defaultGeometry, crs,
137: isAbstract, restrictions, super Type, description);
138: }
139:
140: public FeatureCollectionType createFeatureCollectionType(Name name,
141: Collection properties, Collection members,
142: AttributeDescriptor defaultGeom,
143: CoordinateReferenceSystem crs, boolean isAbstract,
144: Set restrictions, AttributeType super Type,
145: InternationalString description) {
146: return new FeatureCollectionTypeImpl(name, properties, members,
147: defaultGeom, crs, isAbstract, restrictions, superType,
148: description);
149: }
150: }
|