com.lexonics.edsel
Class Node

java.lang.Object
  extended bycom.lexonics.edsel.Node

public final class Node
extends Object

An Edsel node. A Node has a name and an attribute set. The name is a valid Edsel identifier; that is, it is a non-null, non-empty String that contains no characters other than upper- and lowercase ASCII letters, digits, and hyphens. Names beginning with hyphens are reserved. By convention, node names are concatenations of words with only the first character of each word uppercase. The attribute set is a non-null Set of Attributes; no two Attributes in the attribute set have equal names. Nodes are immutable.


Field Summary
static Node Edge
          The predefined structure Node with name -Edge.
static Node MultiAttribute
          The predefined structure Node with name -MultiAttribute.
static Node MultiEdge
          The predefined structure Node with name -MultiEdge.
static Node Structure
          The predefined structure Node with name -Structure.
 
Constructor Summary
Node(String name)
          Construct a Node with a given name and an empty attribute set.
Node(String name, Set attributeSet)
          Construct a Node with a given name and attribute set.
 
Method Summary
 Attribute attribute(String name)
          Return the Attribute in this Node with a given name, or null if none.
 Set attributeSet()
          Return a shallow copy of the attribute set of this Node.
 boolean equals(Object o)
          Compare a given object with this Node for equality.
 int hashCode()
          Return the hash code value for this Node.
 String name()
          Return the name of this Node.
static Node predefinedStructureNode(String name)
          Return the predefined structure node with a given name, or null if none.
 String toString()
          Return a string representation of this Node.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

Structure

public static final Node Structure
The predefined structure Node with name -Structure.


MultiAttribute

public static final Node MultiAttribute
The predefined structure Node with name -MultiAttribute.


Edge

public static final Node Edge
The predefined structure Node with name -Edge.


MultiEdge

public static final Node MultiEdge
The predefined structure Node with name -MultiEdge.

Constructor Detail

Node

public Node(String name)
Construct a Node with a given name and an empty attribute set.

Parameters:
name - The name of the Node. Must be a valid Edsel identifier.
Throws:
IllegalArgumentException - The name is not a valid Edsel identifier.

Node

public Node(String name,
            Set attributeSet)
Construct a Node with a given name and attribute set.

Parameters:
name - The name of the Node. Must be a valid Edsel identifier.
attributeSet - The attribute set of the Node. Must be a non-null Set of Attributes, no two of which have equal names. This set is copied by a shallow copy, to guarantee Node immutability.
Throws:
IllegalArgumentException - The name is not a valid Edsel identifier, the attribute set is null, an element of the attribute set is not an Attribute, or two Attributes in the attribute set have equal names.
Method Detail

attribute

public Attribute attribute(String name)
Return the Attribute in this Node with a given name, or null if none.

Parameters:
name - The name.
Returns:
The Attribute in this Node with the given name, or null if none.

attributeSet

public Set attributeSet()
Return a shallow copy of the attribute set of this Node.

Returns:
A shallow copy of the attribute set of this Node.

equals

public boolean equals(Object o)
Compare a given object with this Node for equality. Return true if the given object is also a Node, and the two Nodes have equal names and attribute sets.

Parameters:
o - The object.
Returns:
true if the object is equal to this Node.

hashCode

public int hashCode()
Return the hash code value for this Node. The hash code of a Node is defined to be the sum of the hash codes of its name and attribute set.

Returns:
The hash code value for this Node.

name

public String name()
Return the name of this Node.

Returns:
The name of this Node.

predefinedStructureNode

public static Node predefinedStructureNode(String name)
Return the predefined structure node with a given name, or null if none.

Parameters:
name - The name.
Returns:
The predefined structure node with the given name, or null if none.

toString

public String toString()
Return a string representation of this Node.

Returns:
The string representation. Any backslash or single quote in the value of an Attribute in the attribute set is escaped by a backslash.


Copyright, 2003
Lexonics, Inc.
All Rights Reserved