Package com.vividsolutions.jump.feature
Class FeatureSchema
- java.lang.Object
-
- com.vividsolutions.jump.feature.FeatureSchema
-
- All Implemented Interfaces:
Serializable
,Cloneable
- Direct Known Subclasses:
AttributeMapping.CombinedSchema
,FlexibleFeatureSchema
public class FeatureSchema extends Object implements Cloneable, Serializable
Metadata for a FeatureCollection: attribute names and types.- See Also:
FeatureCollection
, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected int
attributeCount
protected List<String>
attributeNames
protected Map<String,Integer>
attributeNameToIndexMap
protected List<Boolean>
attributeReadOnly
protected List<AttributeType>
attributeTypes
protected CoordinateSystem
coordinateSystem
protected int
externalPKIndex
protected int
geometryIndex
protected ArrayList<Operation>
operations
-
Constructor Summary
Constructors Constructor Description FeatureSchema()
FeatureSchema(FeatureSchema fsIn)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAttribute(String attributeName, AttributeType attributeType)
Adds an attribute with the given case-sensitive name.void
addDynamicAttribute(String attributeName, AttributeType attributeType, Operation operation)
Add a dynamic attribute to this FeatureSchema A dynamic attribute is a readOnly attribute which is dynamically evaluated on demand.void
addExternalPrimaryKey(String attributeName, AttributeType attributeType)
Add an attribute containing an external identifier.FeatureSchema
clone()
Creates a deep copy of this FeatureSchema.static void
cloneFromTo(FeatureSchema fsIn, FeatureSchema fsOut)
a deepcopy routine to copy one FeatureSchema values into another, preferrable freshly createdboolean
equals(Object other)
Returns whether the two FeatureSchemas have the same attribute names with the same types and in the same order.boolean
equals(Object other, boolean orderMatters)
Returns whether the two FeatureSchemas have the same attribute names with the same types and (optionally) in the same order.int
getAttributeCount()
Returns the total number of spatial and non-spatial attributes in this FeatureSchema.int
getAttributeIndex(String attributeName)
Returns the zero-based index of the attribute with the given name (case-sensitive)String
getAttributeName(int attributeIndex)
Returns the (case-sensitive) name of the attribute at the given zero-based index.List<String>
getAttributeNames()
Returns an unmodifiable list containing all attribute names.AttributeType
getAttributeType(int attributeIndex)
Returns whether the attribute at the given zero-based index is a string, integer, double, etc.AttributeType
getAttributeType(String attributeName)
Returns whether the attribute with the given name (case-sensitive) is a string, integer, double, etc.CoordinateSystem
getCoordinateSystem()
int
getExternalPrimaryKeyIndex()
Returns the attribute index of the externalId attribute, or -1 if there is no externalId.int
getGeometryIndex()
Returns the attribute index of the Geometry, or -1 if there is no Geometry attributeOperation
getOperation(int attributeIndex)
Get the operation in charge of the attribute value evaluation.boolean
hasAttribute(String attributeName)
Returns whether this FeatureSchema has an attribute with this nameboolean
isAttributeReadOnly(int attributeIndex)
Returns the "readonly" status of the attribute specified by the attributeIndex.
A return result of TRUE means the a user will not be able to edit the attribute in the layer's attribute table, even though the layer's "editable" flag has been set to TRUEboolean
isOperation(int attributeIndex)
Returns true if an attribute must be computed on the fly by an Operation.void
removeExternalPrimaryKey()
Remove the primary key from this schema definition.void
setAttributeReadOnly(int attributeIndex, boolean isReadOnly)
Sets the "readonly" status of the attribute specified by the attributeIndex.FeatureSchema
setCoordinateSystem(CoordinateSystem coordinateSystem)
Sets the CoordinateSystem associated with this FeatureSchema, but does not perform any reprojection.void
setExternalPrimaryKeyIndex(int index)
Sets the primary key to be the attribute at position index.void
setOperation(int attributeIndex, Operation operation)
Set the Operation in charge of computing this attribute.String
toString()
-
-
-
Field Detail
-
coordinateSystem
protected CoordinateSystem coordinateSystem
-
geometryIndex
protected int geometryIndex
-
externalPKIndex
protected int externalPKIndex
-
attributeCount
protected int attributeCount
-
attributeTypes
protected List<AttributeType> attributeTypes
-
-
Constructor Detail
-
FeatureSchema
public FeatureSchema()
-
FeatureSchema
public FeatureSchema(FeatureSchema fsIn)
-
-
Method Detail
-
cloneFromTo
public static void cloneFromTo(FeatureSchema fsIn, FeatureSchema fsOut)
a deepcopy routine to copy one FeatureSchema values into another, preferrable freshly created- Parameters:
fsIn
- input FeatureSchemafsOut
- output FeatureSchema
-
clone
public FeatureSchema clone()
Creates a deep copy of this FeatureSchema. Warning : FeatureSchema.clone() does not follow general contract of clone (which recommends using super.clone) but makes a deep copy of the original FeatureSchema using the constructor.
-
getAttributeIndex
public int getAttributeIndex(String attributeName)
Returns the zero-based index of the attribute with the given name (case-sensitive)- Throws:
IllegalArgumentException
- if attributeName is unrecognized
-
hasAttribute
public boolean hasAttribute(String attributeName)
Returns whether this FeatureSchema has an attribute with this name- Parameters:
attributeName
- the name to look up- Returns:
- whether this FeatureSchema has an attribute with this name
-
getGeometryIndex
public int getGeometryIndex()
Returns the attribute index of the Geometry, or -1 if there is no Geometry attribute
-
getAttributeName
public String getAttributeName(int attributeIndex)
Returns the (case-sensitive) name of the attribute at the given zero-based index.
-
getAttributeType
public AttributeType getAttributeType(int attributeIndex)
Returns whether the attribute at the given zero-based index is a string, integer, double, etc.
-
getAttributeType
public AttributeType getAttributeType(String attributeName)
Returns whether the attribute with the given name (case-sensitive) is a string, integer, double, etc.
-
getAttributeCount
public int getAttributeCount()
Returns the total number of spatial and non-spatial attributes in this FeatureSchema. There are 0 or 1 spatial attributes and 0 or more non-spatial attributes.
-
getAttributeNames
public List<String> getAttributeNames()
Returns an unmodifiable list containing all attribute names. Method added to facilitate foreach iteration over attributes- Returns:
- an unmodifiable list of attribute names
-
addAttribute
public void addAttribute(String attributeName, AttributeType attributeType)
Adds an attribute with the given case-sensitive name.- Throws:
org.locationtech.jts.util.AssertionFailedException
- if a second Geometry is being added
-
addDynamicAttribute
public void addDynamicAttribute(String attributeName, AttributeType attributeType, Operation operation)
Add a dynamic attribute to this FeatureSchema A dynamic attribute is a readOnly attribute which is dynamically evaluated on demand.- Since:
- 1.6
-
equals
public boolean equals(Object other)
Returns whether the two FeatureSchemas have the same attribute names with the same types and in the same order.
-
equals
public boolean equals(Object other, boolean orderMatters)
Returns whether the two FeatureSchemas have the same attribute names with the same types and (optionally) in the same order. WARNING : be aware that equals method compare neither isReadOnly attribute nor operation. Not sure if it must be added.
-
setCoordinateSystem
public FeatureSchema setCoordinateSystem(CoordinateSystem coordinateSystem)
Sets the CoordinateSystem associated with this FeatureSchema, but does not perform any reprojection.- Returns:
- this FeatureSchema
-
getCoordinateSystem
public CoordinateSystem getCoordinateSystem()
- See Also:
setCoordinateSystem(CoordinateSystem)
-
isAttributeReadOnly
public boolean isAttributeReadOnly(int attributeIndex)
Returns the "readonly" status of the attribute specified by the attributeIndex.
A return result of TRUE means the a user will not be able to edit the attribute in the layer's attribute table, even though the layer's "editable" flag has been set to TRUE- Parameters:
attributeIndex
- The index of the attribute in question.- Returns:
- TRUE if the specified attribute has been previously set as readonly.
- See Also:
setAttributeReadOnly(int, boolean)
-
setAttributeReadOnly
public void setAttributeReadOnly(int attributeIndex, boolean isReadOnly)
Sets the "readonly" status of the attribute specified by the attributeIndex.
Some schemas (like those that represent database tables) can have attributes that should not be modified (like primary keys). Setting such an attribute as readonly means a user will not be able to edit the attribute in the layer's attribute table, even though the layer's "editable" flag has been set to TRUE- Parameters:
attributeIndex
- The index of the attribute to setisReadOnly
- A flag that indicates whether the specified attribute should be considered "readonly".- See Also:
isAttributeReadOnly(int)
-
isOperation
public boolean isOperation(int attributeIndex)
Returns true if an attribute must be computed on the fly by an Operation.- Parameters:
attributeIndex
- The index of the attribute in question.- Returns:
- TRUE if the specified attribute is dynamically computed.
-
setOperation
public void setOperation(int attributeIndex, Operation operation)
Set the Operation in charge of computing this attribute.- Parameters:
attributeIndex
- index of the attribute to compute.operation
- operation in charge of the evaluation.
-
getOperation
public Operation getOperation(int attributeIndex)
Get the operation in charge of the attribute value evaluation.- Parameters:
attributeIndex
- index of the attribute.
-
getExternalPrimaryKeyIndex
public int getExternalPrimaryKeyIndex()
Returns the attribute index of the externalId attribute, or -1 if there is no externalId.
-
setExternalPrimaryKeyIndex
public void setExternalPrimaryKeyIndex(int index)
Sets the primary key to be the attribute at position index.- Parameters:
index
- index of the external primary key
-
removeExternalPrimaryKey
public void removeExternalPrimaryKey()
Remove the primary key from this schema definition.
-
addExternalPrimaryKey
public void addExternalPrimaryKey(String attributeName, AttributeType attributeType)
Add an attribute containing an external identifier. This attribute is read-only fo OpenJUMP. It is the responsability of the external datastore to write in this attribute.- Parameters:
attributeName
- name of the external idattributeType
- type of the external id- Throws:
IllegalArgumentException
- if the attributeType of the id is not one of Integer, String or Object (for Long)
-
-