story.dbcore.links
Class LinkLabel

java.lang.Object
  extended by story.dbcore.links.LinkLabel
All Implemented Interfaces:
java.io.Serializable

public class LinkLabel
extends java.lang.Object
implements java.io.Serializable

An object that represents a collection of all the attributes attached to a certain link, serving as the link label.

It is primarily driven by AttributeSet, as the attributes with which we annotate nodes are similar to those with which we annotate links.

A LinkLabel is meant to be passed around only within db-core, and never revealed to calling applications or users. This is because they support write operations. Users who want to read or alter LinkLabels should go through the proper DBCoreInterface channel.

However, calling applications are allowed to create new LinkLabels and pass them to the db-core. They just will never see the label again and any changes they make to the label object will be ignored. The label is cloned when it is brought into the db-core.

See Also:
Serialized Form

Field Summary
static LinkLabel EMPTY_LABEL
           
 
Constructor Summary
LinkLabel()
          Constructor
LinkLabel(AttributeID ID, Attribute attribute)
          Constructor with first attribute to initiate.
LinkLabel(boolean overrider)
          Private constructor for a strictly empty label.
LinkLabel(NodeAddress concreteAddress, NodeInstancing instancing, LinkDirection instancing_direction)
          Constructor that you must use iff this is a LinkLabel for a linkInstancing (e.g., [ex1] = exampleOf(provision(health))).
LinkLabel(java.lang.String comment)
          Super-duper-easy constructor that takes a string, assumes it is a free-text comment, and sets up a single "comment" attribute for the label with the parameter
 
Method Summary
 boolean containsAttribute(AttributeID ID)
          Determines whether the label has an attribute of a certain name.
 boolean equivalent(LinkLabel other)
          Determines whether two LinkLables are equivalent.
 void finalize()
          Finalize this LinkLabel.
 LinkLabelAddress getAddress()
          Get the address of this LinkLabel.
 java.lang.Class getAttributeClass(AttributeID ID)
          Get an existing attribute's class.
 java.util.Iterator getAttributeIDs()
          Get an Iterator over all the AttributeIDs in the LinkLabel.
 AttributeValue getAttributeValue(AttributeID ID)
           
 NodeInstancing getInstancing()
          Return the NodeInstancing of the instancing of the link for which this is a label, or null if this is not such a label.
 NodeAddress getInstancingAddress()
          Return the NodeAddress of the concrete node for the linkInstancing for which this is a label, or null if this is not such a label.
 LinkDirection getInstancingDirection()
          Return the LinkDirection of the instancing of the link for which this is a label, or null if this is not such a label.
 void initAttribute(AttributeID ID, Attribute attribute)
          Initializes an attribute in the LinkLabel.
 boolean isFinalized()
          Determine whether this LinkLabel is finalized.
 java.lang.StringBuffer render()
          Renders the entire link label (all attributes) as a single string, in the syntax the command interpreter can understand.
 java.lang.StringBuffer renderForHumans()
          Renders the entire link label (all attributes) as a single string, in a way that is NOT interpretable by the command interpreter, but is nicer for humans to read.
 java.lang.StringBuffer renderInstancing(LinkType linkType)
          Renders the linkInstancing of the label, if any.
 AttributeValue setAttribute(AttributeID ID, AttributeValue value)
          Sets an attribute in the LinkLabel.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_LABEL

public static final LinkLabel EMPTY_LABEL
Constructor Detail

LinkLabel

public LinkLabel(NodeAddress concreteAddress,
                 NodeInstancing instancing,
                 LinkDirection instancing_direction)
Constructor that you must use iff this is a LinkLabel for a linkInstancing (e.g., [ex1] = exampleOf(provision(health))).


LinkLabel

public LinkLabel()
Constructor


LinkLabel

public LinkLabel(boolean overrider)
Private constructor for a strictly empty label.


LinkLabel

public LinkLabel(AttributeID ID,
                 Attribute attribute)
          throws Scheherexception
Constructor with first attribute to initiate.

Throws:
Scheherexception

LinkLabel

public LinkLabel(java.lang.String comment)
          throws Scheherexception
Super-duper-easy constructor that takes a string, assumes it is a free-text comment, and sets up a single "comment" attribute for the label with the parameter

Throws:
Scheherexception
Method Detail

isFinalized

public boolean isFinalized()
Determine whether this LinkLabel is finalized.


finalize

public void finalize()
Finalize this LinkLabel. Any further attempt to alter it will throw an exception.

Overrides:
finalize in class java.lang.Object

initAttribute

public void initAttribute(AttributeID ID,
                          Attribute attribute)
                   throws Scheherexception
Initializes an attribute in the LinkLabel.

Throws:
Scheherexception

setAttribute

public AttributeValue setAttribute(AttributeID ID,
                                   AttributeValue value)
                            throws Scheherexception
Sets an attribute in the LinkLabel.

Throws:
Scheherexception

equivalent

public boolean equivalent(LinkLabel other)
                   throws Scheherexception
Determines whether two LinkLables are equivalent.

Throws:
Scheherexception

renderInstancing

public java.lang.StringBuffer renderInstancing(LinkType linkType)
                                        throws Scheherexception
Renders the linkInstancing of the label, if any.

Throws:
Scheherexception

renderForHumans

public java.lang.StringBuffer renderForHumans()
                                       throws Scheherexception
Renders the entire link label (all attributes) as a single string, in a way that is NOT interpretable by the command interpreter, but is nicer for humans to read.

Throws:
Scheherexception

render

public java.lang.StringBuffer render()
                              throws Scheherexception
Renders the entire link label (all attributes) as a single string, in the syntax the command interpreter can understand.

Throws:
Scheherexception

getAttributeIDs

public java.util.Iterator getAttributeIDs()
                                   throws Scheherexception
Get an Iterator over all the AttributeIDs in the LinkLabel.

Throws:
Scheherexception

getAttributeValue

public AttributeValue getAttributeValue(AttributeID ID)
                                 throws Scheherexception
Throws:
Scheherexception

getAttributeClass

public java.lang.Class getAttributeClass(AttributeID ID)
                                  throws Scheherexception
Get an existing attribute's class.

Parameters:
ID - The AttributeID for the attribute.
Throws:
Scheherexception

containsAttribute

public boolean containsAttribute(AttributeID ID)
                          throws Scheherexception
Determines whether the label has an attribute of a certain name.

Throws:
Scheherexception

getAddress

public LinkLabelAddress getAddress()
                            throws Scheherexception
Get the address of this LinkLabel.

Throws:
Scheherexception

getInstancingAddress

public NodeAddress getInstancingAddress()
Return the NodeAddress of the concrete node for the linkInstancing for which this is a label, or null if this is not such a label. For example, if this is the label of the link ex1 = exampleof(provision(health)), this will return ex1 as a NodeAddress.


getInstancing

public NodeInstancing getInstancing()
Return the NodeInstancing of the instancing of the link for which this is a label, or null if this is not such a label. For example, if this is the label of the link ex1 = exampleof(provision(health)), this will return provision(health) as a NodeInstancing.


getInstancingDirection

public LinkDirection getInstancingDirection()
Return the LinkDirection of the instancing of the link for which this is a label, or null if this is not such a label. For example, if this is the label of the link ex1 = exampleof(provision(health)), this will return FromNode as a LinkDirection.



Copyright © 2011 David K. Elson. All Rights Reserved.