com.fullspan.pwkeep.data
Class PwkBean

java.lang.Object
  extended by com.fullspan.pwkeep.data.PwkBean
Direct Known Subclasses:
PwkCategory, PwkItem

public class PwkBean
extends java.lang.Object

Base class for PWKeep data objects (such as PwkCategory and PwkItem).

Version:
$Revision: 1.4 $, $Date: 2004/01/18 08:09:05 $
Author:
Mitch Stuart, $Author: mitch $

Constructor Summary
PwkBean(java.lang.String name)
           
 
Method Summary
static java.lang.String getChildTextTrim(org.jdom.Element elem, java.lang.String childName)
          Wrapper to safely call getTextTrim on the named child element.
 java.lang.String getName()
           
 java.lang.String getTypeName(int count)
          Returns a user-friendly type name for this object, suitable for use in user interface messages.
static PwkBean newInstance(org.jdom.Element elem)
          Returns a new PwkBean of the proper subclass type, based on the name of the XML element passed in.
 void setName(java.lang.String name)
           
 org.jdom.Element toJdomElement()
          Returns an XML element representing this object.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PwkBean

public PwkBean(java.lang.String name)
Method Detail

newInstance

public static PwkBean newInstance(org.jdom.Element elem)
Returns a new PwkBean of the proper subclass type, based on the name of the XML element passed in.

Parameters:
elem - the XML element representing the data object
Returns:
a new instance of a PwkBean subclass

getChildTextTrim

public static java.lang.String getChildTextTrim(org.jdom.Element elem,
                                                java.lang.String childName)
Wrapper to safely call getTextTrim on the named child element. Returns null if the named child element does not exists.

Parameters:
elem - the parent element
childName - the name of the child element whose text is to be returned
Returns:
the trimmed text, or null if the named child element does not exist

getName

public java.lang.String getName()

setName

public void setName(java.lang.String name)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toJdomElement

public org.jdom.Element toJdomElement()
Returns an XML element representing this object. This method is only valid for subclasses, if it is called for the base class PwkBean, it will throw an UnsupportedOperationException.

Returns:
an XML element representing this object
Throws:
java.lang.UnsupportedOperationException - if called on the PwkBean base class

getTypeName

public java.lang.String getTypeName(int count)
Returns a user-friendly type name for this object, suitable for use in user interface messages. The name will be singular or plural based on the value of the count parameter.

The text is retrieved from lines like the following in messages.properties:


   typename.display.singular.com.fullspan.pwkeep.data.PwkItem=item
   typename.display.plural.com.fullspan.pwkeep.data.PwkItem=items
 

Parameters:
count - the number of objects - used to determine whether to return a singular or plural name
Returns:
the name for the type of this object