Class FeatureSchema
java.lang.Object
com.vividsolutions.jump.feature.FeatureSchema
- All Implemented Interfaces:
Serializable, Cloneable
- Direct Known Subclasses:
AttributeMapping.CombinedSchema, FlexibleFeatureSchema
Metadata for a FeatureCollection: attribute names and types.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected List<AttributeType> protected CoordinateSystemprotected intprotected int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAttribute(String attributeName, AttributeType attributeType) Adds an attribute with the given case-sensitive name.voidaddDynamicAttribute(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.voidaddExternalPrimaryKey(String attributeName, AttributeType attributeType) Add an attribute containing an external identifier.clone()Creates a deep copy of this FeatureSchema.static voidcloneFromTo(FeatureSchema fsIn, FeatureSchema fsOut) a deepcopy routine to copy one FeatureSchema values into another, preferrable freshly createdbooleanReturns whether the two FeatureSchemas have the same attribute names with the same types and in the same order.booleanReturns whether the two FeatureSchemas have the same attribute names with the same types and (optionally) in the same order.intReturns the total number of spatial and non-spatial attributes in this FeatureSchema.intgetAttributeIndex(String attributeName) Returns the zero-based index of the attribute with the given name (case-sensitive)getAttributeName(int attributeIndex) Returns the (case-sensitive) name of the attribute at the given zero-based index.Returns an unmodifiable list containing all attribute names.getAttributeType(int attributeIndex) Returns whether the attribute at the given zero-based index is a string, integer, double, etc.getAttributeType(String attributeName) Returns whether the attribute with the given name (case-sensitive) is a string, integer, double, etc.intReturns the attribute index of the externalId attribute, or -1 if there is no externalId.intReturns the attribute index of the Geometry, or -1 if there is no Geometry attributegetOperation(int attributeIndex) Get the operation in charge of the attribute value evaluation.booleanhasAttribute(String attributeName) Returns whether this FeatureSchema has an attribute with this namebooleanisAttributeReadOnly(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 TRUEbooleanisOperation(int attributeIndex) Returns true if an attribute must be computed on the fly by an Operation.voidRemove the primary key from this schema definition.voidsetAttributeReadOnly(int attributeIndex, boolean isReadOnly) Sets the "readonly" status of the attribute specified by the attributeIndex.setCoordinateSystem(CoordinateSystem coordinateSystem) Sets the CoordinateSystem associated with this FeatureSchema, but does not perform any reprojection.voidsetExternalPrimaryKeyIndex(int index) Sets the primary key to be the attribute at position index.voidsetOperation(int attributeIndex, Operation operation) Set the Operation in charge of computing this attribute.toString()
-
Field Details
-
coordinateSystem
-
attributeNameToIndexMap
-
geometryIndex
protected int geometryIndex -
externalPKIndex
protected int externalPKIndex -
attributeCount
protected int attributeCount -
attributeNames
-
attributeTypes
-
attributeReadOnly
-
operations
-
-
Constructor Details
-
FeatureSchema
public FeatureSchema() -
FeatureSchema
-
-
Method Details
-
cloneFromTo
a deepcopy routine to copy one FeatureSchema values into another, preferrable freshly created- Parameters:
fsIn- input FeatureSchemafsOut- output 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
Returns the zero-based index of the attribute with the given name (case-sensitive)- Throws:
IllegalArgumentException- if attributeName is unrecognized
-
hasAttribute
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
Returns the (case-sensitive) name of the attribute at the given zero-based index. -
getAttributeType
Returns whether the attribute at the given zero-based index is a string, integer, double, etc. -
getAttributeType
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
-
addAttribute
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
-
equals
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
Sets the CoordinateSystem associated with this FeatureSchema, but does not perform any reprojection.- Returns:
- this FeatureSchema
-
getCoordinateSystem
- See Also:
-
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
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:
-
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
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
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
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)
-
toString
-