Java Doc for MetadataBuilder.java in  » GIS » GeoTools-2.4.1 » org » geotools » coverage » io » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » GIS » GeoTools 2.4.1 » org.geotools.coverage.io 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.geotools.coverage.io.MetadataBuilder

MetadataBuilder
public class MetadataBuilder (Code)
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 MetadataBuilder 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 MetadataBuilder.addAlias . For example, one may want to parse the following informations:
 XMinimum           = 217904.31
 YMaximum           = 5663495.1
 XResolution        = 1000.0000
 YResolution        = 1000.0000
 Units              = 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 MetadataBuilder object must be setup using the following code:
 addAlias(
MetadataBuilder.X_MINIMUM ,    "XMinimum");
 addAlias(
MetadataBuilder.Y_MAXIMUM ,    "YMaximum");
 addAlias(
MetadataBuilder.X_RESOLUTION , "XResolution");
 addAlias(
MetadataBuilder.Y_RESOLUTION , "YResolution");
 // etc...
 
Once the mapping is etablished, MetadataBuilder provides a set of getXXX() methods for constructing various objects from those informations. For example, the MetadataBuilder.getCoordinateReferenceSystem method constructs a CoordinateReferenceSystem object using available informations.
version:
   $Id: MetadataBuilder.java 25699 2007-05-31 15:55:07Z desruisseaux $
author:
   Martin Desruisseaux
since:
   2.2

Inner Class :public static class Key implements Serializable

Field Summary
final public static  KeyCENTRAL_MERIDIAN
     Key for the "central_meridian" projection parameter.
final public static  KeyCOORDINATE_REFERENCE_SYSTEM
     Key for the .
final public static  KeyDATUM
     Key for the coordinate reference system's .
final public static  KeyDEPTH
     Key for the image's "depth" in pixels.
final public static  KeyELLIPSOID
     Key for the coordinate reference system .
final public static  KeyFALSE_EASTING
     Key for the "false_easting" projection parameter.
final public static  KeyFALSE_NORTHING
     Key for the "false_northing" projection parameter.
final public static  KeyHEIGHT
     Key for the image's height in pixels.
final public static  KeyLATITUDE_OF_ORIGIN
     Key for the "latitude_of_origin" projection parameter.
final public static  KeyOPERATION_METHOD
     Key for the .
final public static  KeyPROJECTION
     Key for the .
final public static  KeySEMI_MAJOR
     Key for the "semi_major" projection parameter.
final public static  KeySEMI_MINOR
     Key for the "semi_minor" projection parameter.
final public static  KeyUNITS
     Key for the units. The MetadataBuilder.getUnit method looks for this metadata.
final public static  KeyWIDTH
     Key for the image's width in pixels.
final public static  KeyX_MAXIMUM
     Key for the maximal x value (eastern limit).
final public static  KeyX_MINIMUM
     Key for the minimal x value (western limit).
final public static  KeyX_RESOLUTION
     Key for the resolution among the x axis.
final public static  KeyY_MAXIMUM
     Key for the maximal y value (northern limit).
final public static  KeyY_MINIMUM
     Key for the minimal y value (southern limit). This is usually the latitude coordinate of the bottom right corner. The MetadataBuilder.getEnvelope method looks for this metadata.
final public static  KeyY_RESOLUTION
     Key for the resolution among the y axis.
final public static  KeyZ_MAXIMUM
     Key for the maximal z value.
final public static  KeyZ_MINIMUM
     Key for the minimal z value.
final public static  KeyZ_RESOLUTION
     Key for the resolution among the z axis.

Constructor Summary
public  MetadataBuilder()
     Constructs a new MetadataBuilder using default factories.
public  MetadataBuilder(FactoryGroup factories)
     Constructs a new MetadataBuilder using the specified factories.

Method Summary
public synchronized  voidadd(GridCoverage coverage)
     Add all metadata from the specified grid coverage.
public synchronized  voidadd(RenderedImage image)
     Add all metadata from the specified image.
public synchronized  voidadd(PropertySource properties, String prefix)
     Add metadata from the specified property source.
Parameters:
  properties - The properties source.
Parameters:
  prefix - The prefix for properties to add, of null to addall properties.
public synchronized  voidadd(String alias, Object value)
     Add a metadata for the specified key.
public synchronized  voidaddAlias(Key key, String alias)
     Add an alias to a key.
public synchronized  voidclear()
     Clears this metadata set.
public synchronized  booleancontains(Key key)
     Checks if this MetadataBuilder contains a value for the specified key. Invoking MetadataBuilder.get will thrown a MissingMetadataException if and only if MetadataBuilder.contains returns false for the same key.
Parameters:
  key - The key to test for inclusion in this MetadataBuilder .
public synchronized  Objectget(Key key)
     Returns the metadata for the specified key.
public synchronized  String[]getAlias(Key key)
     Returns the list of alias for the specified key, or null if the key has no alias.
public synchronized  DategetAsDate(Key key)
     Returns a metadata as a Date value.
public synchronized  doublegetAsDouble(Key key)
     Returns a metadata as a double value.
public synchronized  intgetAsInt(Key key)
     Returns a metadata as a int value.
public synchronized  CoordinateReferenceSystemgetCoordinateReferenceSystem()
     Returns the coordinate reference system.
public synchronized  EllipsoidgetEllipsoid()
     Returns the ellipsoid.
public synchronized  EnvelopegetEnvelope()
     Returns the envelope.
public  StringgetFormatPattern(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 .

  • if type is assignable to Number.class , then this method returns the number pattern as specified by DecimalFormat .
  • Otherwise, if type is assignable to Date.class , then this method returns the date pattern as specified by SimpleDateFormat .

In any case, this method returns null if this object should use the default pattern for the .
Parameters:
  type - The data type ( Number.class or Date.class ).

public synchronized  GeodeticDatumgetGeodeticDatum()
     Returns the geodetic datum.
public synchronized  GeographicBoundingBoxgetGeographicBoundingBox()
     Convenience method returning the envelope in geographic coordinate system using WGS 1984 datum.
throws:
  MetadataException - if the operation failed.
public synchronized  GridRangegetGridRange()
     Returns the grid range.
public  LocalegetLocale()
     Returns the locale to use when parsing metadata values as numbers, angles or dates.
public synchronized  ConversiongetProjection()
     Returns the projection.
public  GridSampleDimension[]getSampleDimensions()
     Returns the sample dimensions for each band of the GridCoverage to be read.
public  StringgetSeparator()
     Returns the characters to use as separator between keys and values.
public  StringgetSource()
     Returns the source file name or URL.
public synchronized  UnitgetUnit()
     Returns the units.
public synchronized  voidlistMetadata(Writer out)
     List all metadata to the specified stream.
public synchronized  voidload(File header)
     Reads all metadata from a text file.
public synchronized  voidload(URL header)
     Reads all metadata from an URL.
protected  voidload(BufferedReader in)
     Reads all metadata from a stream.
protected  booleanparseLine(String line)
     Parses a line and add the key-value pair to this metadata set.
public synchronized  voidsetFormatPattern(Class type, String pattern)
     Set the pattern to use for parsing and formatting values of the specified type.
public synchronized  voidsetSeparator(String separator)
     Set the characters to use as separator between keys and values.
final synchronized  voidsetUserLocale(Locale locale)
     Sets the current Locale of this MetadataBuilder to the given value.
public  StringtoString()
     Returns a string representation of this metadata set.
static  Stringtrim(String str, String separator)
     Trim a character string.

Field Detail
CENTRAL_MERIDIAN
final public static Key CENTRAL_MERIDIAN(Code)
Key for the "central_meridian" projection parameter. There is no specific method for this key. However, this key may be queried indirectly by MetadataBuilder.getProjection .
See Also:   MetadataBuilder.SEMI_MAJOR
See Also:   MetadataBuilder.SEMI_MINOR
See Also:   MetadataBuilder.LATITUDE_OF_ORIGIN
See Also:   MetadataBuilder.FALSE_EASTING
See Also:   MetadataBuilder.FALSE_NORTHING
See Also:   MetadataBuilder.PROJECTION



COORDINATE_REFERENCE_SYSTEM
final public static Key COORDINATE_REFERENCE_SYSTEM(Code)
Key for the . The MetadataBuilder.getCoordinateReferenceSystem method looks for this metadata.
See Also:   MetadataBuilder.UNITS
See Also:   MetadataBuilder.DATUM
See Also:   MetadataBuilder.PROJECTION



DATUM
final public static Key DATUM(Code)
Key for the coordinate reference system's . The MetadataBuilder.getGeodeticDatum method looks for this metadata.
See Also:   MetadataBuilder.UNITS
See Also:   MetadataBuilder.ELLIPSOID
See Also:   MetadataBuilder.PROJECTION
See Also:   MetadataBuilder.COORDINATE_REFERENCE_SYSTEM



DEPTH
final public static Key DEPTH(Code)
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 MetadataBuilder.getGridRange method looks for this metadata in order to infer the along the dimension 2.
See Also:   MetadataBuilder.Z_MINIMUM
See Also:   MetadataBuilder.Z_MAXIMUM
See Also:   MetadataBuilder.Z_RESOLUTION



ELLIPSOID
final public static Key ELLIPSOID(Code)
Key for the coordinate reference system . The MetadataBuilder.getEllipsoid method looks for this metadata.
See Also:   MetadataBuilder.UNITS
See Also:   MetadataBuilder.DATUM
See Also:   MetadataBuilder.PROJECTION
See Also:   MetadataBuilder.COORDINATE_REFERENCE_SYSTEM



FALSE_EASTING
final public static Key FALSE_EASTING(Code)
Key for the "false_easting" projection parameter. There is no specific method for this key. However, this key may be queried indirectly by MetadataBuilder.getProjection .
See Also:   MetadataBuilder.SEMI_MAJOR
See Also:   MetadataBuilder.SEMI_MINOR
See Also:   MetadataBuilder.LATITUDE_OF_ORIGIN
See Also:   MetadataBuilder.CENTRAL_MERIDIAN
See Also:   MetadataBuilder.FALSE_NORTHING
See Also:   MetadataBuilder.PROJECTION



FALSE_NORTHING
final public static Key FALSE_NORTHING(Code)
Key for the "false_northing" projection parameter. There is no specific method for this key. However, this key may be queried indirectly by MetadataBuilder.getProjection .
See Also:   MetadataBuilder.SEMI_MAJOR
See Also:   MetadataBuilder.SEMI_MINOR
See Also:   MetadataBuilder.LATITUDE_OF_ORIGIN
See Also:   MetadataBuilder.CENTRAL_MERIDIAN
See Also:   MetadataBuilder.FALSE_EASTING
See Also:   MetadataBuilder.PROJECTION



HEIGHT
final public static Key HEIGHT(Code)
Key for the image's height in pixels. The MetadataBuilder.getGridRange method looks for this metadata in order to infer the along the dimension 1.
See Also:   MetadataBuilder.WIDTH
See Also:   MetadataBuilder.X_RESOLUTION
See Also:   MetadataBuilder.Y_RESOLUTION



LATITUDE_OF_ORIGIN
final public static Key LATITUDE_OF_ORIGIN(Code)
Key for the "latitude_of_origin" projection parameter. There is no specific method for this key. However, this key may be queried indirectly by MetadataBuilder.getProjection .
See Also:   MetadataBuilder.SEMI_MAJOR
See Also:   MetadataBuilder.SEMI_MINOR
See Also:   MetadataBuilder.CENTRAL_MERIDIAN
See Also:   MetadataBuilder.FALSE_EASTING
See Also:   MetadataBuilder.FALSE_NORTHING
See Also:   MetadataBuilder.PROJECTION



OPERATION_METHOD
final public static Key OPERATION_METHOD(Code)
Key for the . The MetadataBuilder.getProjection method looks for this metadata. The operation method name determines the . This name is the projection classification.

If this metadata is not defined, then the operation name is inferred from the .
See Also:   MetadataBuilder.PROJECTION
See Also:   MetadataBuilder.COORDINATE_REFERENCE_SYSTEM




PROJECTION
final public static Key PROJECTION(Code)
Key for the . The MetadataBuilder.getProjection method looks for this metadata. If the metadata is not defined, then the projection name is assumed the same than the name.
See Also:   MetadataBuilder.SEMI_MAJOR
See Also:   MetadataBuilder.SEMI_MINOR
See Also:   MetadataBuilder.LATITUDE_OF_ORIGIN
See Also:   MetadataBuilder.CENTRAL_MERIDIAN
See Also:   MetadataBuilder.FALSE_EASTING
See Also:   MetadataBuilder.FALSE_NORTHING



SEMI_MAJOR
final public static Key SEMI_MAJOR(Code)
Key for the "semi_major" projection parameter. There is no specific method for this key. However, this key may be queried indirectly by MetadataBuilder.getProjection .
See Also:   MetadataBuilder.SEMI_MINOR
See Also:   MetadataBuilder.LATITUDE_OF_ORIGIN
See Also:   MetadataBuilder.CENTRAL_MERIDIAN
See Also:   MetadataBuilder.FALSE_EASTING
See Also:   MetadataBuilder.FALSE_NORTHING
See Also:   MetadataBuilder.PROJECTION



SEMI_MINOR
final public static Key SEMI_MINOR(Code)
Key for the "semi_minor" projection parameter. There is no specific method for this key. However, this key may be queried indirectly by MetadataBuilder.getProjection .
See Also:   MetadataBuilder.SEMI_MAJOR
See Also:   MetadataBuilder.LATITUDE_OF_ORIGIN
See Also:   MetadataBuilder.CENTRAL_MERIDIAN
See Also:   MetadataBuilder.FALSE_EASTING
See Also:   MetadataBuilder.FALSE_NORTHING
See Also:   MetadataBuilder.PROJECTION



UNITS
final public static Key UNITS(Code)
Key for the units. The MetadataBuilder.getUnit method looks for this metadata. The following heuristic rule may be applied in order to infer the CRS from the units:

  • If the unit is compatible with , then a is assumed.
  • Otherwise, if this unit is compatible with , then a is assumed.

See Also:   MetadataBuilder.ELLIPSOID
See Also:   MetadataBuilder.DATUM
See Also:   MetadataBuilder.PROJECTION
See Also:   MetadataBuilder.COORDINATE_REFERENCE_SYSTEM



WIDTH
final public static Key WIDTH(Code)
Key for the image's width in pixels. The MetadataBuilder.getGridRange method looks for this metadata in order to infer the along the dimension 0.
See Also:   MetadataBuilder.HEIGHT
See Also:   MetadataBuilder.X_RESOLUTION
See Also:   MetadataBuilder.Y_RESOLUTION



X_MAXIMUM
final public static Key X_MAXIMUM(Code)
Key for the maximal x value (eastern limit). This is usually the longitude coordinate of the bottom right corner. The MetadataBuilder.getEnvelope method looks for this metadata in order to set the for dimension 0.
See Also:   MetadataBuilder.X_MINIMUM
See Also:   MetadataBuilder.Y_MINIMUM
See Also:   MetadataBuilder.Y_MAXIMUM
See Also:   MetadataBuilder.X_RESOLUTION
See Also:   MetadataBuilder.Y_RESOLUTION



X_MINIMUM
final public static Key X_MINIMUM(Code)
Key for the minimal x value (western limit). This is usually the longitude coordinate of the upper left corner. The MetadataBuilder.getEnvelope method looks for this metadata in order to set the for dimension 0.
See Also:   MetadataBuilder.X_MAXIMUM
See Also:   MetadataBuilder.Y_MINIMUM
See Also:   MetadataBuilder.Y_MAXIMUM
See Also:   MetadataBuilder.X_RESOLUTION
See Also:   MetadataBuilder.Y_RESOLUTION



X_RESOLUTION
final public static Key X_RESOLUTION(Code)
Key for the resolution among the x axis. The MetadataBuilder.getEnvelope method looks for this metadata in order to infer the coordinates for dimension 0.
See Also:   MetadataBuilder.X_MINIMUM
See Also:   MetadataBuilder.X_MAXIMUM
See Also:   MetadataBuilder.Y_MINIMUM
See Also:   MetadataBuilder.Y_MAXIMUM
See Also:   MetadataBuilder.Y_RESOLUTION



Y_MAXIMUM
final public static Key Y_MAXIMUM(Code)
Key for the maximal y value (northern limit). This is usually the latitude coordinate of the upper left corner. The MetadataBuilder.getEnvelope method looks for this metadata in order to set the for dimension 1.
See Also:   MetadataBuilder.X_MINIMUM
See Also:   MetadataBuilder.X_MAXIMUM
See Also:   MetadataBuilder.Y_MINIMUM
See Also:   MetadataBuilder.X_RESOLUTION
See Also:   MetadataBuilder.Y_RESOLUTION



Y_MINIMUM
final public static Key Y_MINIMUM(Code)
Key for the minimal y value (southern limit). This is usually the latitude coordinate of the bottom right corner. The MetadataBuilder.getEnvelope method looks for this metadata. in order to set the for dimension 1.
See Also:   MetadataBuilder.X_MINIMUM
See Also:   MetadataBuilder.X_MAXIMUM
See Also:   MetadataBuilder.Y_MAXIMUM
See Also:   MetadataBuilder.X_RESOLUTION
See Also:   MetadataBuilder.Y_RESOLUTION



Y_RESOLUTION
final public static Key Y_RESOLUTION(Code)
Key for the resolution among the y axis. The MetadataBuilder.getEnvelope method looks for this metadata in order to infer the coordinates for dimension 1.
See Also:   MetadataBuilder.X_MINIMUM
See Also:   MetadataBuilder.X_MAXIMUM
See Also:   MetadataBuilder.Y_MINIMUM
See Also:   MetadataBuilder.Y_MAXIMUM
See Also:   MetadataBuilder.X_RESOLUTION
See Also:   MetadataBuilder.WIDTH
See Also:   MetadataBuilder.HEIGHT



Z_MAXIMUM
final public static Key Z_MAXIMUM(Code)
Key for the maximal z value. This is usually the maximal altitude. The MetadataBuilder.getEnvelope method looks for this metadata in order to set the for dimension 2.
See Also:   MetadataBuilder.Z_MINIMUM
See Also:   MetadataBuilder.Z_RESOLUTION
See Also:   MetadataBuilder.DEPTH



Z_MINIMUM
final public static Key Z_MINIMUM(Code)
Key for the minimal z value. This is usually the minimal altitude. The MetadataBuilder.getEnvelope method looks for this metadata in order to set the for dimension 2.
See Also:   MetadataBuilder.Z_MAXIMUM
See Also:   MetadataBuilder.Z_RESOLUTION
See Also:   MetadataBuilder.DEPTH



Z_RESOLUTION
final public static Key Z_RESOLUTION(Code)
Key for the resolution among the z axis. The MetadataBuilder.getEnvelope method looks for this metadata in order to infer the coordinates for dimension 2.
See Also:   MetadataBuilder.Z_MINIMUM
See Also:   MetadataBuilder.Z_MAXIMUM
See Also:   MetadataBuilder.DEPTH




Constructor Detail
MetadataBuilder
public MetadataBuilder()(Code)
Constructs a new MetadataBuilder using default factories.



MetadataBuilder
public MetadataBuilder(FactoryGroup factories)(Code)
Constructs a new MetadataBuilder using the specified factories.




Method Detail
add
public synchronized void add(GridCoverage coverage) throws AmbiguousMetadataException(Code)
Add all metadata from the specified grid coverage. This method can be used together with MetadataBuilder.listMetadata as a way to format the metadata for an arbitrary grid coverage. The default implementation performs the following step:




add
public synchronized void add(RenderedImage image) throws AmbiguousMetadataException(Code)
Add all metadata from the specified image.
Parameters:
  image - The image with metadata to add to this MetadataBuilder .
throws:
  AmbiguousMetadataException - if a metadata is defined twice.
See Also:   MetadataBuilder.add(GridCoverage)
See Also:   MetadataBuilder.add(PropertySource,String)
See Also:   MetadataBuilder.add(String,Object)



add
public synchronized void add(PropertySource properties, String prefix) throws AmbiguousMetadataException(Code)
Add metadata from the specified property source.
Parameters:
  properties - The properties source.
Parameters:
  prefix - The prefix for properties to add, of null to addall properties. If non-null, only properties begining with this prefixwill be added.
throws:
  AmbiguousMetadataException - if a metadata is defined twice.
See Also:   MetadataBuilder.add(GridCoverage)
See Also:   MetadataBuilder.add(RenderedImage)
See Also:   MetadataBuilder.add(String,Object)



add
public synchronized void add(String alias, Object value) throws AmbiguousMetadataException(Code)
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 thefile to be parsed (this is different from Key objects, which are keysin a format neutral way). This key is usually, but not always, one of the aliasdefined with MetadataBuilder.addAlias.
Parameters:
  value - The value for the metadata to add. If null orImage.UndefinedProperty, then this method do nothing.
throws:
  AmbiguousMetadataException - if a different value already exists for the specifiedalias, or for an other alias bound to the same Key.
See Also:   MetadataBuilder.add(GridCoverage)
See Also:   MetadataBuilder.add(RenderedImage)
See Also:   MetadataBuilder.add(PropertySource,String)
See Also:   MetadataBuilder.parseLine



addAlias
public synchronized void addAlias(Key key, String alias) throws AmbiguousMetadataException(Code)
Add an alias to a key. After this method has been invoked, calls to MetadataBuilder.get 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 MetadataBuilder.getEnvelope method will not work unless the following alias are set:

 addAlias(
 , "ULX");
 addAlias(
 , "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(
 , "Resolution");
 addAlias(
 , "Resolution");
 

Parameters:
  key - The key to add an alias. This key is format neutral.
Parameters:
  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. Ifthis alias is already bound to the specified key, then this method do nothing.
throws:
  AmbiguousMetadataException - if the addition of the supplied aliaswould 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:   MetadataBuilder.getAlias
See Also:   MetadataBuilder.contains
See Also:   MetadataBuilder.get



clear
public synchronized void clear()(Code)
Clears this metadata set. If the same MetadataBuilder 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 MetadataBuilder can been immediately reused for parsing new files of the same kind.



contains
public synchronized boolean contains(Key key)(Code)
Checks if this MetadataBuilder contains a value for the specified key. Invoking MetadataBuilder.get will thrown a MissingMetadataException if and only if MetadataBuilder.contains returns false for the same key.
Parameters:
  key - The key to test for inclusion in this MetadataBuilder . true if the given key was found.
See Also:   MetadataBuilder.get
See Also:   MetadataBuilder.addAlias



get
public synchronized Object get(Key key) throws MissingMetadataException(Code)
Returns the metadata for the specified key. This method expect a format neutral, case insensitive Key argument. In order to maps the key to the actual name used in the underlying metadata file, the method MetadataBuilder.addAlias must have been invoked prior to any get method.
Parameters:
  key - The key of the desired metadata. Keys are case insensitive and format neutral. Value for the specified key (never null ).
throws:
  MissingMetadataException - if no value exists for the specified key.
See Also:   MetadataBuilder.getAsDouble
See Also:   MetadataBuilder.getAsInt
See Also:   MetadataBuilder.contains
See Also:   MetadataBuilder.addAlias



getAlias
public synchronized String[] getAlias(Key key)(Code)
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. The alias for the specified key, or null if none.
See Also:   MetadataBuilder.addAlias



getAsDate
public synchronized Date getAsDate(Key key) throws MetadataException(Code)
Returns a metadata as a Date value. The default implementation invokes MetadataBuilder.get get (key) and parse the resulting value with DateFormat.parse(String) for the .
Parameters:
  key - The key of the desired metadata. Keys are case-insensitive. Value for the specified key as a Date.
throws:
  MissingMetadataException - if no value exists for the specified key.
throws:
  MetadataException - if the value can't be parsed as a date.



getAsDouble
public synchronized double getAsDouble(Key key) throws MetadataException(Code)
Returns a metadata as a double value. The default implementation invokes MetadataBuilder.get get (key) and parse the resulting value with NumberFormat.parse(String) for the .
Parameters:
  key - The key of the desired metadata. Keys are case-insensitive. Value for the specified key as a double .
throws:
  MissingMetadataException - if no value exists for the specified key.
throws:
  MetadataException - if the value can't be parsed as a double .
See Also:   MetadataBuilder.getAsInt
See Also:   MetadataBuilder.get
See Also:   MetadataBuilder.contains
See Also:   MetadataBuilder.addAlias



getAsInt
public synchronized int getAsInt(Key key) throws MetadataException(Code)
Returns a metadata as a int value. The default implementation invokes MetadataBuilder.getAsDouble getAsDouble (key) and make sure that the resulting value is an integer.
Parameters:
  key - The key of the desired metadata. Keys are case-insensitive. Value for the specified key as an int .
throws:
  MissingMetadataException - if no value exists for the specified key.
throws:
  MetadataException - if the value can't be parsed as an int .
See Also:   MetadataBuilder.getAsDouble
See Also:   MetadataBuilder.get
See Also:   MetadataBuilder.contains
See Also:   MetadataBuilder.addAlias



getCoordinateReferenceSystem
public synchronized CoordinateReferenceSystem getCoordinateReferenceSystem() throws MetadataException(Code)
Returns the coordinate reference system. The default implementation constructs a CRS from the information provided by MetadataBuilder.getUnit , MetadataBuilder.getGeodeticDatum and MetadataBuilder.getProjection . The coordinate system name (optional) will be fetch from metadata MetadataBuilder.COORDINATE_REFERENCE_SYSTEM , if presents as a string.
throws:
  MissingMetadataException - if a required value is missing(e.g. MetadataBuilder.PROJECTION, MetadataBuilder.DATUM, MetadataBuilder.UNITS, etc.).
throws:
  MetadataException - if the operation failed for some other reason.
See Also:   MetadataBuilder.getUnit
See Also:   MetadataBuilder.getGeodeticDatum
See Also:   MetadataBuilder.getProjection



getEllipsoid
public synchronized Ellipsoid getEllipsoid() throws MetadataException(Code)
Returns the ellipsoid. The default implementation invokes ( ) and transform the resulting string into an Ellipsoid object.
throws:
  MissingMetadataException - if no value exists for the MetadataBuilder.ELLIPSOID key.
throws:
  MetadataException - if the operation failed for some other reason.
See Also:   MetadataBuilder.getCoordinateReferenceSystem
See Also:   MetadataBuilder.getGeodeticDatum



getEnvelope
public synchronized Envelope getEnvelope() throws MetadataException(Code)
Returns the envelope. The default implementation constructs an envelope using the values from the following keys:
throws:
  MissingMetadataException - if a required value is missing.
throws:
  MetadataException - if the operation failed for some other reason.
See Also:   MetadataBuilder.getGridRange
See Also:   MetadataBuilder.getGeographicBoundingBox



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

  • if type is assignable to Number.class , then this method returns the number pattern as specified by DecimalFormat .
  • Otherwise, if type is assignable to Date.class , then this method returns the date pattern as specified by SimpleDateFormat .

In any case, this method returns null if this object should use the default pattern for the .
Parameters:
  type - The data type ( Number.class or Date.class ). The format pattern for the specified data type, or null forthe default locale-dependent pattern.
throws:
  IllegalArgumentException - if type is not valid.




getGeodeticDatum
public synchronized GeodeticDatum getGeodeticDatum() throws MetadataException(Code)
Returns the geodetic datum. The default implementation invokes ( ) and transform the resulting string into a GeodeticDatum object.
throws:
  MissingMetadataException - if no value exists for the MetadataBuilder.DATUM key.
throws:
  MetadataException - if the operation failed for some other reason.
See Also:   MetadataBuilder.getCoordinateReferenceSystem
See Also:   MetadataBuilder.getEllipsoid



getGeographicBoundingBox
public synchronized GeographicBoundingBox getGeographicBoundingBox() throws MetadataException(Code)
Convenience method returning the envelope in geographic coordinate system using WGS 1984 datum.
throws:
  MetadataException - if the operation failed. This exceptionmay contains a TransformException as its cause.
See Also:   MetadataBuilder.getEnvelope
See Also:   MetadataBuilder.getGridRange



getGridRange
public synchronized GridRange getGridRange() throws MetadataException(Code)
Returns the grid range. Default implementation fetchs the metadata values for keys MetadataBuilder.WIDTH and MetadataBuilder.HEIGHT , and transform the resulting strings into a GridRange object.
throws:
  MissingMetadataException - if a required value is missing.
throws:
  MetadataException - if the operation failed for some other reason.
See Also:   MetadataBuilder.getEnvelope
See Also:   MetadataBuilder.getGeographicBoundingBox



getLocale
public Locale getLocale() throws MetadataException(Code)
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. The locale to use for parsing metadata values.
throws:
  MetadataException - if this information can't be fetched.
See Also:   MetadataBuilder.getAsDouble
See Also:   MetadataBuilder.getAsInt
See Also:   MetadataBuilder.getAsDate



getProjection
public synchronized Conversion getProjection() throws MetadataException(Code)
Returns the projection. The default implementation performs the following steps:

  • Gets the projection classification with ( ), or with ( ) if no value were defined for the former.
  • Gets the list of projection parameters for the above classification.
  • Gets the metadata values for each parameters in the above step. If a parameter is not defined in this MetadataBuilder , then it will be left to its (projection dependent) default value. Parameters are projection dependent, but will typically include "semi_major" , "semi_minor" , "central_meridian" , "latitude_of_origin" , "false_easting" and "false_northing" . The names actually used in the metadata file to be parsed must be declared as usual, e.g. ( , ...)
  • If no value was defined for "semi-major" and/or "semi-minor" parameters, then invokes MetadataBuilder.getEllipsoid and uses its semi-axis length.
  • If a value exists for the optional key MetadataBuilder.PROJECTION , then takes it as the projection name. The projection name is for documentation purpose only and do not affect any computation. If there is no value for MetadataBuilder.PROJECTION , then the projection name will be the same than the operation method name (the first step above).
The projection.
throws:
  MissingMetadataException - if no value exists for the MetadataBuilder.PROJECTION or theMetadataBuilder.OPERATION_METHOD keys.
throws:
  MetadataException - if the operation failed for some other reason(for example if a parameter value can't be parsed as a double ).
See Also:   MetadataBuilder.getCoordinateReferenceSystem
See Also:   MetadataBuilder.SEMI_MAJOR
See Also:   MetadataBuilder.SEMI_MINOR
See Also:   MetadataBuilder.LATITUDE_OF_ORIGIN
See Also:   MetadataBuilder.CENTRAL_MERIDIAN
See Also:   MetadataBuilder.FALSE_EASTING
See Also:   MetadataBuilder.FALSE_NORTHING



getSampleDimensions
public GridSampleDimension[] getSampleDimensions() throws MetadataException(Code)
Returns the sample dimensions for each band of the GridCoverage to be read. If sample dimensions are not know, then this method returns null . The default implementation always returns null .
throws:
  MetadataException - if the operation failed.



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



getSource
public String getSource() throws MetadataException(Code)
Returns the source file name or URL. This is the path specified during the last call to a load(...) method. The source file name or URL.
throws:
  MetadataException - if this information can't be fetched. #load(File) #load(URL)



getUnit
public synchronized Unit getUnit() throws MetadataException(Code)
Returns the units. The default implementation invokes ( ) and transform the resulting string into an Unit object.
throws:
  MissingMetadataException - if no value exists for the MetadataBuilder.UNITS key.
throws:
  MetadataException - if the operation failed for some other reason.
See Also:   MetadataBuilder.getCoordinateReferenceSystem



listMetadata
public synchronized void listMetadata(Writer out) throws IOException(Code)
List all metadata to the specified stream. The default implementation list the metadata as key = value pairs. Each pair is formatted on its own line, and the caracter '=' is inserted between keys and values. A question mark ('?') is put in front of any unknow name (i.e. any name not specified with MetadataBuilder.addAlias ).
Parameters:
  out - Stream to write metadata to.
throws:
  IOException - if an error occured while listing metadata.
See Also:   MetadataBuilder.add(GridCoverage)
See Also:   MetadataBuilder.toString()



load
public synchronized void load(File header) throws IOException(Code)
Reads all metadata from a text file. The default implementation invokes MetadataBuilder.load(BufferedReader) . Note that this method do not invokes MetadataBuilder.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:
  IOException - if an error occurs during loading.
See Also:   MetadataBuilder.clear()
See Also:   MetadataBuilder.load(URL)
See Also:   MetadataBuilder.parseLine
See Also:   MetadataBuilder.getSource



load
public synchronized void load(URL header) throws IOException(Code)
Reads all metadata from an URL. The default implementation invokes MetadataBuilder.load(BufferedReader) . Note that this method do not invokes MetadataBuilder.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:
  IOException - if an error occurs during loading.
See Also:   MetadataBuilder.clear()
See Also:   MetadataBuilder.load(File)
See Also:   MetadataBuilder.parseLine
See Also:   MetadataBuilder.getSource



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

  • This method is not public because it has no way to know how to set the MetadataBuilder.getSource source metadata.
  • This method is not synchronized. Synchronization, if wanted, must be done from the public frontend.
  • This method do not invokes MetadataBuilder.clear prior the loading.

Parameters:
  in - The stream to read until EOF. The stream will not be closed.
throws:
  IOException - if an error occurs during loading.
See Also:   MetadataBuilder.clear()
See Also:   MetadataBuilder.load(File)
See Also:   MetadataBuilder.load(URL)
See Also:   MetadataBuilder.parseLine



parseLine
protected boolean parseLine(String line) throws IIOException(Code)
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 (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:
MetadataBuilder.add(String,Object) 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 MetadataBuilder.add ), 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 MetadataBuilder has been subclassed) until someone consume it.
Parameters:
  line - The line to parse. true if this method has consumed the line.
throws:
  IIOException - if the line is badly formatted.
throws:
  AmbiguousMetadataException - if a different value was already defined for the samemetadata name.
See Also:   MetadataBuilder.load(File)
See Also:   MetadataBuilder.load(URL)
See Also:   MetadataBuilder.add(String,Object)



setFormatPattern
public synchronized void setFormatPattern(Class type, String pattern)(Code)
Set the pattern to use for parsing and formatting values of the specified type. The type should be either Number.class or Date.class .
  • If type is assignable to .class, then pattern should be a DecimalFormat pattern (example: "#0.###" ).
  • If type is assignable to .class, then pattern should be a SimpleDateFormat pattern (example: "yyyy/MM/dd HH:mm" ).

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



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



setUserLocale
final synchronized void setUserLocale(Locale locale)(Code)
Sets the current Locale of this MetadataBuilder to the given value. A value of null removes any previous setting, and indicates that the parser should localize as it sees fit.

Note: this is the locale to use for formatting error messages, not the locale to use for parsing the file. The locale for parsing is specified by MetadataBuilder.getLocale .




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



trim
static String trim(String str, String separator)(Code)
Trim a character string. Leading and trailing spaces are removed. Any succession of one ore more unicode whitespace characters (as of Character.isSpaceChar(char) are replaced by a single '_' character. Example:
"This   is a   test"
will be returned as
"This_is_a_test"

Parameters:
  str - The string to trim (may be null ).
Parameters:
  separator - The separator to insert in place of succession of whitespaces.Usually "_" for keys and " " for values. The trimed string, or null if str was null.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.