public abstract class IDataCoder
extends java.lang.Object
This class is used to store and fetch IData objects to and from disk into a format specified by the derived class.
Note: If you extend this class, you must implement the following methods: decode, encode and getContentType.
Coder
,
IDataXMLCoder
,
IData
Constructor and Description |
---|
IDataCoder() |
Modifier and Type | Method and Description |
---|---|
abstract IData |
decode(java.io.InputStream is)
Decodes the data in the specified InputStream to an IData object.
|
IData |
decodeFromBytes(byte[] b)
Decodes the data in the specified byte [] to an IData object.
|
abstract void |
encode(java.io.OutputStream os,
IData data)
Encodes the contents of a specified IData object and writes the encoded data to an
OutputStream.
|
byte[] |
encodeToBytes(IData data)
Encodes the specified IData object and writes the encoded data to a byte [].
|
abstract java.lang.String |
getContentType()
Returns a String containing the name of the content type that is in use by this instance
of IDataCoder.
|
IData |
readFromFile(java.io.File f)
Decodes the contents of the specified File and puts it in an IData object.
|
void |
writeToFile(java.io.File f,
IData v)
Encodes the specified IData object and writes the encoded data to a file.
|
public abstract IData decode(java.io.InputStream is) throws java.io.IOException, InvalidDatatypeException
Note: If you extend this class, you must implement this method.
is
- The InputStream that this method will decode. The data in this object must be
encoded in the way that your implementation of decode expects.java.io.IOException
- If an error occurs while reading the InputStream or writing to the
IData object.InvalidDatatypeException
- If the content of InputStream cannot an be properly
parsed and decoded.decodeFromBytes(byte[])
,
readFromFile(java.io.File)
public IData decodeFromBytes(byte[] b) throws java.io.IOException
b
- The byte [] that contains that data that this method will decode.java.io.IOException
- If an error occurs while reading the byte [], parsing its contents, or
writing to the IData object.decode(java.io.InputStream)
,
readFromFile(java.io.File)
public abstract void encode(java.io.OutputStream os, IData data) throws java.io.IOException, InvalidDatatypeException
os
- The OutputStream to which you want the encoded data written.data
- The IData object whose data you want to encode.java.io.IOException
- If an error occurs while reading data from the IData object or writing
data to the OutputStream.InvalidDatatypeException
- If the data in the IData object cannot be encoded (i.e.,
the IData object contains an object type that is not supported by the specific
implementation of encode that you are using).encodeToBytes(com.wm.data.IData)
,
writeToFile(java.io.File, com.wm.data.IData)
public byte[] encodeToBytes(IData data) throws java.io.IOException
data
- The IData object whose data you want to encode.java.io.IOException
- If an error occurs while reading data from the IData object or writing
data to the byte [].encode(java.io.OutputStream, com.wm.data.IData)
,
writeToFile(java.io.File, com.wm.data.IData)
public abstract java.lang.String getContentType()
public IData readFromFile(java.io.File f) throws java.io.IOException
f
- A File representing the file that you want to decode. (The data in the file must
be encoded in the way that the specific implementation of decode that you are using
expects.)java.io.IOException
- If an error occurs while reading data from the file, parsing its contents, or
writing it to the IData object.decode(java.io.InputStream)
,
decodeFromBytes(byte[])
,
writeToFile(java.io.File, com.wm.data.IData)
public void writeToFile(java.io.File f, IData v) throws java.io.IOException
f
- A File representing the file to which you want the encoded data written. If this
file does not exist, it will be created. If the file already exists, it will be overwritten.v
- The IData object whose data you want to encode.java.io.IOException
- If an error occurs while reading data from the IData object or writing
data to the file.encode(java.io.OutputStream, com.wm.data.IData)
,
encodeToBytes(com.wm.data.IData)
,
\