java.beans
Class Encoder

java.lang.Object
  extended by java.beans.Encoder
Direct Known Subclasses:
XMLEncoder

public class Encoder
extends Object

Since:
1.4

Constructor Summary
Encoder()
           
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Encoder

public Encoder()
Method Detail

writeObject

protected void writeObject(Object o)

setExceptionListener

public void setExceptionListener(ExceptionListener listener)
Sets the 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.


getExceptionListener

public ExceptionListener getExceptionListener()
Returns the currently active ExceptionListener instance.


getPersistenceDelegate

public PersistenceDelegate getPersistenceDelegate(Class<?> type)

setPersistenceDelegate

public void setPersistenceDelegate(Class<?> type,
                                   PersistenceDelegate delegate)
Sets the 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 PersistenceDelegates affect all Encoder instances. In this implementation the access is thread safe.


remove

public Object remove(Object oldInstance)

get

public 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.

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.


writeStatement

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.


writeExpression

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.