ca.quine.jcommons.sourceexporter
Class DefaultMarshaller
java.lang.Object
|
+--ca.quine.jcommons.sourceexporter.SourceMarshaller
|
+--ca.quine.jcommons.sourceexporter.DefaultMarshaller
- public class DefaultMarshaller
- extends SourceMarshaller
Marshals a JavaBean by looking for get/set or get/is method pairs.
The DefaultMarshaller will normally only marshal an Object if no other
marshaller has indicated that it can handle that Object.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DefaultMarshaller
public DefaultMarshaller()
doesMarshal
public boolean doesMarshal(Object object)
- Returns true for all non-null Objects. The DefaultMarshaller is,
by default, the last marshaller to get a chance to marshal an
Object. The
NullMarshaller
is, by default, the first
marshaller to get a chance to marshal an Object, so normally
the given object
would not be null here. The
test is a guard clause which will, under all normal circumstances,
never be triggered.
- Specified by:
doesMarshal
in class SourceMarshaller
marshal
public String marshal(ChainOfResponsibility chainOfResponsibility,
MarshallingContext context,
ClassSource classSource,
Object object,
boolean marshalAsObject)
throws IOException,
IllegalArgumentException,
IllegalAccessException,
InvocationTargetException,
ClassNotFoundException,
InstantiationException
- Marshals the given
object
into the given
classSource
, adding new methods to the
classSource
as required and returning
a String
that will be put inside a setter call
or used in a return.
This method will return either the source code to pull an already seen
Object out of the alreadySeen
map, or a method call that
will return the required Object for use in a setter call or return
statement.
- Specified by:
marshal
in class SourceMarshaller
IOException
IllegalArgumentException
IllegalAccessException
InvocationTargetException
ClassNotFoundException
InstantiationException
getJustInitializedObjectOfType
protected Object getJustInitializedObjectOfType(MarshallingContext context,
String objectType)
throws ClassNotFoundException,
IllegalAccessException,
InstantiationException
- Create a newly instantiated Object of the requested type, or get one out
of the "justInitializedObjectMap". The returned Object can then be
compared to an Object about to be marshalled to cut down on unneeded
setter calls.
- Parameters:
context
- the "justInitializedObjectMap" from the context is
used to instantiate each type only onceobjectType
- the fully qualified class name to instantiate,
which must have a public, no-args constructor.
- Returns:
- a newly instantiated Object of the requested type
- Throws:
ClassNotFoundException
IllegalAccessException
InstantiationException