org.geotools.image.io.text
Class TextMetadataParser

java.lang.Object
  extended by org.geotools.image.io.text.TextMetadataParser
Direct Known Subclasses:
DefaultTextMetadataParser

public abstract class TextMetadataParser
extends java.lang.Object

Helper class for creating OpenGIS's object from a set of metadata. Metadata are key-value pairs, for example "Units=meters". There is a wide variety of ways to contruct OpenGIS's objects from key-value pairs, and supporting them is not always straightforward. The MetadataReader class tries to make the work easier. It defines a set of format-neutral keys (i.e. keys not related to any specific file format). Before parsing a file, the mapping between format-neutral keys and "real" keys used in a particuler file format must be specified. This mapping is constructed with calls to addAlias(org.geotools.image.io.text.TextMetadataParser.Key, java.lang.String). For example, one may want to parse the following informations:

 XMinimum           = 217904.31
 YMaximum           = 5663495.1
 XResolution        = 1000.0000
 YResolution        = 1000.0000
 Unit               = meters
 Projection         = Mercator_1SP
 Central meridian   = -15.2167
 Latitude of origin =  28.0667
 False easting      = 0.00000000
 False northing     = 0.00000000
 Ellipsoid          = Clarke 1866
 Datum              = Clarke 1866
 
Before to be used for parsing such informations, a MetadataReader object must be setup using the following code:
 addAlias(X_MINIMUM,    "XMinimum");
 addAlias(Y_MAXIMUM,    "YMaximum");
 addAlias(X_RESOLUTION, "XResolution");
 addAlias(Y_RESOLUTION, "YResolution");
 // etc...
 

Since:
2.5
Version:
$Id: TextMetadataParser.java 30972 2008-07-09 15:39:01Z cedricbr $
Author:
Martin Desruisseaux (IRD), Cédric Briançon

Nested Class Summary
static class TextMetadataParser.Key
          A key for fetching metadata in a format independent way.
 
Field Summary
static TextMetadataParser.Key CENTRAL_MERIDIAN
          Key for the "central_meridian" projection parameter.
static TextMetadataParser.Key COORDINATE_REFERENCE_SYSTEM
          Key for the coordinate reference system.
static TextMetadataParser.Key COORDINATE_REFERENCE_SYSTEM_TYPE
          Key for the coordinate reference system type.
static TextMetadataParser.Key COORDINATE_SYSTEM
          Key for the coordinate system.
static TextMetadataParser.Key COORDINATE_SYSTEM_TYPE
          Key for the coordinate system type.
static TextMetadataParser.Key DATUM
          Key for the coordinate reference system's datum.
static TextMetadataParser.Key DATUM_TYPE
           
static TextMetadataParser.Key DEPTH
          Key for the image's "depth" in pixels.
static TextMetadataParser.Key ELLIPSOID
          Key for the coordinate reference system ellipsoid.
static TextMetadataParser.Key ELLIPSOID_UNIT
          The unit of the ellipsoid.
static TextMetadataParser.Key FALSE_EASTING
          Key for the "false_easting" projection parameter.
static TextMetadataParser.Key FALSE_NORTHING
          Key for the "false_northing" projection parameter.
static TextMetadataParser.Key GREENWICH_LONGITUDE
          Key for the "greenwich_longitude" parameter.
static TextMetadataParser.Key HEIGHT
          Key for the image's height in pixels.
static TextMetadataParser.Key INVERSE_FLATTENING
          Key for the "inverse_flattening" ellipsoid parameter.
static TextMetadataParser.Key LATITUDE_OF_ORIGIN
          Key for the "latitude_of_origin" projection parameter.
protected  GeographicMetadata metadata
          The geogrpahic metadata to consider.
static TextMetadataParser.Key OPERATION_METHOD
          Key for the operation method.
static TextMetadataParser.Key PRIME_MERIDIAN
          Key for the "prime_meridian" name parameter.
static TextMetadataParser.Key PROJECTION
          Key for the projection.
static TextMetadataParser.Key SEMI_MAJOR
          Key for the "semi_major" ellipsoid parameter.
static TextMetadataParser.Key SEMI_MINOR
          Key for the "semi_minor" ellipsoid parameter.
static TextMetadataParser.Key UNIT
          Key for the coordinate system axis units.
static TextMetadataParser.Key WIDTH
          Key for the image's width in pixels.
static TextMetadataParser.Key X_DIRECTION
          Key for the direction among the x axis.
static TextMetadataParser.Key X_MAXIMUM
          Key for the maximal x value (eastern limit).
static TextMetadataParser.Key X_MINIMUM
          Key for the minimal x value (western limit).
static TextMetadataParser.Key X_RESOLUTION
          Key for the resolution among the x axis.
static TextMetadataParser.Key Y_DIRECTION
          Key for the direction among the y axis.
static TextMetadataParser.Key Y_MAXIMUM
          Key for the maximal y value (northern limit).
static TextMetadataParser.Key Y_MINIMUM
          Key for the minimal y value (southern limit).
static TextMetadataParser.Key Y_RESOLUTION
          Key for the resolution among the y axis.
static TextMetadataParser.Key Z_DIRECTION
          Key for the direction among the z axis.
static TextMetadataParser.Key Z_MAXIMUM
          Key for the maximal z value.
static TextMetadataParser.Key Z_MINIMUM
          Key for the minimal z value.
static TextMetadataParser.Key Z_RESOLUTION
          Key for the resolution among the z axis.
 
Constructor Summary
TextMetadataParser()
          Constructs a new MetadataReader using default factories.
TextMetadataParser(ReferencingFactoryContainer factories)
          Constructs a new MetadataReader using the specified factories.
 
Method Summary
 void add(javax.media.jai.PropertySource properties, java.lang.String prefix)
          Add metadata from the specified property source.
 void add(java.awt.image.RenderedImage image)
          Add all metadata from the specified image.
 void add(java.lang.String alias, java.lang.Object value)
          Add a metadata for the specified key.
 void addAlias(TextMetadataParser.Key key, java.lang.String alias)
          Add an alias to a key.
 void clear()
          Clears this metadata set.
 java.util.Set<java.lang.String> getAlias(TextMetadataParser.Key key)
          Returns the list of alias for the specified key, or null if the key has no alias.
 java.lang.String getFormatPattern(java.lang.Class<?> type)
          Returns the pattern used for parsing and formatting values of the specified type.
protected  GeographicMetadata getGeographicMetadata()
           
 java.util.Locale getLocale()
          Returns the locale to use when parsing metadata values as numbers, angles or dates.
 java.lang.String getSeparator()
          Returns the characters to use as separator between keys and values.
 java.lang.String getSource()
          Returns the source file name or URL.
protected  void load(java.io.BufferedReader in)
          Reads all metadata from a stream.
 void load(java.io.File header)
          Reads all metadata from a text file.
 void load(java.net.URL header)
          Reads all metadata from an URL.
protected  boolean parseLine(java.lang.String line)
          Parses a line and add the key-value pair to this metadata set.
protected abstract  void put(TextMetadataParser.Key key, java.lang.Object value)
          Put the specified value in the right node of the metadata tree.
protected abstract  void putDone()
          Should be launched after the put(Key, Object) method has been done.
 void setFormatPattern(java.lang.Class<?> type, java.lang.String pattern)
          Set the pattern to use for parsing and formatting values of the specified type.
protected  void setGeographicMetadata(GeographicMetadata metadata)
           
 void setSeparator(java.lang.String separator)
          Set the characters to use as separator between keys and values.
 java.lang.String toString()
          Returns a string representation of this metadata set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

metadata

protected GeographicMetadata metadata
The geogrpahic metadata to consider.


COORDINATE_REFERENCE_SYSTEM

public static final TextMetadataParser.Key COORDINATE_REFERENCE_SYSTEM
Key for the coordinate reference system. The MetadataReader.getCoordinateReferenceSystem() method looks for this metadata.

See Also:
UNIT, DATUM, PROJECTION

COORDINATE_REFERENCE_SYSTEM_TYPE

public static final TextMetadataParser.Key COORDINATE_REFERENCE_SYSTEM_TYPE
Key for the coordinate reference system type.

See Also:
UNIT, DATUM, PROJECTION

COORDINATE_SYSTEM

public static final TextMetadataParser.Key COORDINATE_SYSTEM
Key for the coordinate system. The MetadataReader.getCoordinateSystem() method looks for this metadata.

See Also:
UNIT, DATUM, PROJECTION

COORDINATE_SYSTEM_TYPE

public static final TextMetadataParser.Key COORDINATE_SYSTEM_TYPE
Key for the coordinate system type.

See Also:
UNIT, DATUM, PROJECTION

UNIT

public static final TextMetadataParser.Key UNIT
Key for the coordinate system axis units. The MetadataReader.getUnit(java.lang.String) method looks for this metadata. The following heuristic rule may be applied in order to infer the CRS from the units:

See Also:
ELLIPSOID, DATUM, PROJECTION, COORDINATE_REFERENCE_SYSTEM

DATUM

public static final TextMetadataParser.Key DATUM
Key for the coordinate reference system's datum. The MetadataReader.getDatum() method looks for this metadata.

See Also:
UNIT, ELLIPSOID, PROJECTION, COORDINATE_REFERENCE_SYSTEM

DATUM_TYPE

public static final TextMetadataParser.Key DATUM_TYPE

ELLIPSOID

public static final TextMetadataParser.Key ELLIPSOID
Key for the coordinate reference system ellipsoid. The MetadataReader.getEllipsoid() method looks for this metadata.

See Also:
UNIT, DATUM, PROJECTION, COORDINATE_REFERENCE_SYSTEM

ELLIPSOID_UNIT

public static final TextMetadataParser.Key ELLIPSOID_UNIT
The unit of the ellipsoid.


OPERATION_METHOD

public static final TextMetadataParser.Key OPERATION_METHOD
Key for the operation method. The MetadataReader.getProjection() method looks for this metadata. The operation method name determines the math transform implementation and its list of parameters. This name is the projection classification.

If this metadata is not defined, then the operation name is inferred from the projection name.

See Also:
PROJECTION, COORDINATE_REFERENCE_SYSTEM

PROJECTION

public static final TextMetadataParser.Key PROJECTION
Key for the projection. The MetadataReader.getProjection() method looks for this metadata. If the metadata is not defined, then the projection name is assumed the same than the operation method name.

See Also:
SEMI_MAJOR, SEMI_MINOR, LATITUDE_OF_ORIGIN, CENTRAL_MERIDIAN, FALSE_EASTING, FALSE_NORTHING

PRIME_MERIDIAN

public static final TextMetadataParser.Key PRIME_MERIDIAN
Key for the "prime_meridian" name parameter.


GREENWICH_LONGITUDE

public static final TextMetadataParser.Key GREENWICH_LONGITUDE
Key for the "greenwich_longitude" parameter.


SEMI_MAJOR

public static final TextMetadataParser.Key SEMI_MAJOR
Key for the "semi_major" ellipsoid parameter. There is no specific method for this key. However, this key may be queried indirectly by MetadataReader.getEllipsoid().

See Also:
SEMI_MINOR, INVERSE_FLATTENING, LATITUDE_OF_ORIGIN, CENTRAL_MERIDIAN, FALSE_EASTING, FALSE_NORTHING, PROJECTION

SEMI_MINOR

public static final TextMetadataParser.Key SEMI_MINOR
Key for the "semi_minor" ellipsoid parameter. There is no specific method for this key. However, this key may be queried indirectly by MetadataReader.getEllipsoid().

See Also:
INVERSE_FLATTENING, SEMI_MAJOR, LATITUDE_OF_ORIGIN, CENTRAL_MERIDIAN, FALSE_EASTING, FALSE_NORTHING, PROJECTION

INVERSE_FLATTENING

public static final TextMetadataParser.Key INVERSE_FLATTENING
Key for the "inverse_flattening" ellipsoid parameter. There is no specific method for this key. However, this key may be queried indirectly by MetadataReader.getEllipsoid().

See Also:
SEMI_MINOR, SEMI_MAJOR, LATITUDE_OF_ORIGIN, CENTRAL_MERIDIAN, FALSE_EASTING, FALSE_NORTHING, PROJECTION

LATITUDE_OF_ORIGIN

public static final TextMetadataParser.Key LATITUDE_OF_ORIGIN
Key for the "latitude_of_origin" projection parameter. There is no specific method for this key. However, this key may be queried indirectly by MetadataReader.getProjection().

See Also:
SEMI_MAJOR, SEMI_MINOR, CENTRAL_MERIDIAN, FALSE_EASTING, FALSE_NORTHING, PROJECTION

CENTRAL_MERIDIAN

public static final TextMetadataParser.Key CENTRAL_MERIDIAN
Key for the "central_meridian" projection parameter. There is no specific method for this key. However, this key may be queried indirectly by MetadataReader.getProjection().

See Also:
SEMI_MAJOR, SEMI_MINOR, LATITUDE_OF_ORIGIN, FALSE_EASTING, FALSE_NORTHING, PROJECTION

FALSE_EASTING

public static final TextMetadataParser.Key FALSE_EASTING
Key for the "false_easting" projection parameter. There is no specific method for this key. However, this key may be queried indirectly by MetadataReader.getProjection().

See Also:
SEMI_MAJOR, SEMI_MINOR, LATITUDE_OF_ORIGIN, CENTRAL_MERIDIAN, FALSE_NORTHING, PROJECTION

FALSE_NORTHING

public static final TextMetadataParser.Key FALSE_NORTHING
Key for the "false_northing" projection parameter. There is no specific method for this key. However, this key may be queried indirectly by MetadataReader.getProjection().

See Also:
SEMI_MAJOR, SEMI_MINOR, LATITUDE_OF_ORIGIN, CENTRAL_MERIDIAN, FALSE_EASTING, PROJECTION

X_MINIMUM

public static final TextMetadataParser.Key X_MINIMUM
Key for the minimal x value (western limit). This is usually the longitude coordinate of the upper left corner. The MetadataReader.getEnvelope() method looks for this metadata in order to set the minimal coordinate for dimension 0.

See Also:
X_MAXIMUM, Y_MINIMUM, Y_MAXIMUM, X_RESOLUTION, Y_RESOLUTION

Y_MINIMUM

public static final TextMetadataParser.Key Y_MINIMUM
Key for the minimal y value (southern limit). This is usually the latitude coordinate of the bottom right corner. The MetadataReader.getEnvelope() method looks for this metadata. in order to set the minimal coordinate for dimension 1.

See Also:
X_MINIMUM, X_MAXIMUM, Y_MAXIMUM, X_RESOLUTION, Y_RESOLUTION

Z_MINIMUM

public static final TextMetadataParser.Key Z_MINIMUM
Key for the minimal z value. This is usually the minimal altitude. The MetadataReader.getEnvelope() method looks for this metadata in order to set the minimal coordinate for dimension 2.

See Also:
Z_MAXIMUM, Z_RESOLUTION, DEPTH

X_MAXIMUM

public static final TextMetadataParser.Key X_MAXIMUM
Key for the maximal x value (eastern limit). This is usually the longitude coordinate of the bottom right corner. The MetadataReader.getEnvelope() method looks for this metadata in order to set the maximal coordinate for dimension 0.

See Also:
X_MINIMUM, Y_MINIMUM, Y_MAXIMUM, X_RESOLUTION, Y_RESOLUTION

Y_MAXIMUM

public static final TextMetadataParser.Key Y_MAXIMUM
Key for the maximal y value (northern limit). This is usually the latitude coordinate of the upper left corner. The MetadataReader.getEnvelope() method looks for this metadata in order to set the maximal coordinate for dimension 1.

See Also:
X_MINIMUM, X_MAXIMUM, Y_MINIMUM, X_RESOLUTION, Y_RESOLUTION

Z_MAXIMUM

public static final TextMetadataParser.Key Z_MAXIMUM
Key for the maximal z value. This is usually the maximal altitude. The MetadataReader.getEnvelope() method looks for this metadata in order to set the maximal coordinate for dimension 2.

See Also:
Z_MINIMUM, Z_RESOLUTION, DEPTH

X_RESOLUTION

public static final TextMetadataParser.Key X_RESOLUTION
Key for the resolution among the x axis. The MetadataReader.getEnvelope() method looks for this metadata in order to infer the coordinates for dimension 0.

See Also:
X_MINIMUM, X_MAXIMUM, Y_MINIMUM, Y_MAXIMUM, Y_RESOLUTION

Y_RESOLUTION

public static final TextMetadataParser.Key Y_RESOLUTION
Key for the resolution among the y axis. The MetadataReader.getEnvelope() method looks for this metadata in order to infer the coordinates for dimension 1.

See Also:
X_MINIMUM, X_MAXIMUM, Y_MINIMUM, Y_MAXIMUM, X_RESOLUTION, WIDTH, HEIGHT

Z_RESOLUTION

public static final TextMetadataParser.Key Z_RESOLUTION
Key for the resolution among the z axis. The MetadataReader.getEnvelope() method looks for this metadata in order to infer the coordinates for dimension 2.

See Also:
Z_MINIMUM, Z_MAXIMUM, DEPTH

X_DIRECTION

public static final TextMetadataParser.Key X_DIRECTION
Key for the direction among the x axis. The MetadataReader.getAxis(int) method looks for this metadata in order to set its direction.


Y_DIRECTION

public static final TextMetadataParser.Key Y_DIRECTION
Key for the direction among the y axis. The MetadataReader.getAxis(int) method looks for this metadata in order to set its direction.


Z_DIRECTION

public static final TextMetadataParser.Key Z_DIRECTION
Key for the direction among the z axis. The MetadataReader.getAxis(int) method looks for this metadata in order to set its direction.


WIDTH

public static final TextMetadataParser.Key WIDTH
Key for the image's width in pixels. The MetadataReader.getGridRange() method looks for this metadata in order to infer the grid size along the dimension 0.

See Also:
HEIGHT, X_RESOLUTION, Y_RESOLUTION

HEIGHT

public static final TextMetadataParser.Key HEIGHT
Key for the image's height in pixels. The MetadataReader.getGridRange() method looks for this metadata in order to infer the grid size along the dimension 1.

See Also:
WIDTH, X_RESOLUTION, Y_RESOLUTION

DEPTH

public static final TextMetadataParser.Key DEPTH
Key for the image's "depth" in pixels. This metadata may exists for 3D images, but some implementations accept at most 1 pixel depth among the third dimension. The MetadataReader.getGridRange() method looks for this metadata in order to infer the grid size along the dimension 2.

See Also:
Z_MINIMUM, Z_MAXIMUM, Z_RESOLUTION
Constructor Detail

TextMetadataParser

public TextMetadataParser()
Constructs a new MetadataReader using default factories.


TextMetadataParser

public TextMetadataParser(ReferencingFactoryContainer factories)
Constructs a new MetadataReader using the specified factories.

Method Detail

getSeparator

public java.lang.String getSeparator()
Returns the characters to use as separator between keys and values. Leading and trailing spaces will be keept when formatting with #listMetadata, but will be ignored when parsing with parseLine(java.lang.String). The default value is " = ".


setSeparator

public void setSeparator(java.lang.String separator)
Set the characters to use as separator between keys and values.


getFormatPattern

public java.lang.String getFormatPattern(java.lang.Class<?> type)
Returns the pattern used for parsing and formatting values of the specified type. The type should be either Number.class or Date.class.

In any case, this method returns null if this object should use the default pattern for the data locale.

Parameters:
type - The data type (Number.class or Date.class).
Returns:
The format pattern for the specified data type, or null for the default locale-dependent pattern.
Throws:
java.lang.IllegalArgumentException - if type is not valid.

setFormatPattern

public void setFormatPattern(java.lang.Class<?> type,
                             java.lang.String pattern)
Set the pattern to use for parsing and formatting values of the specified type. The type should be either Number.class or Date.class.

Parameters:
type - The data type (Number.class or Date.class).
pattern - The format pattern for the specified data type, or null for the default locale-dependent pattern.
Throws:
java.lang.IllegalArgumentException - if type is not valid.

clear

public void clear()
Clears this metadata set. If the same MetadataReader object is used for parsing many files, then clear() should be invoked prior any load(...) method. Note that clear() do not remove any alias, so this MetadataReader can be immediately reused for parsing new files of the same kind.


load

public void load(java.io.File header)
          throws java.io.IOException
Reads all metadata from a text file. The default implementation invokes load(BufferedReader). Note that this method do not invokes clear() prior the loading. Consequently, the loaded metadata will be added to the set of existing metadata.

Parameters:
header - The file to read until EOF.
Throws:
java.io.IOException - if an error occurs during loading.
See Also:
clear(), load(URL), parseLine(java.lang.String), getSource()

load

public void load(java.net.URL header)
          throws java.io.IOException
Reads all metadata from an URL. The default implementation invokes load(BufferedReader). Note that this method do not invokes clear() prior the loading. Consequently, the loaded metadata will be added to the set of existing metadata.

Parameters:
header - The URL to read until EOF.
Throws:
java.io.IOException - if an error occurs during loading.
See Also:
clear(), load(File), parseLine(java.lang.String), getSource()

load

protected void load(java.io.BufferedReader in)
             throws java.io.IOException
Reads all metadata from a stream. The default implementation invokes parseLine(java.lang.String) for each non-empty line found in the stream. Notes:

Parameters:
in - The stream to read until EOF. The stream will not be closed.
Throws:
java.io.IOException - if an error occurs during loading.
See Also:
clear(), load(File), load(URL), parseLine(java.lang.String)

parseLine

protected boolean parseLine(java.lang.String line)
                     throws javax.imageio.IIOException
Parses a line and add the key-value pair to this metadata set. The default implementation takes the substring on the left side of the first occurence of the separator (usually the '=' character) as the key, and the substring on the right side of the separator as the value. For example, if line has the following value:
 Ellipsoid = WGS 1984
 
Then, the default implementation will translate this line in the following call:
 add("Ellipsoid", "WGS 1984");
 
This method returns true if it has consumed the line, or false otherwise. A line is "consumed" if parseLine(...) has either added the key-value pair (using add(java.awt.image.RenderedImage)), or determined that the line must be ignored (for example because parseLine(...) detected a character announcing a comment line). A "consumed" line will not receive any further treatment. The line is not consumed (i.e. this method returns false) if parseLine(...) don't know what to do with it. Non-consumed line will typically go up in a chain of parseLine(...) methods (if MetadataReader has been subclassed) until someone consume it.

Parameters:
line - The line to parse.
Returns:
true if this method has consumed the line.
Throws:
javax.imageio.IIOException - if the line is badly formatted.
AmbiguousMetadataException - if a different value was already defined for the same metadata name.
See Also:
load(File), load(URL), add(String,Object)

add

public void add(java.awt.image.RenderedImage image)
         throws AmbiguousMetadataException
Add all metadata from the specified image.

Parameters:
image - The image with metadata to add to this MetadataReader.
Throws:
AmbiguousMetadataException - if a metadata is defined twice.
See Also:
#add(GridCoverage), add(PropertySource,String), add(String,Object)

add

public void add(javax.media.jai.PropertySource properties,
                java.lang.String prefix)
         throws AmbiguousMetadataException
Add metadata from the specified property source.

Parameters:
properties - The properties source.
prefix - The prefix for properties to add, of null to add all properties. If non-null, only properties begining with this prefix will be added.
Throws:
AmbiguousMetadataException - if a metadata is defined twice.
See Also:
#add(GridCoverage), add(RenderedImage), add(String,Object)

add

public void add(java.lang.String alias,
                java.lang.Object value)
         throws AmbiguousMetadataException
Add a metadata for the specified key. Keys are case-insensitive, ignore leading and trailing whitespaces and consider any other whitespace sequences as equal to a single '_' character.

Parameters:
alias - The key for the metadata to add. This is usually the name found in the file to be parsed (this is different from TextMetadataParser.Key objects, which are keys in a format neutral way). This key is usually, but not always, one of the alias defined with addAlias(org.geotools.image.io.text.TextMetadataParser.Key, java.lang.String).
value - The value for the metadata to add. If null or Image.UndefinedProperty, then this method do nothing.
Throws:
AmbiguousMetadataException - if a different value already exists for the specified alias, or for an other alias bound to the same TextMetadataParser.Key.
See Also:
#add(GridCoverage), add(RenderedImage), add(PropertySource,String), parseLine(java.lang.String)

addAlias

public void addAlias(TextMetadataParser.Key key,
                     java.lang.String alias)
              throws AmbiguousMetadataException
Add an alias to a key. After this method has been invoked, calls to get(key) will really looks for metadata named alias. Alias are mandatory in order to get various getXXX() methods to work for a particular file format.

For example if the file to be parsed uses the names "ULX" and "ULY" for the coordinate of the upper left corner, then the #getEnvelope method will not work unless the following alias are set:

 addAlias(X_MINIMUM, "ULX");
 addAlias(Y_MAXIMUM, "ULY");
 
An arbitrary number of alias can be set for the same key. For example, addAlias(Y_MAXIMUM, ...) could be invoked twice with "ULY" and "Limit North" alias. The getXXX() methods will try alias in the order they were added and use the first value found.

The same alias can also be set to more than one key. For example, the following code is legal. It means that pixel are square with the same horizontal and vertical resolution:

 addAlias(X_RESOLUTION, "Resolution");
 addAlias(Y_RESOLUTION, "Resolution");
 

Parameters:
key - The key to add an alias. This key is format neutral.
alias - The alias to add. This is the name actually used in the file to be parsed. Alias are case insensitive and ignore multiple whitespace, like keys. If this alias is already bound to the specified key, then this method do nothing.
Throws:
AmbiguousMetadataException - if the addition of the supplied alias would introduce an ambiguity in the current set of metadata. This occurs if the key has already an alias mapping to a different value.
See Also:
getAlias(org.geotools.image.io.text.TextMetadataParser.Key), #contains, #get

getAlias

public java.util.Set<java.lang.String> getAlias(TextMetadataParser.Key key)
Returns the list of alias for the specified key, or null if the key has no alias. Alias are the names used in the underlying metadata file, and are format dependent.

Parameters:
key - The format neutral key.
Returns:
The alias for the specified key, or null if none.
See Also:
addAlias(org.geotools.image.io.text.TextMetadataParser.Key, java.lang.String)

getSource

public java.lang.String getSource()
                           throws MetadataException
Returns the source file name or URL. This is the path specified during the last call to a load(...) method.

Returns:
The source file name or URL.
Throws:
MetadataException - if this information can't be fetched.

getLocale

public java.util.Locale getLocale()
Returns the locale to use when parsing metadata values as numbers, angles or dates. This is not the locale used for formatting error messages, if any. The default implementation returns Locale.US, since it is the format used in most data file.

Returns:
The locale to use for parsing metadata values.
Throws:
MetadataException - if this information can't be fetched.
See Also:
#getAsDouble, #getAsInt, #getAsDate

getGeographicMetadata

protected GeographicMetadata getGeographicMetadata()

setGeographicMetadata

protected void setGeographicMetadata(GeographicMetadata metadata)

put

protected abstract void put(TextMetadataParser.Key key,
                            java.lang.Object value)
Put the specified value in the right node of the metadata tree. This part is left to subclasses in order to provide different tree structure.

Parameters:
key - The alias of the key to add.
value - The value to add in the metadata tree.

putDone

protected abstract void putDone()
Should be launched after the put(Key, Object) method has been done. It will add axes according to the dimension defined, and sets grid range and offset vectors for all dimensions defined.


toString

public java.lang.String toString()
Returns a string representation of this metadata set. The default implementation write the class name and the envelope in geographic coordinates, as returned by #getGeographicBoundingBox. Then, it append the list of all metadata as formatted by #listMetadata.

Overrides:
toString in class java.lang.Object


Copyright © 1996-2010 Geotools. All Rights Reserved.