Home / Development / Documentation / 2.0.44 / TextElementData
TreeGraph 2
 


info.bioinfweb.treegraph.document
Class TextElementData

java.lang.Object
  extended by info.bioinfweb.treegraph.document.TextElementData
All Implemented Interfaces:
Cloneable

public class TextElementData
extends Object
implements Cloneable

This class is used to store data of tree elements which can either be a string or a decimal value.

Author:
Ben Stöver

Field Summary
private  double decimal
           
private  String text
           
 
Constructor Summary
TextElementData()
           
TextElementData(double decimal)
           
TextElementData(String string)
           
 
Method Summary
 void assign(TextElementData other)
           
 void clear()
          Clears this object.
 TextElementData clone()
           
 boolean equals(Object other)
           
static String formatTextElement(TextElement element)
          Returns the formatted value of the given text element.
 String formatValue(DecimalFormat format)
          Return the contained string or the contained formated decimal value or an empty string is the object contains no data.
 double getDecimal()
          Return the stored decimal value or Double.NaN is no decimal is stored.
 String getText()
          Returns the stored string value or null is no string is stored.
 boolean isDecimal()
          Return whether this object contains a decimal value.
 boolean isEmpty()
          Return whether this object is empty.
 boolean isString()
          Return whether this object contains a string value.
 void setDecimal(double doubleValue)
           
 void setText(String stringValue)
           
 String toString()
          Returns either the stored string, the decimal value as a sting or null if the object is empty.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

text

private String text

decimal

private double decimal
Constructor Detail

TextElementData

public TextElementData()

TextElementData

public TextElementData(String string)

TextElementData

public TextElementData(double decimal)
Method Detail

getDecimal

public double getDecimal()
Return the stored decimal value or Double.NaN is no decimal is stored.

Returns:

setDecimal

public void setDecimal(double doubleValue)

getText

public String getText()
Returns the stored string value or null is no string is stored.

Returns:

setText

public void setText(String stringValue)

clear

public void clear()
Clears this object. If a string or a decimal value are stored they will be deleted.

See Also:
isEmpty()

isString

public boolean isString()
Return whether this object contains a string value. Not that the return of false does not necessarily mean that a decimal value is contained. This object could also be empty.

Returns:
true if the stored value is a string
See Also:
isDecimal(), isEmpty()

isDecimal

public boolean isDecimal()
Return whether this object contains a decimal value. Not that the return of false does not necessarily mean that a string value is contained. This object could also be empty.

Returns:
true if the stored value is a decimnal
See Also:
isString(), isEmpty()

isEmpty

public boolean isEmpty()
Return whether this object is empty. It that case is neither contains a string nor a decimal.

Returns:
true if there is no value stored
See Also:
isDecimal(), isString()

formatValue

public String formatValue(DecimalFormat format)
Return the contained string or the contained formated decimal value or an empty string is the object contains no data.

Parameters:
format - the format-object to format a possibly contained decimal value
Returns:
the (formatted) string representation of the stored value

formatTextElement

public static String formatTextElement(TextElement element)
Returns the formatted value of the given text element.

Parameters:
element - the element to be formatted
Returns:

toString

public String toString()
Returns either the stored string, the decimal value as a sting or null if the object is empty.

Overrides:
toString in class Object
See Also:
Object.toString()

assign

public void assign(TextElementData other)

equals

public boolean equals(Object other)
Overrides:
equals in class Object

clone

public TextElementData clone()
Overrides:
clone in class Object