org.geotools.metadata
Class AbstractMetadata

java.lang.Object
  extended by org.geotools.metadata.AbstractMetadata
Direct Known Subclasses:
ModifiableMetadata

public abstract class AbstractMetadata
extends java.lang.Object

Base class for metadata implementations. Subclasses must implement the interfaces of some metadata standard. This class uses Java reflection in order to provide default implementation of copy constructor, equals(java.lang.Object) and hashCode methods.

Since:
2.4
Version:
$Id: AbstractMetadata.java 30640 2008-06-12 17:34:32Z acuster $
Author:
Martin Desruisseaux (Geomatys)

Field Summary
protected static java.util.logging.Logger LOGGER
          The logger for metadata implementation.
 
Constructor Summary
protected AbstractMetadata()
          Creates an initially empty metadata.
protected AbstractMetadata(java.lang.Object source)
          Constructs a metadata entity initialized with the values from the specified metadata.
 
Method Summary
 java.util.Map<java.lang.String,java.lang.Object> asMap()
          Returns a view of this metadata object as a map.
 javax.swing.tree.TreeModel asTree()
          Returns a view of this metadata as a tree.
 boolean equals(java.lang.Object object)
          Compares this metadata with the specified object for equality.
 java.lang.Class<?> getInterface()
          Returns the metadata interface implemented by this class.
abstract  MetadataStandard getStandard()
          Returns the metadata standard implemented by subclasses.
 int hashCode()
          Computes a hash code value for this metadata using Java reflection.
 java.lang.String toString()
          Returns a string representation of this metadata.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

LOGGER

protected static final java.util.logging.Logger LOGGER
The logger for metadata implementation.

Constructor Detail

AbstractMetadata

protected AbstractMetadata()
Creates an initially empty metadata.


AbstractMetadata

protected AbstractMetadata(java.lang.Object source)
                    throws java.lang.ClassCastException,
                           UnmodifiableMetadataException
Constructs a metadata entity initialized with the values from the specified metadata. The source metadata must implements the same metadata interface (defined by the standard) than this class, but don't need to be the same implementation class. The copy is performed using Java reflections.

Parameters:
source - The metadata to copy values from.
Throws:
java.lang.ClassCastException - if the specified metadata don't implements the expected metadata interface.
UnmodifiableMetadataException - if this class don't define set methods corresponding to the get methods found in the implemented interface, or if this instance is not modifiable for some other reason.
Method Detail

getStandard

public abstract MetadataStandard getStandard()
Returns the metadata standard implemented by subclasses.

Returns:
The metadata standard implemented.

getInterface

public java.lang.Class<?> getInterface()
Returns the metadata interface implemented by this class. It should be one of the interfaces defined in the metadata standard implemented by this class.

Returns:
The standard interface implemented by this implementation class.

asMap

public java.util.Map<java.lang.String,java.lang.Object> asMap()
Returns a view of this metadata object as a map. The map is backed by this metadata object using Java reflection, so changes in the underlying metadata object are immediately reflected in the map. The keys are the property names as determined by the list of get*() methods declared in the metadata interface.

The map supports the put operations if the underlying metadata object contains #set*(...) methods.

Returns:
A view of this metadata object as a map.

asTree

public javax.swing.tree.TreeModel asTree()
Returns a view of this metadata as a tree. Note that while TreeModel is defined in the javax.swing.tree package, it can be seen as a data structure independent of Swing. It will not force class loading of Swing framework.

In current implementation, the tree is not live (i.e. changes in metadata are not reflected in the tree). However it may be improved in a future Geotools implementation.

Returns:
A view of this metadata object as a tree.

equals

public boolean equals(java.lang.Object object)
Compares this metadata with the specified object for equality. The default implementation uses Java reflection. Subclasses may override this method for better performances.

This method performs a deep comparaison (i.e. if this metadata contains other metadata, the comparaison will walk through the other metadata content as well) providing that every childs implement the Object.equals(java.lang.Object) method as well. This is the case by default if every childs are subclasses of AbstractMetadata.

Overrides:
equals in class java.lang.Object
Parameters:
object - The object to compare with this metadata.
Returns:
true if the given object is equals to this metadata.

hashCode

public int hashCode()
Computes a hash code value for this metadata using Java reflection. The hash code is defined as the sum of hash code values of all non-null properties. This is the same contract than Set.hashCode() and ensure that the hash code value is insensitive to the ordering of properties.

Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Returns a string representation of this metadata.

Overrides:
toString in class java.lang.Object


Copyright © 1996-2010 Geotools. All Rights Reserved.