Java Doc for MetadataAccessor.java in  » GIS » GeoTools-2.4.1 » org » geotools » image » io » metadata » 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.image.io.metadata 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.geotools.image.io.metadata.MetadataAccessor

All known Subclasses:   org.geotools.image.io.metadata.ImageGeometry,  org.geotools.image.io.metadata.ImageReferencing,  org.geotools.image.io.metadata.Band,  org.geotools.image.io.metadata.Axis,  org.geotools.image.io.metadata.ChildList,
MetadataAccessor
public class MetadataAccessor (Code)
Base class for parsers. This class provides convenience methods for encoding and decoding metadata information. A metadata root is specified at construction time, together with a path to the of interest. Example of valid paths:

  • "CoordinateReferenceSystem/Datum"
  • "CoordinateReferenceSystem/CoordinateSystem"
  • "GridGeometry/Envelope"

In addition, some elements contains an arbitrary amount of childs. The path to child elements can also be specified to the constructor. Examples (note that the constructor expects paths relative to the parent; we show absolute paths below for completness):

  • "CoordinateReferenceSystem/CoordinateSystem/Axis"
  • "GridGeometry/Envelope/CoordinateValues"
  • "SampleDimensions/SampleDimension"
The get and set methods defined in this class will operate on the selected , which may be either the one specified at construction time, or one of its childs. The element can be selected by MetadataAccessor.selectParent (the default) or MetadataAccessor.selectChild .

The example below creates an accessor for a node called "CoordinateSystem" which is expected to have childs called "Axis" :

 MetadataAccessor accessor = new MetadataAccessor(metadata,
 "CoordinateReferenceSystem/CoordinateSystem", "Axis");
 accessor.selectParent();
 String csName = accessor.getString("name");
 accessor.selectChild(0);
 String firstAxisName = accessor.getString("name");
 

since:
   2.4
version:
   $Id: MetadataAccessor.java 27583 2007-10-23 11:29:26Z desruisseaux $
author:
   Martin Desruisseaux



Constructor Summary
protected  MetadataAccessor(MetadataAccessor clone)
     Creates an accessor with the same parent and childs than the specified one.
protected  MetadataAccessor(GeographicMetadata metadata, String parentPath, String childPath)
     Creates an accessor for the at the given path.

Method Summary
protected  intappendChild()
     Adds a new child at the path given at construction time. The will be increased by 1.

The new child is not automatically selected.

protected  intchildCount()
     Returns the number of child .
protected  DategetDate(String attribute)
     Returns an attribute as a date for the , or null if none.
protected  DoublegetDouble(String attribute)
     Returns an attribute as a floating point for the , or null if none.
protected  double[]getDoubles(String attribute, boolean unique)
     Returns an attribute as an array of floating point for the , or null if none.
protected  IntegergetInteger(String attribute)
     Returns an attribute as an integer for the , or null if none.
protected  int[]getIntegers(String attribute, boolean unique)
     Returns an attribute as an array of integers for the , or null if none.
protected  StringgetString(String attribute)
     Returns an attribute as a string for the , or null if none.
protected  ObjectgetUserObject()
     Returns the associated with the , or null if none.
protected  ObjectgetUserObject(Class type)
     Returns the user object associated as an instance of the specified class.
protected  voidselectChild(int index)
     Selects the at the given index.
protected  voidselectParent()
     Selects the parent of child elements.
protected  voidsetDate(String attribute, Date value)
     Set the attribute to the specified value, or remove the attribute if the value is null.
protected  voidsetDouble(String attribute, double value)
     Set the attribute to the specified floating point value, or remove the attribute if the value is NaN.
protected  voidsetDoubles(String attribute, double[] values)
     Set the attribute to the specified array of values, or remove the attribute if the array is null .
final  voidsetEnum(String attribute, String value, Collection enums)
     Set the attribute to the specified enumeration value, or remove the attribute if the value is null.
protected  voidsetInteger(String attribute, int value)
     Set the attribute to the specified integer value.
protected  voidsetIntegers(String attribute, int[] values)
     Set the attribute to the specified array of values, or remove the attribute if the array is null .
protected  voidsetString(String attribute, String value)
     Set the attribute to the specified value, or remove the attribute if the value is null.

Every set methods in this class except MetadataAccessor.setUserObject setUserObject invoke this method last.

protected  voidsetUserObject(Object value)
     Sets the associated with the .
protected  booleansetWarningsEnabled(boolean enabled)
     Enables or disables the warnings.
public  StringtoString()
     Returns a string representation of metadata, mostly for debugging purpose.
public static  StringtrimFractionalPart(String value)
     Trims the factional part of the given string, provided that it doesn't change the value. More specifically, this method removes the trailing ".0" characters if any.
final  voidwarning(String method, int key, Object value)
     Convenience method for logging a warning.
protected  voidwarningOccurred(LogRecord record)
     Invoked when a warning occured.


Constructor Detail
MetadataAccessor
protected MetadataAccessor(MetadataAccessor clone)(Code)
Creates an accessor with the same parent and childs than the specified one. The two accessors will share the same (including the list of childs), so change in one accessor will be immediately reflected in the other accessor. However each accessor can independently.

The main purpose of this constructor is to create many views over the same list of childs, where each view a different child.




MetadataAccessor
protected MetadataAccessor(GeographicMetadata metadata, String parentPath, String childPath)(Code)
Creates an accessor for the at the given path. Paths are separated by the '/' character. See for path examples.
Parameters:
  metadata - The metadata node.
Parameters:
  parentPath - The path to the of interest, or null if the metadata root node is directly the node of interest.
Parameters:
  childPath - The path (relative to parentPath ) to the child, or null if none.




Method Detail
appendChild
protected int appendChild()(Code)
Adds a new child at the path given at construction time. The will be increased by 1.

The new child is not automatically selected. In order to select this new child, the MetadataAccessor.selectChild method must be invoked explicitly. The index of the new child element.
See Also:   MetadataAccessor.childCount
See Also:   MetadataAccessor.selectChild




childCount
protected int childCount()(Code)
Returns the number of child . This is the upper value (exclusive) for MetadataAccessor.selectChild . The child count.
See Also:   MetadataAccessor.selectChild
See Also:   MetadataAccessor.appendChild



getDate
protected Date getDate(String attribute)(Code)
Returns an attribute as a date for the , or null if none. If the attribute can't be parsed as a date, then this method logs a warning and returns null .
Parameters:
  attribute - The attribute to fetch (e.g. "origin" ). The attribute value, or null if none or unparseable.



getDouble
protected Double getDouble(String attribute)(Code)
Returns an attribute as a floating point for the , or null if none. If the attribute can't be parsed as a floating point, then this method logs a warning and returns null .
Parameters:
  attribute - The attribute to fetch (e.g. "minimum" ). The attribute value, or null if none or unparseable.



getDoubles
protected double[] getDoubles(String attribute, boolean unique)(Code)
Returns an attribute as an array of floating point for the , or null if none. If an element can't be parsed as a floating point, then this method logs a warning and returns null .
Parameters:
  attribute - The attribute to fetch (e.g. "fillValues" ).
Parameters:
  unique - true if duplicated values should be collapsed into unique values,or false for preserving duplicated values. The attribute values, or null if none.



getInteger
protected Integer getInteger(String attribute)(Code)
Returns an attribute as an integer for the , or null if none. If the attribute can't be parsed as an integer, then this method logs a warning and returns null .
Parameters:
  attribute - The attribute to fetch (e.g. "minimum" ). The attribute value, or null if none or unparseable.



getIntegers
protected int[] getIntegers(String attribute, boolean unique)(Code)
Returns an attribute as an array of integers for the , or null if none. If an element can't be parsed as an integer, then this method logs a warning and returns null .
Parameters:
  attribute - The attribute to fetch (e.g. "minimum" ).
Parameters:
  unique - true if duplicated values should be collapsed into unique values,or false for preserving duplicated values. The attribute values, or null if none.



getString
protected String getString(String attribute)(Code)
Returns an attribute as a string for the , or null if none. This method never returns an empty string.

Every get methods in this class except MetadataAccessor.getUserObject getUserObject invoke this method first. Consequently, this method provides a single point for overriding if subclasses want to process the attribute before parsing.
Parameters:
  attribute - The attribute to fetch (e.g. "name" ). The attribute value (never an empty string), or null if none.




getUserObject
protected Object getUserObject()(Code)
Returns the associated with the , or null if none. If no user object is defined for the element, then the is returned as a fallback. This is consistent with MetadataAccessor.setUserObject implementation, and allows some parsing of nodes that are not IIOMetadataNode instances.

The getUserObject methods are the only ones to not parse the value returned by MetadataAccessor.getString . The user object, or null if none.
See Also:   MetadataAccessor.getUserObject(Class)
See Also:   MetadataAccessor.setUserObject




getUserObject
protected Object getUserObject(Class type) throws ClassCastException(Code)
Returns the user object associated as an instance of the specified class. If the value returned by MetadataAccessor.getUserObject() is not of the expected type, then this method will tries to parse it as a string.
Parameters:
  type - The expected class. The user object, or null if none.
throws:
  ClassCastException - if the user object can not be casted to the specified type.
See Also:   MetadataAccessor.getUserObject()
See Also:   MetadataAccessor.setUserObject



selectChild
protected void selectChild(int index) throws IndexOutOfBoundsException(Code)
Selects the at the given index. Every subsequent calls to get or set methods will apply to this selected child element.
Parameters:
  index - The index of the element to select.
throws:
  IndexOutOfBoundsException - if the specified index is out of bounds.
See Also:   MetadataAccessor.childCount
See Also:   MetadataAccessor.appendChild
See Also:   MetadataAccessor.selectParent



selectParent
protected void selectParent() throws NoSuchElementException(Code)
Selects the parent of child elements. Every subsequent calls to get or set methods will apply to this parent element.
throws:
  NoSuchElementException - if there is no parent .
See Also:   MetadataAccessor.selectChild



setDate
protected void setDate(String attribute, Date value)(Code)
Set the attribute to the specified value, or remove the attribute if the value is null.
Parameters:
  attribute - The attribute name.
Parameters:
  value - The attribute value.



setDouble
protected void setDouble(String attribute, double value)(Code)
Set the attribute to the specified floating point value, or remove the attribute if the value is NaN.
Parameters:
  attribute - The attribute name.
Parameters:
  value - The attribute value.



setDoubles
protected void setDoubles(String attribute, double[] values)(Code)
Set the attribute to the specified array of values, or remove the attribute if the array is null .
Parameters:
  attribute - The attribute name.
Parameters:
  value - The attribute value.



setEnum
final void setEnum(String attribute, String value, Collection enums)(Code)
Set the attribute to the specified enumeration value, or remove the attribute if the value is null.
Parameters:
  attribute - The attribute name.
Parameters:
  value - The attribute value.
Parameters:
  enums - The set of allowed values, or null if unknown.



setInteger
protected void setInteger(String attribute, int value)(Code)
Set the attribute to the specified integer value.
Parameters:
  attribute - The attribute name.
Parameters:
  value - The attribute value.



setIntegers
protected void setIntegers(String attribute, int[] values)(Code)
Set the attribute to the specified array of values, or remove the attribute if the array is null .
Parameters:
  attribute - The attribute name.
Parameters:
  value - The attribute value.



setString
protected void setString(String attribute, String value)(Code)
Set the attribute to the specified value, or remove the attribute if the value is null.

Every set methods in this class except MetadataAccessor.setUserObject setUserObject invoke this method last. Consequently, this method provides a single point for overriding if subclasses want to process the attribute after formatting.
Parameters:
  attribute - The attribute name.
Parameters:
  value - The attribute value.




setUserObject
protected void setUserObject(Object value) throws UnsupportedImplementationException(Code)
Sets the associated with the . This is the only set method that doesn't invoke MetadataAccessor.setString with a formatted value.

If the specified value is formattable (i.e. is a , a or an array of the above), then this method also as a string. This is mostly a convenience for formatting purpose since IIOMetadataNode don't use the node value. But it may help some libraries that are not designed to work with with user objects, since they are particular to Image I/O metadata.
Parameters:
  value - The user object, or null if none.
throws:
  UnsupportedImplementationException - if the selected element is not an instance ofIIOMetadataNode.
See Also:   MetadataAccessor.getUserObject()




setWarningsEnabled
protected boolean setWarningsEnabled(boolean enabled)(Code)
Enables or disables the warnings. Warnings are enabled by default. Subclasses way want to temporarily disable the warnings when failures are expected as the normal behavior. For example a subclass may invokes MetadataAccessor.getInteger and fallbacks on MetadataAccessor.getDouble if the former failed. In such case, the warnings should be disabled for the integer parsing, but not for the floating point parsing.
Parameters:
  enabled - true for enabling warnings, or false for disabling. The previous state before this method has been invoked.



toString
public String toString()(Code)
Returns a string representation of metadata, mostly for debugging purpose.



trimFractionalPart
public static String trimFractionalPart(String value)(Code)
Trims the factional part of the given string, provided that it doesn't change the value. More specifically, this method removes the trailing ".0" characters if any. This method is automatically invoked before to or to (for simplifying fractional seconds).
Parameters:
  value - The value to trim. The value without the trailing ".0" part.



warning
final void warning(String method, int key, Object value)(Code)
Convenience method for logging a warning. Do not allow overriding, because it would not work for warnings emitted by the MetadataAccessor.getDate method.



warningOccurred
protected void warningOccurred(LogRecord record)(Code)
Invoked when a warning occured. This method is invoked when some inconsistency has been detected in the geographic metadata. The default implementation delegates to GeographicMetadata.warningOccurred .



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.