org.treebind
Class JavaObjectSource

java.lang.Object
  extended byorg.treebind.DefaultPipeElementImplementation
      extended byorg.treebind.JavaObjectSource
All Implemented Interfaces:
PipeElement, Source

public class JavaObjectSource
extends DefaultPipeElementImplementation
implements Source

Source designed to read Java objects.

Author:
vdv
See Also:
Source

Constructor Summary
JavaObjectSource()
          Creates a new JavaObjectSource.
JavaObjectSource(JavaObject2XmlSaxPipe pipe)
          Creates a new JavaObjectSource in a pipe.
 
Method Summary
 Name getNature(java.lang.reflect.Method method, java.lang.Object value, boolean iterated)
          This method is used internally to derive the nature of a property from a java method.
 Name getRole(java.lang.reflect.Method method, java.lang.Object value, boolean iterated)
          This method is used internally to derive the role of a property from a java method.
 Sink getSink()
          Get the Sink in which properties will be poured.
 void pourObject(java.lang.Object object)
          Pours an object into the source and feed its sink with its properties.
 void setSink(Sink sink)
          Sets the Sink in which properties will be poured.
 
Methods inherited from class org.treebind.DefaultPipeElementImplementation
getPipe, setPipe
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.treebind.PipeElement
getPipe, setPipe
 

Constructor Detail

JavaObjectSource

public JavaObjectSource()
Creates a new JavaObjectSource.


JavaObjectSource

public JavaObjectSource(JavaObject2XmlSaxPipe pipe)
Creates a new JavaObjectSource in a pipe.

Parameters:
pipe - the pipe that will contain the JavaObjectSource.
Method Detail

getNature

public Name getNature(java.lang.reflect.Method method,
                      java.lang.Object value,
                      boolean iterated)
This method is used internally to derive the nature of a property from a java method. It can be overriden to change the default behavior which is to return the JavaClassName.JavaClassName(Object) created with the value of the Java property.

Parameters:
method - the method.
value - the value.
iterated - flag indicating that the property has multiple values.
Returns:
the nature.

getRole

public Name getRole(java.lang.reflect.Method method,
                    java.lang.Object value,
                    boolean iterated)
This method is used internally to derive the role of a property from a java method. It can be overriden to change the default behavior which is to return the JavaMethodName.JavaMethodName(Method, boolean) created with the Java method and iterated flag.

Parameters:
method - the method.
value - the value.
iterated - flag indicating that the property has multiple values.
Returns:
the role.

getSink

public Sink getSink()
Description copied from interface: Source
Get the Sink in which properties will be poured.

Specified by:
getSink in interface Source
Returns:
the sink

pourObject

public void pourObject(java.lang.Object object)
                throws java.lang.Exception
Pours an object into the source and feed its sink with its properties.

Parameters:
object - the object.
Throws:
java.lang.Exception
java.lang.Exception - any exception that can occur while retrieving the property and pouring it into the sink.

setSink

public void setSink(Sink sink)
Description copied from interface: Source
Sets the Sink in which properties will be poured.

Specified by:
setSink in interface Source
Parameters:
sink - the sink