< prev index next >
src/java.desktop/share/classes/java/beans/Encoder.java
Print this page
*** 29,44 ****
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.Map;
/**
! * An <code>Encoder</code> is a class which can be used to create
* files or streams that encode the state of a collection of
! * JavaBeans in terms of their public APIs. The <code>Encoder</code>,
* in conjunction with its persistence delegates, is responsible for
! * breaking the object graph down into a series of <code>Statements</code>s
! * and <code>Expression</code>s which can be used to create it.
* A subclass typically provides a syntax for these expressions
* using some human readable form - like Java source code or XML.
*
* @since 1.4
*
--- 29,44 ----
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.Map;
/**
! * An {@code Encoder} is a class which can be used to create
* files or streams that encode the state of a collection of
! * JavaBeans in terms of their public APIs. The {@code Encoder},
* in conjunction with its persistence delegates, is responsible for
! * breaking the object graph down into a series of {@code Statement}s
! * and {@code Expression}s which can be used to create it.
* A subclass typically provides a syntax for these expressions
* using some human readable form - like Java source code or XML.
*
* @since 1.4
*
*** 73,88 ****
PersistenceDelegate info = getPersistenceDelegate(o == null ? null : o.getClass());
info.writeObject(o, this);
}
/**
! * Sets the exception handler for this stream to <code>exceptionListener</code>.
* The exception handler is notified when this stream catches recoverable
* exceptions.
*
* @param exceptionListener The exception handler for this stream;
! * if <code>null</code> the default exception listener will be used.
*
* @see #getExceptionListener
*/
public void setExceptionListener(ExceptionListener exceptionListener) {
this.exceptionListener = exceptionListener;
--- 73,88 ----
PersistenceDelegate info = getPersistenceDelegate(o == null ? null : o.getClass());
info.writeObject(o, this);
}
/**
! * Sets the exception handler for this stream to {@code exceptionListener}.
* The exception handler is notified when this stream catches recoverable
* exceptions.
*
* @param exceptionListener The exception handler for this stream;
! * if {@code null} the default exception listener will be used.
*
* @see #getExceptionListener
*/
public void setExceptionListener(ExceptionListener exceptionListener) {
this.exceptionListener = exceptionListener;
*** 230,242 ****
Expression exp = bindings.remove(oldInstance);
return getValue(exp);
}
/**
! * Returns a tentative value for <code>oldInstance</code> in
* the environment created by this stream. A persistence
! * delegate can use its <code>mutatesTo</code> method to
* determine whether this value may be initialized to
* form the equivalent object at the output or whether
* a new object must be instantiated afresh. If the
* stream has not yet seen this value, null is returned.
*
--- 230,242 ----
Expression exp = bindings.remove(oldInstance);
return getValue(exp);
}
/**
! * Returns a tentative value for {@code oldInstance} in
* the environment created by this stream. A persistence
! * delegate can use its {@code mutatesTo} method to
* determine whether this value may be initialized to
* form the equivalent object at the output or whether
* a new object must be instantiated afresh. If the
* stream has not yet seen this value, null is returned.
*
*** 276,298 ****
newExp.loader = oldExp.loader;
return newExp;
}
/**
! * Writes statement <code>oldStm</code> to the stream.
! * The <code>oldStm</code> should be written entirely
* in terms of the callers environment, i.e. the
* target and all arguments should be part of the
* object graph being written. These expressions
* represent a series of "what happened" expressions
* which tell the output stream how to produce an
* object graph like the original.
* <p>
* The implementation of this method will produce
* a second expression to represent the same expression in
* an environment that will exist when the stream is read.
! * This is achieved simply by calling <code>writeObject</code>
* on the target and all the arguments and building a new
* expression with the results.
*
* @param oldStm The expression to be written to the stream.
*/
--- 276,298 ----
newExp.loader = oldExp.loader;
return newExp;
}
/**
! * Writes statement {@code oldStm} to the stream.
! * The {@code oldStm} should be written entirely
* in terms of the callers environment, i.e. the
* target and all arguments should be part of the
* object graph being written. These expressions
* represent a series of "what happened" expressions
* which tell the output stream how to produce an
* object graph like the original.
* <p>
* The implementation of this method will produce
* a second expression to represent the same expression in
* an environment that will exist when the stream is read.
! * This is achieved simply by calling {@code writeObject}
* on the target and all the arguments and building a new
* expression with the results.
*
* @param oldStm The expression to be written to the stream.
*/
*** 311,324 ****
/**
* The implementation first checks to see if an
* expression with this value has already been written.
* If not, the expression is cloned, using
! * the same procedure as <code>writeStatement</code>,
* and the value of this expression is reconciled
* with the value of the cloned expression
! * by calling <code>writeObject</code>.
*
* @param oldExp The expression to be written to the stream.
*/
public void writeExpression(Expression oldExp) {
// System.out.println("Encoder::writeExpression: " + oldExp);
--- 311,324 ----
/**
* The implementation first checks to see if an
* expression with this value has already been written.
* If not, the expression is cloned, using
! * the same procedure as {@code writeStatement},
* and the value of this expression is reconciled
* with the value of the cloned expression
! * by calling {@code writeObject}.
*
* @param oldExp The expression to be written to the stream.
*/
public void writeExpression(Expression oldExp) {
// System.out.println("Encoder::writeExpression: " + oldExp);
< prev index next >