Package org.apache.sis.metadata
Class TreeNode.Element
java.lang.Object
org.apache.sis.metadata.TreeNode
org.apache.sis.metadata.TreeNode.Element
- All Implemented Interfaces:
TreeTable.Node
- Direct Known Subclasses:
TreeNode.CollectionElement
- Enclosing class:
TreeNode
A node for a metadata property value. This class does not store the property value directly.
Instead, is stores a reference to the metadata object that contains the property values,
together with the index for fetching the value in that object. That way, the real storage
objects still the metadata object, which allow
TreeTableView
to be a dynamic view.
Instances of this class shall be instantiated only for metadata singletons. If a metadata
property is a collection, then the TreeNode.CollectionElement
subclass shall be instantiated
instead.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.sis.metadata.TreeNode
TreeNode.CollectionElement, TreeNode.Element
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final PropertyAccessor
The accessor to use for fetching the property names, types and values from theTreeNode.metadata
object.(package private) final Function
<TreeNode, TreeTable.Node> If tree node should be wrapped in another object before to be returned, the function performing that wrapping.private final int
Index of the value in theTreeNode.metadata
object to be fetched with theaccessor
.Fields inherited from class org.apache.sis.metadata.TreeNode
baseType, cachedValue, metadata, table
-
Constructor Summary
ConstructorsConstructorDescriptionElement
(TreeNode parent, Object metadata, PropertyAccessor accessor, int indexInData) Creates a new child for a property of the given metadata at the given index. -
Method Summary
Modifier and TypeMethodDescription(package private) void
appendIdentifier
(StringBuilder buffer) Appends an identifier for this node in the given buffer, forTreeNode.toString()
implementation.boolean
Returnstrue
if the value returned bygetUserObject()
should be the same for both nodes.(package private) final String
The property identifier to be returned in theTableColumn.IDENTIFIER
cells.(package private) CharSequence
getName()
Gets the name of this node.(package private) final CharSequence
Gets remarks about the value in this node, ornull
if none.Fetches the node value from the metadata object.int
hashCode()
Returns a hash code value for this node.(package private) final boolean
Returnstrue
if the metadata is writable.(package private) void
setUserObject
(Object value) Sets the property value for this node.private Class
<?> standardSubType
(Class<?>[] subtypes) Returns the element of the given array which is both assignable toTreeNode.baseType
and a member of the standard represented byTreeTableView.standard
.Methods inherited from class org.apache.sis.metadata.TreeNode
appendStringTo, getChildren, getIndex, getParent, getValue, isEditable, isLeaf, isMetadata, newChild, setValue, toString
-
Field Details
-
accessor
The accessor to use for fetching the property names, types and values from theTreeNode.metadata
object. Note that the reference stored in this field is the same for all siblings. -
indexInData
private final int indexInDataIndex of the value in theTreeNode.metadata
object to be fetched with theaccessor
. -
decorator
If tree node should be wrapped in another object before to be returned, the function performing that wrapping. This is used if we want to render a metadata property in a different way than the way implied by JavaBeans. The wrapping operation should be cheap because it will be applied every time the user request the node.Example: the"defaultLocale+otherLocale"
property is represented byMap.Entry<Locale,Charset>
values. The nodes created by this class contain thoseMap.Entry
values, but we want to show them to users as as aLocale
node with aCharset
child. This separation is done byLocaleAndCharset
.
-
-
Constructor Details
-
Element
Element(TreeNode parent, Object metadata, PropertyAccessor accessor, int indexInData) Creates a new child for a property of the given metadata at the given index.- Parameters:
parent
- the parent of this node.metadata
- the metadata object for which this node will be a value.accessor
- accessor to use for fetching the name, type and value.indexInData
- index to be given to the accessor for fetching the value.
-
-
Method Details
-
getIdentifier
The property identifier to be returned in theTableColumn.IDENTIFIER
cells.- Overrides:
getIdentifier
in classTreeNode
-
appendIdentifier
Appends an identifier for this node in the given buffer, forTreeNode.toString()
implementation.- Overrides:
appendIdentifier
in classTreeNode
-
getName
CharSequence getName()Gets the name of this node. Current implementation derives the name from theKeyNamePolicy.UML_IDENTIFIER
instead ofKeyNamePolicy.JAVABEANS_PROPERTY
in order to get the singular form instead of the plural one, because we will create one node for each element in a collection.If the property name is equal, ignoring case, to the simple type name, then this method returns the subtype name (SIS-298). For example, instead of:
we format: -
standardSubType
Returns the element of the given array which is both assignable toTreeNode.baseType
and a member of the standard represented byTreeTableView.standard
. If no such type is found, returnsnull
. If more than one type is found, returns theVoid.TYPE
sentinel value. -
getRemarks
Gets remarks about the value in this node, ornull
if none.- Overrides:
getRemarks
in classTreeNode
-
getUserObject
Fetches the node value from the metadata object.- Specified by:
getUserObject
in interfaceTreeTable.Node
- Overrides:
getUserObject
in classTreeNode
- Returns:
- any object stored at this node by the user, or
null
if none.
-
setUserObject
Sets the property value for this node.- Overrides:
setUserObject
in classTreeNode
-
isWritable
final boolean isWritable()Returnstrue
if the metadata is writable.- Overrides:
isWritable
in classTreeNode
-
equals
Returnstrue
if the value returned bygetUserObject()
should be the same for both nodes.- Specified by:
equals
in interfaceTreeTable.Node
- Overrides:
equals
in classTreeNode
- Parameters:
other
- the other object to compare with this node.- Returns:
- whether the two objects are nodes with equal values and equal children, ignoring parents.
-
hashCode
public int hashCode()Returns a hash code value for this node.- Specified by:
hashCode
in interfaceTreeTable.Node
- Overrides:
hashCode
in classTreeNode
- Returns:
- a hash code for this node, potentially based on values and children but ignoring parent.
-