Rakesh API

org.rakeshv
Class BaseObject

java.lang.Object
  extended by org.rakeshv.BaseObject
Direct Known Subclasses:
ServerPreferences, UserPreferences

public class BaseObject
extends java.lang.Object

A sub-class of java.lang.Object that is meant to be used as the base-class for all classes. This class provides an over-ridden toString() method that returns an XML representation of all the fields in a class that have Java Bean style accessor methods.

Copyright 2004 Rakesh Vidyadharan

Version:
$Id: BaseObject.java,v 1.3 2004/11/06 20:40:55 rakesh Exp $
Author:
Rakesh Vidyadharan 2004 October 3

Field Summary
static java.lang.String END_OF_LINE
          The end of line characters to use to delimit lines.
private static java.util.logging.Logger logger
          A logger used to log errors.
 
Constructor Summary
BaseObject()
           
 
Method Summary
protected  void printCollection(java.util.Collection collection, java.lang.StringBuffer buffer)
          Append XML representations of each element stored in the Collection to the specified StringBuffer.
private  void printField(java.lang.reflect.Field field, java.lang.StringBuffer buffer)
          Fetch the value of the specified Field using its accessor method (if it exists).
protected  void printMap(java.util.Map map, java.lang.StringBuffer buffer)
          Append an XML representation of the key-value mappings stored in the specified Map to the specified StringBuffer.
 java.lang.String toString()
          Returns a string that presents an XML representation of the data encapsulated in this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

private static final java.util.logging.Logger logger
A logger used to log errors.


END_OF_LINE

public static final java.lang.String END_OF_LINE
The end of line characters to use to delimit lines.

Constructor Detail

BaseObject

public BaseObject()
Method Detail

toString

public java.lang.String toString()
Returns a string that presents an XML representation of the data encapsulated in this object.

Overrides:
toString in class java.lang.Object
Returns:
String - The XML representation of the object.

printField

private void printField(java.lang.reflect.Field field,
                        java.lang.StringBuffer buffer)
Fetch the value of the specified Field using its accessor method (if it exists). Write the XML representation of the data encapsulated in the field to the specified StringBuffer.

Parameters:
field - The field whose XML representation is to be derived.
buffer - The StringBuffer to which the field's XML representation is to be written.

printCollection

protected void printCollection(java.util.Collection collection,
                               java.lang.StringBuffer buffer)
Append XML representations of each element stored in the Collection to the specified StringBuffer. This method will be invoked recursively for elements that are themselves collections.

See Also:
printMap( Map, StringBuffer )

printMap

protected void printMap(java.util.Map map,
                        java.lang.StringBuffer buffer)
Append an XML representation of the key-value mappings stored in the specified Map to the specified StringBuffer. This method invokes itself recursively for values that are themselves maps.

Parameters:
map - The map whose XML representation is to be generated.
buffer - The StringBuffer to which the XML representation is to be appended.

Rakesh API

Copyright © 2002-2005 - Rakesh Vidyadharan