Package wt.util
Class Encoder
java.lang.Object
wt.util.Encoder
The
Encoder class provides methods to encode and decode serializable objects to and
from character strings. It provides static convenience methods to encode and decode a
single serializable object to and from a character string. Instances of Encoder
can be used to efficiently reuse a single java.io.ObjectInputStream or
java.io.ObjectOutputStream to read and write many character strings or
byte streams. The encoding scheme is considered an internal property of the
encoder, but is guaranteed to be a subset of ASCII characters such as Base64-encoding.
A duplicate of this class exists as wt.pds.PDSEncoder where the object input and
object output streams implement wt.pds.PDSObjectInput and wt.pds.PDSObjectOutput
interfaces. These are tagging interfaces used by some Windchill classes to identify when they are being
serialized for long term (persistent) storage. If serializing objects for persistent storage,
that class should be used.
NOTE: This class duplicates code that exists in wt.pds.PDSEncoder. Any changes to
this class should be reflected there as well.
Supported API: true
Extendable: false
-
Method Summary
Modifier and TypeMethodDescriptionstatic SerializableProduces a serializable object from the encoded string argument.static Stringencode(Serializable obj) Produces an encoded string from an object argument.setInput(InputStream in) Set a input stream to read next object stream.Set a string to read next encoded object stream.setOutput(OutputStream out) Set a output stream to receive the next object stream.setOutput(StringBuffer buf) Set a string buffer to receive the next encoded object stream.
-
Method Details
-
encode
Produces an encoded string from an object argument. The object must be Serializable. A transientEncoderobject is constructed to perform the serialization.
Supported API: true- Parameters:
obj- Serializable object to be encoded- Returns:
- String serialization of the object
- Throws:
IOException
-
decode
Produces a serializable object from the encoded string argument.
Supported API: true- Parameters:
str- encoded string returned by encode operation- Returns:
- Serializable object
- Throws:
IOExceptionClassNotFoundException
-
setOutput
Set a string buffer to receive the next encoded object stream.
Supported API: true- Parameters:
buf- theStringBuffer- Returns:
- the
ObjectOutputStreamfor writing to this buffer - Throws:
IOException
-
setOutput
Set a output stream to receive the next object stream.
Supported API: true- Parameters:
out- theOutputStream- Returns:
- the
ObjectOutputStreamfor writing to this byte stream - Throws:
IOException
-
setInput
Set a string to read next encoded object stream.
Supported API: true- Parameters:
str- theString- Returns:
- the
ObjectInputStreamfor reading this string - Throws:
IOException
-
setInput
Set a input stream to read next object stream.
Supported API: true- Parameters:
in- theInputStream- Returns:
- the
ObjectInputStreamfor reading this stream - Throws:
IOException
-