org.vfny.geoserver.global
Class FeatureTypeInfo

java.lang.Object
  extended byorg.vfny.geoserver.global.GlobalLayerSupertype
      extended byorg.vfny.geoserver.global.FeatureTypeInfo
All Implemented Interfaces:
org.geotools.data.FeatureTypeMetaData, org.geotools.data.MetaData

public class FeatureTypeInfo
extends org.vfny.geoserver.global.GlobalLayerSupertype
implements org.geotools.data.FeatureTypeMetaData

Represents a FeatureTypeInfo, its user config and autodefined information.


Field Summary
protected static java.util.logging.Logger LOGGER
          for debugging
 
Constructor Summary
FeatureTypeInfo(FeatureTypeInfoDTO dto, Data data)
          FeatureTypeInfo constructor.
 
Method Summary
 org.geotools.data.AttributeTypeMetaData AttributeTypeMetaData(java.lang.String attributeName)
          Implement AttributeTypeMetaData.
 boolean containsMetaData(java.lang.String key)
          Implement containsMetaData.
static java.lang.String get(java.util.Map map, java.lang.String key)
          get purpose.
static boolean get(java.util.Map map, java.lang.String key, boolean defaultValue)
          get purpose.
static java.nio.charset.Charset get(java.util.Map map, java.lang.String key, java.nio.charset.Charset defaultCharSet)
          get purpose.
static java.lang.Class get(java.util.Map map, java.lang.String key, java.lang.Class defaultType)
          get purpose.
static java.io.File get(java.util.Map map, java.lang.String key, java.io.File defaultFile)
          get purpose.
static int get(java.util.Map map, java.lang.String key, int defaultValue)
          get purpose.
static java.util.logging.Level get(java.util.Map map, java.lang.String key, java.util.logging.Level defaultLevel)
          get purpose.
static java.util.List get(java.util.Map map, java.lang.String key, java.util.List defaultList)
          get purpose.
static java.util.Map get(java.util.Map map, java.lang.String key, java.util.Map defaultMap)
          get purpose.
static java.lang.String get(java.util.Map map, java.lang.String key, java.lang.String defaultValue)
          get purpose.
static java.net.URL get(java.util.Map map, java.lang.String key, java.net.URL defaultUrl)
          get purpose.
 java.lang.String getAbstract()
          Get abstract (description) of FeatureType.
protected  java.lang.String getAttribute(org.w3c.dom.Element elem, java.lang.String attName, boolean mandatory)
          getAttribute purpose.
 java.util.List getAttributeNames()
          FeatureType attributes names as a List.
 com.vividsolutions.jts.geom.Envelope getBoundingBox()
          getBoundingBox purpose.
 DataStoreInfo getDataStoreInfo()
          getDataStore purpose.
 org.geotools.data.DataStoreMetaData getDataStoreMetaData()
          Implement getDataStoreMetaData.
 org.geotools.filter.Filter getDefinitionQuery()
          getDefinitionQuery purpose.
 org.geotools.data.FeatureSource getFeatureSource()
          getFeatureSource purpose.
 org.geotools.feature.FeatureType getFeatureType()
          Access real geotools2 FeatureType.
 java.util.List getKeywords()
          Keywords describing content of FeatureType.
 com.vividsolutions.jts.geom.Envelope getLatLongBoundingBox()
          getLatLongBoundingBox purpose.
 java.lang.Object getMetaData(java.lang.String key)
          Implement getMetaData.
 java.lang.String getName()
          overrides getName to return full type name with namespace prefix
 java.lang.String getName(boolean allowShort)
          Convenience method for those who just want to report the name of the featureType instead of requiring the full name for look up.
 NameSpaceInfo getNameSpace()
          Gets the namespace for this featureType.
 int getNumDecimals()
          getNumDecimals purpose.
 java.lang.String getPrefix()
          Returns the XML prefix used for GML output of this FeatureType.
 java.lang.String getSchemaBase()
          getSchemaName purpose.
 java.lang.String getSchemaName()
          getSchemaName purpose.
 java.lang.String getShortName()
          Same as getName()
 java.lang.String getSRS()
          getSRS purpose.
 java.lang.String getTitle()
          getTitle purpose.
 java.lang.String getTypeName()
          Access typeName.
 java.lang.String getXMLSchema()
          Get XMLSchema for this FeatureType.
 boolean isEnabled()
          Indicates if this FeatureTypeInfo is enabled.
static org.w3c.dom.Element loadConfig(java.io.Reader fis)
          loadConfig purpose.
protected  java.lang.String notNull(java.lang.String s)
          checks s for nullity and if so, returns an empty String, else just returns s
 void putMetaData(java.lang.String key, java.lang.Object value)
          Implement putMetaData.
static org.geotools.data.FeatureSource reTypeSource(org.geotools.data.FeatureSource source, FeatureTypeInfoDTO ftc)
           
 void setSchemaBase(java.lang.String string)
          setSchemaName purpose.
 void setSchemaName(java.lang.String string)
          setSchemaName purpose.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

protected static final java.util.logging.Logger LOGGER
for debugging

Constructor Detail

FeatureTypeInfo

public FeatureTypeInfo(FeatureTypeInfoDTO dto,
                       Data data)
                throws ConfigurationException
FeatureTypeInfo constructor.

Generates a new object from the data provided.

Parameters:
dto - FeatureTypeInfoDTO The data to populate this class with.
data - Data a reference for future use to get at DataStoreInfo instances
Throws:
ConfigurationException
Method Detail

getNumDecimals

public int getNumDecimals()
getNumDecimals purpose.

The default number of decimals allowed in the data.

Returns:
int the default number of decimals allowed in the data.

getDataStoreInfo

public DataStoreInfo getDataStoreInfo()
getDataStore purpose.

gets the string of the path to the schema file. This is set during feature reading, the schema file should be in the same folder as the feature type info, with the name schema.xml. This function does not guarantee that the schema file actually exists, it just gives the location where it _should_ be located.

Returns:
DataStoreInfo the requested DataStoreInfo if it was found.
See Also:
Data.getDataStoreInfo(String)

isEnabled

public boolean isEnabled()
Indicates if this FeatureTypeInfo is enabled. For now just gets whether the backing datastore is enabled.

Returns:
true if this FeatureTypeInfo is enabled.

getPrefix

public java.lang.String getPrefix()
Returns the XML prefix used for GML output of this FeatureType.

Returns the namespace prefix for this FeatureTypeInfo. This prefix also seems to be used as a "ID" for looking up GeoServer Namespace.

Returns:
String the namespace prefix.

getNameSpace

public NameSpaceInfo getNameSpace()
Gets the namespace for this featureType. This isn't _really_ necessary, but I'm putting it in in case we change namespaces, letting FeatureTypes set their own namespaces instead of being dependant on datasources. This method will allow us to make that change more easily in the future.

Returns:
NameSpaceInfo the namespace specified for the specified DataStoreInfo (by ID)
Throws:
java.lang.IllegalStateException - THrown when disabled.

getName

public java.lang.String getName()
overrides getName to return full type name with namespace prefix

Returns:
String the FeatureTypeInfo name - should be unique for the parent Data instance.

getName

public java.lang.String getName(boolean allowShort)
Convenience method for those who just want to report the name of the featureType instead of requiring the full name for look up. If allowShort is true then just the localName, with no prefix, will be returned if the dataStore is not enabled. If allow short is false then a full getName will be returned, with potentially bad results.

Parameters:
allowShort - does nothing
Returns:
String getName()
See Also:
getName()

getShortName

public java.lang.String getShortName()
Same as getName()

Returns:
String getName()
See Also:
getName()

getFeatureSource

public org.geotools.data.FeatureSource getFeatureSource()
                                                 throws java.io.IOException
getFeatureSource purpose.

Returns a real FeatureSource.

Specified by:
getFeatureSource in interface org.geotools.data.FeatureTypeMetaData
Returns:
FeatureSource the feature source represented by this info class
Throws:
java.io.IOException - when an error occurs.
org.geotools.data.DataSourceException - DOCUMENT ME!

reTypeSource

public static org.geotools.data.FeatureSource reTypeSource(org.geotools.data.FeatureSource source,
                                                           FeatureTypeInfoDTO ftc)
                                                    throws org.geotools.feature.SchemaException
Throws:
org.geotools.feature.SchemaException

getBoundingBox

public com.vividsolutions.jts.geom.Envelope getBoundingBox()
                                                    throws java.io.IOException
getBoundingBox purpose.

The feature source bounds.

Returns:
Envelope the feature source bounds.
Throws:
java.io.IOException - when an error occurs

getDefinitionQuery

public org.geotools.filter.Filter getDefinitionQuery()
getDefinitionQuery purpose.

Returns the definition query for this feature source

Returns:
Filter the definition query

getLatLongBoundingBox

public com.vividsolutions.jts.geom.Envelope getLatLongBoundingBox()
                                                           throws java.io.IOException
getLatLongBoundingBox purpose.

The feature source lat/long bounds.

Returns:
Envelope the feature source lat/long bounds.
Throws:
java.io.IOException - when an error occurs

getSRS

public java.lang.String getSRS()
getSRS purpose.

Proprietary identifier number

Returns:
int the SRS number.

getXMLSchema

public java.lang.String getXMLSchema()
                              throws java.io.IOException
Get XMLSchema for this FeatureType.

Note this may require connection to the real geotools2 DataStore and as such is subject to IOExceptions.

You have been warned.

Returns:
XMLFragment
Throws:
java.io.IOException - DOCUMENT ME!

getAttribute

protected java.lang.String getAttribute(org.w3c.dom.Element elem,
                                        java.lang.String attName,
                                        boolean mandatory)
                                 throws ConfigurationException
getAttribute purpose.

XLM helper method.

Parameters:
elem - The element to work on.
attName - The attribute name to find
mandatory - true is an exception is be thrown when the attr is not found.
Returns:
String the Attr value
Throws:
ConfigurationException - thrown when an error occurs.

loadConfig

public static org.w3c.dom.Element loadConfig(java.io.Reader fis)
                                      throws ConfigurationException
loadConfig purpose.

Parses the specified file into a DOM tree.

Parameters:
fis - The file to parse int a DOM tree.
Returns:
the resulting DOM tree
Throws:
ConfigurationException

getAbstract

public java.lang.String getAbstract()
Get abstract (description) of FeatureType.

Returns:
Short description of FeatureType

getKeywords

public java.util.List getKeywords()
Keywords describing content of FeatureType.

Keywords are often used by Search engines or Catalog services.

Returns:
List the FeatureTypeInfo keywords

getTitle

public java.lang.String getTitle()
getTitle purpose.

returns the FeatureTypeInfo title

Returns:
String the FeatureTypeInfo title

getSchemaName

public java.lang.String getSchemaName()
getSchemaName purpose.

Description ...

Returns:

setSchemaName

public void setSchemaName(java.lang.String string)
setSchemaName purpose.

Description ...

Parameters:
string -

getSchemaBase

public java.lang.String getSchemaBase()
getSchemaName purpose.

Description ...

Returns:

setSchemaBase

public void setSchemaBase(java.lang.String string)
setSchemaName purpose.

Description ...

Parameters:
string -

getTypeName

public java.lang.String getTypeName()
Access typeName.

Specified by:
getTypeName in interface org.geotools.data.FeatureTypeMetaData
Returns:
typeName for FeatureType
See Also:
FeatureTypeMetaData.getTypeName()

getFeatureType

public org.geotools.feature.FeatureType getFeatureType()
                                                throws java.io.IOException
Access real geotools2 FeatureType.

Specified by:
getFeatureType in interface org.geotools.data.FeatureTypeMetaData
Returns:
Schema information.
Throws:
java.io.IOException
See Also:
FeatureTypeMetaData.getFeatureType()

getDataStoreMetaData

public org.geotools.data.DataStoreMetaData getDataStoreMetaData()
Implement getDataStoreMetaData.

Specified by:
getDataStoreMetaData in interface org.geotools.data.FeatureTypeMetaData
Returns:
See Also:
FeatureTypeMetaData.getDataStoreMetaData()

getAttributeNames

public java.util.List getAttributeNames()
FeatureType attributes names as a List.

Convience method for accessing attribute names as a Collection. You may use the names for AttributeTypeMetaData lookup or with the schema for XPATH queries.

Specified by:
getAttributeNames in interface org.geotools.data.FeatureTypeMetaData
Returns:
List of attribute names
See Also:
FeatureTypeMetaData.getAttributeNames()

AttributeTypeMetaData

public org.geotools.data.AttributeTypeMetaData AttributeTypeMetaData(java.lang.String attributeName)
Implement AttributeTypeMetaData.

Description ...

Specified by:
AttributeTypeMetaData in interface org.geotools.data.FeatureTypeMetaData
Parameters:
attributeName -
Returns:
See Also:
FeatureTypeMetaData.AttributeTypeMetaData(java.lang.String)

containsMetaData

public boolean containsMetaData(java.lang.String key)
Implement containsMetaData.

Specified by:
containsMetaData in interface org.geotools.data.MetaData
Parameters:
key -
Returns:
See Also:
MetaData.containsMetaData(java.lang.String)

putMetaData

public void putMetaData(java.lang.String key,
                        java.lang.Object value)
Implement putMetaData.

Specified by:
putMetaData in interface org.geotools.data.MetaData
Parameters:
key -
value -
See Also:
MetaData.putMetaData(java.lang.String, java.lang.Object)

getMetaData

public java.lang.Object getMetaData(java.lang.String key)
Implement getMetaData.

Specified by:
getMetaData in interface org.geotools.data.MetaData
Parameters:
key -
Returns:
See Also:
MetaData.getMetaData(java.lang.String)

notNull

protected java.lang.String notNull(java.lang.String s)
checks s for nullity and if so, returns an empty String, else just returns s

Parameters:
s - String
Returns:
String non-null String (null -> "")

get

public static java.lang.String get(java.util.Map map,
                                   java.lang.String key)
get purpose.

Gets a String from a map of Strings

Parameters:
map - Map the map to extract the string from
key - String the key for the map.
Returns:
String the value in the map.
See Also:
Map

get

public static java.io.File get(java.util.Map map,
                               java.lang.String key,
                               java.io.File defaultFile)
get purpose.

Gets a File from a map given the specified key. If the file is not found the default file is returned.

Parameters:
map - Map the map to extract the file from
key - String the key to extract the value for
defaultFile - The default value should the key not exist.
Returns:
File a File as described above.

get

public static java.lang.String get(java.util.Map map,
                                   java.lang.String key,
                                   java.lang.String defaultValue)
get purpose.

Gets a String from a map of Strings, and returns the default if the string does not exist.

Parameters:
map - Map the map to extract the string from
key - String the key for the map.
defaultValue - The default value should the key not exist.
Returns:
String the value in the map.
See Also:
Map

get

public static java.util.List get(java.util.Map map,
                                 java.lang.String key,
                                 java.util.List defaultList)
get purpose.

Gets a List from a map given the specified key. If the list is not found the default list is returned.

Parameters:
map - Map the map to extract the file from
key - String the key to extract the value for
defaultList - The default value should the key not exist.
Returns:
List a List as described above.

get

public static java.util.Map get(java.util.Map map,
                                java.lang.String key,
                                java.util.Map defaultMap)
get purpose.

Gets a Map from a map given the specified key. If the map is not found the default map is returned.

Parameters:
map - Map the map to extract the file from
key - String the key to extract the value for
defaultMap - The default value should the key not exist.
Returns:
Map a Map as described above.

get

public static int get(java.util.Map map,
                      java.lang.String key,
                      int defaultValue)
get purpose.

Gets a int from a map given the specified key. If the int is not found the default int is returned.

Parameters:
map - Map the map to extract the file from
key - String the key to extract the value for
defaultValue - The default value should the key not exist.
Returns:
int an int as described above.

get

public static boolean get(java.util.Map map,
                          java.lang.String key,
                          boolean defaultValue)
get purpose.

Gets a boolean from a map given the specified key. If the boolean is not found the default boolean is returned.

Parameters:
map - Map the map to extract the file from
key - String the key to extract the value for
defaultValue - The default value should the key not exist.
Returns:
boolean an boolean as described above.

get

public static java.nio.charset.Charset get(java.util.Map map,
                                           java.lang.String key,
                                           java.nio.charset.Charset defaultCharSet)
get purpose.

Gets a Charset from a map given the specified key. If the Charset is not found the default Charset is returned.

Parameters:
map - Map the map to extract the file from
key - String the key to extract the value for
defaultCharSet - The default value should the key not exist.
Returns:
Charset an boolean as described above.

get

public static java.util.logging.Level get(java.util.Map map,
                                          java.lang.String key,
                                          java.util.logging.Level defaultLevel)
get purpose.

Gets a Level from a map given the specified key. If the Level is not found the default Level is returned.

Parameters:
map - Map the map to extract the file from
key - String the key to extract the value for
defaultLevel - The default value should the key not exist.
Returns:
Level an boolean as described above.

get

public static java.net.URL get(java.util.Map map,
                               java.lang.String key,
                               java.net.URL defaultUrl)
get purpose.

Gets a URL from a map given the specified key. If the URL is not found the default URL is returned.

Parameters:
map - Map the map to extract the file from
key - String the key to extract the value for
defaultUrl - The default value should the key not exist.
Returns:
URL an boolean as described above.

get

public static java.lang.Class get(java.util.Map map,
                                  java.lang.String key,
                                  java.lang.Class defaultType)
get purpose.

Gets a Class from a map given the specified key. If the Class is not found the default Class is returned.

Parameters:
map - Map the map to extract the file from
key - String the key to extract the value for
defaultType - The default value should the key not exist.
Returns:
Class an boolean as described above.