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:
  • Field Details

    • coordinateSystem

      protected CoordinateSystem coordinateSystem
    • attributeNameToIndexMap

      protected Map<String,Integer> attributeNameToIndexMap
    • geometryIndex

      protected int geometryIndex
    • externalPKIndex

      protected int externalPKIndex
    • attributeCount

      protected int attributeCount
    • attributeNames

      protected List<String> attributeNames
    • attributeTypes

      protected List<AttributeType> attributeTypes
    • attributeReadOnly

      protected List<Boolean> attributeReadOnly
    • operations

      protected ArrayList<Operation> operations
  • Constructor Details

    • FeatureSchema

      public FeatureSchema()
    • FeatureSchema

      public FeatureSchema(FeatureSchema fsIn)
  • Method Details

    • 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 FeatureSchema
      fsOut - 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.
      Overrides:
      clone in class Object
    • 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.
      Overrides:
      equals in class Object
    • 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:
    • 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 set
      isReadOnly - 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

      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 id
      attributeType - type of the external id
      Throws:
      IllegalArgumentException - if the attributeType of the id is not one of Integer, String or Object (for Long)
    • toString

      public String toString()
      Overrides:
      toString in class Object