org.geotoolkit.image.io.metadata
Class MetadataTreeNode

Object
  extended by DefaultMutableTreeNode
      extended by DefaultMutableTreeNode
          extended by NamedTreeNode
              extended by MetadataTreeNode
All Implemented Interfaces:
Serializable, Cloneable, MutableTreeNode, TreeNode, TreeTableNode, Localized

public final class MetadataTreeNode
extends NamedTreeNode
implements TreeTableNode

A node in the tree produced by MetadataTreeTable. The value returned by the toString() method is the programmatic name of the element or attribute represented by this node. The values returned by the getValueAt(int) method are the values for the columns documented in the MetadataTreeTable javadoc. Those values are also accessible by specific getter methods:

  1. getLabel()
  2. getDescription()
  3. getValueType()
  4. getOccurrences()
  5. getUserObject() (this column may be omitted - see MetadataTreeTable)
  6. getDefaultValue()
  7. getValueRestriction()

By default the value returned by getAllowsChildren() is:

Since:
3.05
Version:
3.05
Author:
Martin Desruisseaux (Geomatys)
See Also:
Serialized Form
Module:
coverage/geotk-coverageio (download)    View source code for this class

Field Summary
 
Fields inherited from class DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
 
Method Summary
 Class<?> getColumnClass(int column)
          Returns the most specific superclass of values that can be stored in the given column.
 int getColumnCount()
          Returns the number of columns supported by this TreeTableNode.
 Object getDefaultValue()
          Returns the default value, or null if none.
 String getDescription()
          Returns the description, or null if none.
 String getLabel()
          Returns the display label.
 String getName()
          Returns the programmatic name of this node.
 NumberRange<Integer> getOccurrences()
          Returns the range of occurrences that are valid for this node.
 MetadataTreeNode getParent()
          Returns the parent of this node.
 Object getUserObject()
          Returns the value of this node, or null if none.
 Object getValueAt(int column)
          Gets the value for this node that corresponds to a particular tabular column.
 ValueRestriction getValueRestriction()
          Returns the range or the enumeration of valid values.
 Class<?> getValueType()
          Returns the type of user object that can be associated to the element or attribute.
 boolean isEditable(int column)
          Determines whether the specified column is editable.
 void setUserObject(Object value)
          Sets the value of this node.
 void setValueAt(Object value, int column)
          Sets the value for the given column.
 
Methods inherited from class NamedTreeNode
setName, toString
 
Methods inherited from class DefaultMutableTreeNode
children, getLocale
 
Methods inherited from class DefaultMutableTreeNode
add, breadthFirstEnumeration, clone, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildAt, getChildBefore, getChildCount, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getPath, getPathToRoot, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObjectPath, insert, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, remove, removeAllChildren, removeFromParent, setAllowsChildren, setParent
 
Methods inherited from class Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface TreeNode
children, toString
 
Methods inherited from interface TreeNode
getAllowsChildren, getChildAt, getChildCount, getIndex, isLeaf
 
Methods inherited from interface MutableTreeNode
insert, remove, remove, removeFromParent, setParent
 

Method Detail

getParent

public final MetadataTreeNode getParent()
Returns the parent of this node.

Specified by:
getParent in interface TreeNode
Overrides:
getParent in class DefaultMutableTreeNode
Returns:
The parent of this node, or null if none.

getName

public final String getName()
Returns the programmatic name of this node. This is for example the UML identifier as defined ISO 19115.

Overrides:
getName in class NamedTreeNode
Returns:
The programmatic name of this node.

getLabel

public String getLabel()
Returns the display label. It will be constructed from the programmatic name (often the UML identifier) when first needed and cached for future reuse.

Returns:
The label inferred from the programmatic node name (never null).

getDescription

public String getDescription()
Returns the description, or null if none. The description will be localized in the Tree Table locale, if possible.

Returns:
The description, or null if none.

getOccurrences

public NumberRange<Integer> getOccurrences()
Returns the range of occurrences that are valid for this node. This method never returns null since the minimum value of occurrences is at least 0.

Returns:
The range of occurrences (never null).

getValueType

public Class<?> getValueType()
Returns the type of user object that can be associated to the element or attribute. Collection types are converted to array types. If the node is not allowed to store any object, then this method returns null.

Returns:
The type of user object, or null if this node does not allow value.

getValueRestriction

public ValueRestriction getValueRestriction()
Returns the range or the enumeration of valid values. If there is no restriction on the valid values, then this method returns null.

Returns:
A description of the valid values, or null if none.

getDefaultValue

public Object getDefaultValue()
Returns the default value, or null if none.

Returns:
The default value, or null if none.

getUserObject

public Object getUserObject()
Returns the value of this node, or null if none. This property is the only one which can be modified by a setter method. If the MetadataTreeTable contains an IIOMetadata instance, then the user object is initialized to the value extracted from the IIOMetadata.

Overrides:
getUserObject in class DefaultMutableTreeNode
Returns:
The user object, or null.

setUserObject

public void setUserObject(Object value)
                   throws IllegalArgumentException
Sets the value of this node. The given value must be compliant with the restrictions specified by getValueType() and getValueRestriction().

Specified by:
setUserObject in interface MutableTreeNode
Overrides:
setUserObject in class DefaultMutableTreeNode
Parameters:
value - The value to give to this node (can be null).
Throws:
IllegalArgumentException - if the given value is not an instance of the expected type or violates a value restriction.
See Also:
setValueAt(Object, int)

getColumnCount

public int getColumnCount()
Returns the number of columns supported by this TreeTableNode. This method returns 7 if the tree table contains the data of an IIOMetadata object, or the above value minus one otherwise.

Specified by:
getColumnCount in interface TreeTableNode
Returns:
The number of columns this node supports.

getColumnClass

public Class<?> getColumnClass(int column)
Returns the most specific superclass of values that can be stored in the given column. The columns are numbered from 0 inclusive to getColumnCount() exclusive. They are the same numbers than the ones used for the getValueAt(int) method.

Specified by:
getColumnClass in interface TreeTableNode
Parameters:
column - The column to query.
Returns:
The most specific superclass of legal values in the queried column.

getValueAt

public Object getValueAt(int column)
Gets the value for this node that corresponds to a particular tabular column. The columns are numbered from 0 inclusive to getColumnCount() exclusive. Each column maps to a getter methods of this class, in this order:

  1. getLabel()
  2. getDescription()
  3. getValueType()
  4. getOccurrences()
  5. getUserObject() (this column may be omitted - see below)
  6. getDefaultValue()
  7. getValueRestriction()

Note that if the tree table does not map a IIOMetadata object, then there is no column for getUserObject() and the number of all following columns are shifted by one.

Note: If the behavior of this method is changed, then IIOMetadataTreeTable implementation needs to be modified accordingly.

Specified by:
getValueAt in interface TreeTableNode
Parameters:
column - The column to query.
Returns:
The value for the queried column.

setValueAt

public void setValueAt(Object value,
                       int column)
Sets the value for the given column. This method set the user object to the given value only if the all the following conditions are meet:

Otherwise this method does nothing.

Specified by:
setValueAt in interface TreeTableNode
Parameters:
value - The value to set.
column - The column to set the value on.

isEditable

public boolean isEditable(int column)
Determines whether the specified column is editable. By default only the MetadataTreeTable.VALUE_COLUMN is editable, and only if that column exists. This column does not exist if no IIOMetadata instance was specified to MetadataTreeTable.

Specified by:
isEditable in interface TreeTableNode
Parameters:
column - The column to query.
Returns:
true if the column is editable, false otherwise.


Copyright © 2009-2012 Geotoolkit.org. All Rights Reserved.