Package gw.internal.gosu.properties
Class PropertyNode
- java.lang.Object
-
- gw.internal.gosu.properties.PropertyNode
-
- All Implemented Interfaces:
IGosuObject
public class PropertyNode extends java.lang.Object implements IGosuObject
A node in a tree representation of an underlyingPropertySet. Any compound names, such as a.b.c and a.b.d, in the keys of the property set are split into a tree representation. In the a.b.c/a.b.d example there would be a property node for a, with a child node b with two further leaf children c and d.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,PropertyNode>_childrenprivate java.lang.String_nameprivate PropertyNode_parentprivate java.lang.String_pathprivate PropertySet_propertySet
-
Constructor Summary
Constructors Modifier Constructor Description privatePropertyNode(PropertyNode parent, java.lang.String name, PropertySet propertySet)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddChild(PropertyNode node)static PropertyNodebuildTree(PropertySet propertySet)private PropertyNodegetChild(java.lang.String name)java.util.List<PropertyNode>getChildren()The direct children of this property nodejava.lang.StringgetChildValue(java.lang.String name)Return the value for the named child property; this is just like doing lookup on the underlyingPropertySetexcept that the name is prefixed with the full name of this property.java.lang.StringgetFullName()The full property name, for example a.bITypegetIntrinsicType()Return the intrinsic type based on this property nodeprivate java.lang.StringgetName()PropertyNodegetParent()java.lang.StringgetPath()java.lang.StringgetRelativeName()The last part of the property name, for example b if the full name is a.bjava.lang.StringgetTypeName()Return the name that should be used for the type based on this property nodejava.lang.StringgetValue()Return the value for this property as given by the underlyingPropertySetbooleanhasValue()Does this property node have a value in the underlyingPropertySet(package private) static booleanisGosuIdentifier(java.lang.String name)private static booleanisGosuIdentifierPart(char ch)private static booleanisGosuIdentifierStart(char ch)booleanisLeaf()Is this a leaf node - that is, does it have no children?booleanisRoot()Is this the root of a property node tree?private booleanisUseless()private static java.lang.Stringjoin(java.lang.String head, java.lang.String tail)private voidremoveUseless()java.lang.StringtoString()If this node has a property value, returns the value of that property.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface gw.lang.reflect.gs.IGosuObject
equals, hashCode
-
-
-
-
Field Detail
-
_parent
private final PropertyNode _parent
-
_name
private final java.lang.String _name
-
_path
private final java.lang.String _path
-
_propertySet
private final PropertySet _propertySet
-
_children
private final java.util.Map<java.lang.String,PropertyNode> _children
-
-
Constructor Detail
-
PropertyNode
private PropertyNode(PropertyNode parent, java.lang.String name, PropertySet propertySet)
-
-
Method Detail
-
buildTree
public static PropertyNode buildTree(PropertySet propertySet)
-
getFullName
public java.lang.String getFullName()
The full property name, for example a.b- Returns:
- a non null name, which must be one or more valid Gosu identifiers separated by periods
-
getRelativeName
public java.lang.String getRelativeName()
The last part of the property name, for example b if the full name is a.b- Returns:
- a non null name, which must be a valid Gosu identifier
-
getTypeName
public java.lang.String getTypeName()
Return the name that should be used for the type based on this property node- Returns:
- a non null type name
-
getIntrinsicType
public IType getIntrinsicType()
Return the intrinsic type based on this property node- Specified by:
getIntrinsicTypein interfaceIGosuObject- Returns:
- intrinsic type
-
hasValue
public boolean hasValue()
Does this property node have a value in the underlyingPropertySet- Returns:
- true if the node has an underlying value, false otherwise
-
getValue
public java.lang.String getValue()
Return the value for this property as given by the underlyingPropertySet- Returns:
- the property value, or null if it doesn't have one
-
isLeaf
public boolean isLeaf()
Is this a leaf node - that is, does it have no children?- Returns:
- true if this node has no children, false otherwise
-
isRoot
public boolean isRoot()
Is this the root of a property node tree?- Returns:
- true if this is the root, false otherwise
-
getChildren
public java.util.List<PropertyNode> getChildren()
The direct children of this property node- Returns:
- a non null, though possibly empty, list of children
-
getChildValue
public java.lang.String getChildValue(java.lang.String name)
Return the value for the named child property; this is just like doing lookup on the underlyingPropertySetexcept that the name is prefixed with the full name of this property. For example if this property is a then getting the child value b.c will return the value of a.b.c in the original property set- Parameters:
name- non null name of child property- Returns:
- the child property value, or null if there is no such child property
-
toString
public java.lang.String toString()
If this node has a property value, returns the value of that property. Otherwise returns a string describing the property name.- Specified by:
toStringin interfaceIGosuObject- Overrides:
toStringin classjava.lang.Object
-
getChild
private PropertyNode getChild(java.lang.String name)
-
addChild
private void addChild(PropertyNode node)
-
isUseless
private boolean isUseless()
-
removeUseless
private void removeUseless()
-
isGosuIdentifier
static boolean isGosuIdentifier(java.lang.String name)
-
isGosuIdentifierStart
private static boolean isGosuIdentifierStart(char ch)
-
isGosuIdentifierPart
private static boolean isGosuIdentifierPart(char ch)
-
join
private static java.lang.String join(java.lang.String head, java.lang.String tail)
-
getName
private java.lang.String getName()
-
getPath
public java.lang.String getPath()
-
getParent
public PropertyNode getParent()
-
-