|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.wm.util.coder.IDataCoder
public abstract class IDataCoder
This class is an abstract class that contains methods for transforming an encoded set of data to an IData object. You can extend this class to define a derived class that specifies the format and the content type to decode a file, byte array or an InputStream into an IData object and to encode an IData object into a file, byte array or OutputStream.
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 Summary | |
---|---|
IDataCoder()
|
Method Summary | |
---|---|
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 Coder. |
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public IDataCoder()
Method Detail |
---|
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)
,
\
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |