net.sf.jplist.input
Class PojoBuilder

java.lang.Object
  extended by net.sf.jplist.input.PojoBuilder

public class PojoBuilder
extends java.lang.Object

Builds a JPList Document object from a POJO. The builder will introspect the bean, and execute all the public getXXX() methods that the POJO exposes (with the exception of Object#getObject()). The Document object stores the values returned in a PList Dictionary as XXX = value of getXXX(). If the returned object is any of the primitive types or their wrappers, the builder will call the object's * toString() method and store the value as a JPList StringElement object. If the value returned is a object that implements the java.util.Collection interface, the builder will attempt to iterate through its elements and store the resultant value as a JPList ArrayElement. If the value returned is some other object, the builder will recursively execute the public getXXX() methods of the returned object, using the rules outlined above, and represent the value as an embedded DictionaryElement.

Version:
$Revision: 1.3 $
Author:
Sujit Pal (spal@users.sourceforge.net)

Constructor Summary
PojoBuilder()
          Builds a new PojoBuilder object.
 
Method Summary
 Document build(java.lang.Object obj)
          Builds a JPList Document object from an Object.
 java.util.List getPublicAccessors(java.lang.Class clazz)
          Returns a List of public getXXX() Method objects for the specified class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PojoBuilder

public PojoBuilder()
Builds a new PojoBuilder object.

Method Detail

build

public Document build(java.lang.Object obj)
               throws JPListException
Builds a JPList Document object from an Object. This method will use reflection to invoke all public getXXX() methods exposed by the Object. If the value returned by the getXXX() method is a null, then it will not be included in the JPList Document. The JPList Document is built as an Array of Dictionaries. The first element is a Dictionary containing the classname as a single name value pair. The next element is a Dictionary with the keys being the name of the field, and the value being the Object returned by the getXXX() invocation. If the Object returned is a primitive (int, long, etc) or a primitive wrapper Object (Integer, Long, etc), then the value is the String representation of that object. If the Object returned is a Collection, then it is represented as an Array. If the Object is another subordinate object, then that object is introspected in the same way and the value represented as a Dictionary.

Parameters:
obj - the POJO to build from.
Returns:
a JPList Document
Throws:
JPListException - if there was a problem.

getPublicAccessors

public java.util.List getPublicAccessors(java.lang.Class clazz)
Returns a List of public getXXX() Method objects for the specified class.

Parameters:
clazz - the Class to introspect.
Returns:
a List of public getXXX() Method objects.