java.lang.Object | |
↳ | java.beans.Encoder |
![]() |
An 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 Encoder
,
in conjunction with its persistence delegates, is responsible for
breaking the object graph down into a series of Statements
s
and 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.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns a tentative value for
oldInstance in
the environment created by this stream. | |||||||||||
Gets the exception handler for this stream.
| |||||||||||
Returns the persistence delegate for the given type.
| |||||||||||
Removes the entry for this instance, returning the old entry.
| |||||||||||
Sets the exception handler for this stream to
exceptionListener . | |||||||||||
Sets the persistence delegate associated with this
type to
persistenceDelegate . | |||||||||||
The implementation first checks to see if an
expression with this value has already been written.
| |||||||||||
Writes statement
oldStm to the stream. |
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Write the specified object to the output stream.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Returns a tentative value for oldInstance
in
the environment created by this stream. A persistence
delegate can use its 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.
oldInstance | The instance to be looked up. |
---|
Gets the exception handler for this stream.
Returns the persistence delegate for the given type. The persistence delegate is calculated by applying the following of rules in order:
BeanDescriptor
which defined a "persistenceDelegate" property, this
value is returned.
ConstructorProperties
annotation.
If none of the constructors have the ConstructorProperties
annotation,
then the nullary constructor (constructor with no parameters) will be used.
For example, in the following the nullary constructor
for Foo
will be used, while the two parameter constructor
for Bar
will be used.
public class Foo {
public Foo() { ... }
public Foo(int x) { ... }
}
public class Bar {
public Bar() { ... }
@ConstructorProperties({"x"})
public Bar(int x) { ... }
@ConstructorProperties({"x", "y"})
public Bar(int x, int y) { ... }
}
type | The type of the object. |
---|
Removes the entry for this instance, returning the old entry.
oldInstance | The entry that should be removed. |
---|
Sets the exception handler for this stream to exceptionListener
.
The exception handler is notified when this stream catches recoverable
exceptions.
exceptionListener | The exception handler for this stream;
if null the default exception listener will be used. |
---|
Sets the persistence delegate associated with this type
to
persistenceDelegate
.
type | The class of objects that persistenceDelegate applies to. |
---|---|
persistenceDelegate | The persistence delegate for instances of type . |
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 writeStatement
,
and the value of this expression is reconciled
with the value of the cloned expression
by calling writeObject
.
oldExp | The expression to be written to the stream. |
---|
Writes statement oldStm
to the stream.
The 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.
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 writeObject
on the target and all the arguments and building a new
expression with the results.
oldStm | The expression to be written to the stream. |
---|
Write the specified object to the output stream. The serialized form will denote a series of expressions, the combined effect of which will create an equivalent object when the input stream is read. By default, the object is assumed to be a JavaBean with a nullary constructor, whose state is defined by the matching pairs of "setter" and "getter" methods returned by the Introspector.
o | The object to be written to the stream. |
---|