org.openbp.common.generic.description
Class DescriptionObjectImpl

java.lang.Object
  extended by org.openbp.common.generic.description.DescriptionObjectImpl
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable, Copyable, DescriptionObject, Displayable, Validatable
Direct Known Subclasses:
DisplayObjectImpl

public class DescriptionObjectImpl
extends java.lang.Object
implements DescriptionObject, java.lang.Cloneable, Copyable, Validatable

An object that has a name and a description. \bNote that this class does not support localization currently!\b
\bThe 'locale' parameter of all methods is ignored.\b

Author:
Heiko Erhardt
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.openbp.common.generic.Copyable
COPY_DEEP, COPY_FIRST_LEVEL, COPY_SHALLOW
 
Constructor Summary
DescriptionObjectImpl()
          Default constructor.
DescriptionObjectImpl(java.lang.String name)
          Value constructor.
DescriptionObjectImpl(java.lang.String name, java.lang.String description)
          Value constructor.
 
Method Summary
 java.lang.Object clone()
          Creates a clone of this object.
 int compareTo(java.lang.Object o)
          Compares this object to another Object.
 void copyFrom(java.lang.Object source, int copyMode)
          Copies the values of the source object to this object.
 java.lang.String getDescription()
          Gets the default description of this Object.
 java.lang.String getDescriptionEscape()
          Gets the escape representation of the default description of this Object.
 java.lang.String getDescriptionText()
          Gets text that can be used to describe this object.
 java.lang.String getDisplayText()
          Gets text that can be used to display this object.
 java.lang.String getName()
          Gets the name of this object.
 void setDescription(java.lang.String description)
          Sets the default description of this Object.
 void setDescriptionEscape(java.lang.String description)
          Sets the escape representation of the default description of this Object.
 void setName(java.lang.String name)
          Sets the name of this object.
 java.lang.String toString()
          Returns a string representation of this object.
 boolean validate(MsgContainer msgContainer)
          Checks if the object is valid.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DescriptionObjectImpl

public DescriptionObjectImpl()
Default constructor.


DescriptionObjectImpl

public DescriptionObjectImpl(java.lang.String name)
Value constructor.

Parameters:
name - The internal name of the object

DescriptionObjectImpl

public DescriptionObjectImpl(java.lang.String name,
                             java.lang.String description)
Value constructor.

Parameters:
name - The internal name of the object
description - Description of this object
Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Creates a clone of this object.

Specified by:
clone in interface Copyable
Specified by:
clone in interface DescriptionObject
Overrides:
clone in class java.lang.Object
Returns:
The clone (a deep copy of this object)
Throws:
java.lang.CloneNotSupportedException - If the cloning of one of the contained members failed

copyFrom

public void copyFrom(java.lang.Object source,
                     int copyMode)
              throws java.lang.CloneNotSupportedException
Copies the values of the source object to this object.

Specified by:
copyFrom in interface Copyable
Parameters:
source - The source object. Must be of the same type as this object.
copyMode - Determines if a deep copy, a first level copy or a shallow copy is to be performed. See the constants of the org.openbp.common.generic.description.Copyable class.
Throws:
java.lang.CloneNotSupportedException - If the cloning of one of the contained objects failed

toString

public java.lang.String toString()
Returns a string representation of this object.

Overrides:
toString in class java.lang.Object
Returns:
"(unqualified class name): '(name)'"

getName

public java.lang.String getName()
Gets the name of this object. This name is the internal name of the object (i. e. a class name).

Specified by:
getName in interface DescriptionObject
Returns:
The name

setName

public void setName(java.lang.String name)
Sets the name of this object. This name is the internal name of the object (i. e. a class name).

Specified by:
setName in interface DescriptionObject
Parameters:
name - The new name (may not be null)

getDescription

public java.lang.String getDescription()
Gets the default description of this Object.

Specified by:
getDescription in interface DescriptionObject
Returns:
The description or null if there is no description available

setDescription

public void setDescription(java.lang.String description)
Sets the default description of this Object. The description will be trimmed and spaces after newlines will be removed. (we need this in order to remove spaces inserted by Castor when serializing multi-line text content)

Specified by:
setDescription in interface DescriptionObject
Parameters:
description - The new description or null

getDescriptionEscape

public java.lang.String getDescriptionEscape()
Gets the escape representation of the default description of this Object. In the escape representation, a newline escape ("\n") has been added before any newline character. Tab characters are replaced by the tab escape ("\t"). (we need this in order to remove spaces inserted by Castor when serializing multi-line text content)

Returns:
The description or null if there is no description available

setDescriptionEscape

public void setDescriptionEscape(java.lang.String description)
Sets the escape representation of the default description of this Object. In the escape representation, a newline escape ("\n") has been added before any newline character. Tab characters are replaced by the tab escape ("\t"). (we need this in order to remove spaces inserted by Castor when serializing multi-line text content)

Parameters:
description - The new description or null

getDescriptionText

public java.lang.String getDescriptionText()
Gets text that can be used to describe this object. By default, this is the description text as returned by the getDescription() method.

Specified by:
getDescriptionText in interface DescriptionObject

getDisplayText

public java.lang.String getDisplayText()
Gets text that can be used to display this object. In this case, this is the regular name (DescriptionObject.setName(java.lang.String)) of the object itself.

Specified by:
getDisplayText in interface DescriptionObject
Specified by:
getDisplayText in interface Displayable
Returns:
The display text (should usually not be null)

compareTo

public int compareTo(java.lang.Object o)
Compares this object to another Object. If the object is a description object, it will compar the setName(java.lang.String) values of the two objects. Otherwise, it throws a ClassCastException (as DescriptionObjects are comparable only to other DescriptionObjects).

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - Object to be compared
Returns:
The value 0 if the argument is a string lexicographically equal to this object;
a value less than 0 if the argument is a string lexicographically greater than this object;
and a value greater than 0 if the argument is a string lexicographically less than this object.
Throws:
java.lang.ClassCastException - if the argument is not a DescriptionObject.

validate

public boolean validate(MsgContainer msgContainer)
Checks if the object is valid. The object is invalid if no setName(java.lang.String) has been specified.

Specified by:
validate in interface Validatable
Parameters:
msgContainer - Any errors will be logged to this message container
Returns:
true The object is valid.
false Errors were found within the object or its sub objects.


Copyright © 2011. All Rights Reserved.