public class Encoder extends Object
Constructor and Description |
---|
Encoder() |
Modifier and Type | Method and Description |
---|---|
Object |
get(Object oldInstance)
Returns the replacement object which has been created by the encoder during
the instantiation sequence or
null if the object has not
been processed yet. |
ExceptionListener |
getExceptionListener()
Returns the currently active
ExceptionListener instance. |
PersistenceDelegate |
getPersistenceDelegate(Class<?> type) |
Object |
remove(Object oldInstance) |
void |
setExceptionListener(ExceptionListener listener)
Sets the
ExceptionListener instance to be used for reporting
recorable exceptions in the instantiation and initialization sequence. |
void |
setPersistenceDelegate(Class<?> type,
PersistenceDelegate delegate)
Sets the
PersistenceDelegate instance for the given class. |
void |
writeExpression(Expression expr)
Note: If you call this method not from within an object instantiation and
initialization sequence it will be silently ignored.
|
protected void |
writeObject(Object o) |
void |
writeStatement(Statement stmt)
Note: If you call this method not from within an object instantiation and
initialization sequence it will be silently ignored.
|
public Encoder()
protected void writeObject(Object o)
public void setExceptionListener(ExceptionListener listener)
ExceptionListener
instance to be used for reporting
recorable exceptions in the instantiation and initialization sequence. If
the argument is null
a default instance will be used that
prints the thrown exception to System.err
.public ExceptionListener getExceptionListener()
ExceptionListener
instance.public PersistenceDelegate getPersistenceDelegate(Class<?> type)
public void setPersistenceDelegate(Class<?> type, PersistenceDelegate delegate)
PersistenceDelegate
instance for the given class.
Note: Throws a NullPointerException
if the argument is
null
.
Note: Silently ignores PersistenceDelegates for Array types and primitive wrapper classes.
Note: Although this method is not declared static
changes to
the PersistenceDelegate
s affect all
Encoder
instances. In this implementation the
access is thread safe.
public Object get(Object oldInstance)
null
if the object has not
been processed yet.
Note: The String
class acts as an endpoint for the
inherently recursive algorithm of the Encoder
. Therefore instances
of String
will always be returned by this method. In other
words the assertion:
assert (anyEncoder.get(anyString) == anyString)
Note: If null
is requested, the result will
always be null
.
public void writeStatement(Statement stmt)
Note: If you call this method not from within an object instantiation and initialization sequence it will be silently ignored.
public void writeExpression(Expression expr)
Note: If you call this method not from within an object instantiation and initialization sequence it will be silently ignored.