All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opengis.feature.simple.SimpleFeature Maven / Gradle / Ivy

There is a newer version: 24.2-oss84-1
Show newest version
/*
 *    GeoTools - The Open Source Java GIS Toolkit
 *    http://geotools.org
 *
 *    (C) 2011, Open Source Geospatial Foundation (OSGeo)
 *    (C) 2004-2007 Open Geospatial Consortium Inc.
 *
 *    All Rights Reserved. http://www.opengis.org/legal/
 */
package org.opengis.feature.simple;

import java.util.List;
import org.opengis.feature.ComplexAttribute;
import org.opengis.feature.Feature;
import org.opengis.feature.type.Name;

/**
 * An instance of {@link SimpleFeatureType} composed of fixed list values in a known order.
 *
 * 

The definition of a "simple feature" can be summed up as the following: * *

    *
  • made up of only non-complex attributes, no associations *
  • attributes are of multiplicity 1 *
  • attributes are ordered *
  • attribute names are unqualified (namespaceURI == null) *
* *

* *

Attribute Access

* * The order and multiplicity restrictions on simple feature make attribute values accessible via an * index. For example consider the following shapefile entry: * *
 *  | GEOMETRY   | INT | STRING |
 *  | POINT(0 0) |  0  | "zero" |
 *  
* * Accessing attributes via index would look like: * *
 *  SimpleFeature feature = ...;
 *
 *  Geometry g = (Geometry) feature.getAttribute( 0 );
 *  Integer i = (Integer) feature.getAttribute( 1 );
 *  String s = (String) feature.getAttribute( 2 );
 *  
* * One could also access by name: * *
 *  SimpleFeature feature = ...;
 *
 *  Geometry g = (Geometry) feature.getAttribute( "GEOMETRY" );
 *  Integer i = (Integer) feature.getAttribute( "INT" );
 *  String s = (String) feature.getAttribute( "STRING" );
 *  
* *

Note: Attribute access via getAttribute() methods returns attribute values, and not the * attributes themselves. For access to the actual attributes {@link * ComplexAttribute#getProperty(String)} can be used. * * @see SimpleFeatureType * @author Jody Garnett (LISAsoft) * @author Justin Deoliveira (The Open Planning Project) * @since 2.5 * @version 8.0 */ public interface SimpleFeature extends Feature { /** * Unique Identifier for the SimpleFeature * *

This value is non-null and should be the same as getIdentifier().toString(). Please note * that an ID may be provided * * @return A unique identifier for the attribute, or null if the attribute is * non-identifiable. */ String getID(); /** Override and type narrow to SimpleFeatureType. */ SimpleFeatureType getType(); /** * The type of the feature. * *

This method is a synonym for {@link #getType()}. * * @see #getType() */ SimpleFeatureType getFeatureType(); /** * Returns a list of the values of the attributes contained by the feature.
* *

This method is a convenience for: * *

     * List values = new ArrayList();
     * for ( Property p : getProperties(); ) {
     *   values.add( p.getValue() );
     * }
     *
     * return values;
     * 
* * @return List of attribute values for the feature. */ List getAttributes(); /** * Sets the values of the attributes contained by the feature. * *

The values must be in the order of the attributes defined by the feature type. * *

This method is a convenience for: * *

     * int i = 0;
     * for ( Property p : getProperties() ) {
     *   p.setValue( values.get( i++ ) );
     * }
     * 
* * @param values The attribute values to set. */ void setAttributes(List values); /** * Sets the values of the attributes contained by the feature. * *

The values must be in the order of the attributes defined by the feature type. * *

This method is a convenience for: * *

     * for ( Property p : getProperties() ) {
     *   p.setValue( values[i] );
     * }
     * 
* * @param values The attribute values to set. */ void setAttributes(Object[] values); /** * Gets an attribute value by name. * *

This method is a convenience for: * *

     * Property p = getProperty( name );
     * return p.getValue();
     * 
* * @param name The name of the attribute whose value to retrieve. * @return The attribute value, or null if no such attribute exists with the * specified name. */ Object getAttribute(String name); /** * Sets an attribute value by name. * *

This method is a convenience for: * *

     * Property p = getProperty( name );
     * p.setValue(value);
     * 
* * @param name The name of the attribute whose value to set. * @param value The new value of the attribute. */ void setAttribute(String name, Object value); /** * Gets an attribute value by name. * *

This method is a convenience for: * *

     * Property p = getProperty( name );
     * return p.getValue();
     * 
* *

Since attribute names in simple features do not have a namespace uri this method is * equivalent to calling getAttribute(name.getLocalPart()). * * @param name The name of the attribute whose value to retrieve. * @return The attribute value, or null if no such attribute exists with the * specified name. */ Object getAttribute(Name name); /** * Sets an attribute value by name. * *

This method is a convenience for: * *

     * Property p = getProperty( name );
     * p.setValue(value);
     * 
* *

Since attribute names in simple features do not have a namespace uri this method is * equivalent to calling setAttribute(name.getLocalPart(), value). * * @param name The name of the attribute whose value to set. * @param value The new value of the attribute. */ void setAttribute(Name name, Object value); /** * Gets an attribute value by index. * *

This method is a convenience for: * *

     * Property p = ((List)getProperties()).get( i ) ;
     * return p.getValue();
     * 
* * @param index The index of the attribute whose value to get. * @return The attribute value at the specified index. * @throws IndexOutOfBoundsException If the specified index is out of bounds. */ Object getAttribute(int index) throws IndexOutOfBoundsException; /** * Sets an attribute value by index. * *

This method is a convenience for: * *

     * Property p = ((List)getProperties()).get( i ) ;
     * p.setValue(value);
     * 
* * @param index The index of the attribute whose value to set. * @param value The new value of the attribute. * @throws IndexOutOfBoundsException If the specified index is out of bounds. */ void setAttribute(int index, Object value) throws IndexOutOfBoundsException; /** * The number of attributes the feature is composed of. * *

This is a convenience for: * *

     *   return getAttributes().size();
     * 
* * @return Number of attributes of the feature. */ int getAttributeCount(); /** * Returns the value of the default geometry of the feature. * *

This method is convenience for: * *

     * return getDefaultGeometryProperty().getValue();
     * 
* * @return The default geometry, or null if no default geometry attribute exists. */ Object getDefaultGeometry(); /** * Sets the value of the default geometry for the feature. * *

This method is convenience for: * *

     * getDefaultGeometryProperty().setValue(geometry);
     * 
* * @param geometry The new default geometry value. */ void setDefaultGeometry(Object geometry); }