net.charlesames.utility.entity
Class Clipboard

java.lang.Object
  extended by net.charlesames.utility.entity.Clipboard
All Implemented Interfaces:
java.io.Serializable

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

The Clipboard class implements temporary storage for instances of WriteableEntity which have been serialized into and XML Document.

Author:
Charles Ames
See Also:
Serialized Form

Constructor Summary
Clipboard()
          Constructor for Clipboard instances.
 
Method Summary
 void clear()
          Clear the clipboard by setting both content and entity class to null.
 java.lang.String getAttribute(java.lang.String tag)
          Get the text value of the attribute with the indicated tag.
 org.w3c.dom.Document getContent()
          Get the clipboard contents.
 java.lang.String getContextAsText()
          Get the clipboard content as a text string.
 org.w3c.dom.Element getDocumentElement()
          Get XML serialization of the WriteableEntity saved on the clipboard.
 java.lang.Class<? extends WriteableEntity> getEntityClass()
          Get the class of the WriteableEntity instance serialized onto the clipboard.
 int getIntegerAttribute(java.lang.String tag)
          Get the value of the attribute with the indicated tag and convert it to an integer
 boolean hasAttribute(java.lang.String tag)
          Test if the object serialized on the clipboard has an attribute with the indicated tag.
 boolean hasContent()
          Test if the clipboard has content.
 void setAttribute(java.lang.String tag, java.lang.String value)
          Set the the attribute with the indicated tag to the indicated¯ value.
 void setContent(WriteableEntity entity)
          Serialize the indicated WriteableEntity instance as an XML Document.
 void setIntegerAttribute(java.lang.String tag, int value)
          Set the the attribute with the indicated tag to the indicated integer value.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Clipboard

public Clipboard()
Constructor for Clipboard instances.

Method Detail

getContent

public org.w3c.dom.Document getContent()
Get the clipboard contents.

Returns:
An XML Document holding the serialization of a WriteableEntity instance.

getEntityClass

public java.lang.Class<? extends WriteableEntity> getEntityClass()
Get the class of the WriteableEntity instance serialized onto the clipboard.

Returns:
The class of the WriteableEntity instance serialized onto the clipboard.

hasContent

public boolean hasContent()
Test if the clipboard has content.

Returns:
True if the clipboard has content; false otherwise.

getContextAsText

public java.lang.String getContextAsText()
Get the clipboard content as a text string.

Returns:
The clipboard content as a text string.

setContent

public void setContent(WriteableEntity entity)
Serialize the indicated WriteableEntity instance as an XML Document.

Parameters:
entity - The indicated WriteableEntity instance.

clear

public void clear()
Clear the clipboard by setting both content and entity class to null.


getDocumentElement

public org.w3c.dom.Element getDocumentElement()
Get XML serialization of the WriteableEntity saved on the clipboard.

Returns:
The document element of the content Document.

hasAttribute

public boolean hasAttribute(java.lang.String tag)
Test if the object serialized on the clipboard has an attribute with the indicated tag.

Parameters:
tag - The indicated tag.
Returns:
True if the document has an attribute with the indicated tag; false otherwise.

getIntegerAttribute

public int getIntegerAttribute(java.lang.String tag)
Get the value of the attribute with the indicated tag and convert it to an integer

Parameters:
tag - The indicated tag.
Returns:
The integer value of the attribute with the indicated tag.
Throws:
java.lang.NumberFormatException - when the attribute text does not parse into an integer.

setIntegerAttribute

public void setIntegerAttribute(java.lang.String tag,
                                int value)
Set the the attribute with the indicated tag to the indicated integer value.

Parameters:
tag - The indicated tag.
value - The indicated value.

getAttribute

public java.lang.String getAttribute(java.lang.String tag)
Get the text value of the attribute with the indicated tag.

Parameters:
tag - The indicated tag.
Returns:
The text value of the attribute with the indicated tag.

setAttribute

public void setAttribute(java.lang.String tag,
                         java.lang.String value)
Set the the attribute with the indicated tag to the indicated¯ value.

Parameters:
tag - The indicated tag.
value - The indicated value.