edu.neu.ccs.codec
Interface Codec

All Known Implementing Classes:
CountPrefixCodec, EscapedCodec

public interface Codec

Interface describing the required functionality of a class of objects whose instances can be used to encode and decode data Strings using a recursively-enabled data language.

In short, an class implementing this interface must be able to encode an array of data Strings into a single, compound data String that can later be decoded back to the original array of data Strings. Implementation details such as the encoding scheme, compression ratio, or information loss, are specific to a class that implements this interface.

A CODEC class may only be used after an instance of the class has been installed using the CodecUtilities.installCodec(Codec) method. The standard CODECs provided by the JPT, whose CODEC identifiers are "CPC" and "ESC", and are defined in classes CountPrefixCodec and EscapedCodec respectively, are installed by default by the JPT, and may be used at any time.

Since:
1.0
Version:
2.2
See Also:
CodecUtilities

Method Summary
 String[] decode(String data)
          Decodes the given compound data String into an array of data Strings using the encoding scheme for this class.
 String encode(String[] data)
          Encodes the given array of data Strings into a single compound data String using the encoding scheme for this class.
 String getPrefix()
          Returns the unique three character prefix used to identify the encoding scheme for this class
 

Method Detail

encode

public String encode(String[] data)
Encodes the given array of data Strings into a single compound data String using the encoding scheme for this class.

Parameters:
data - an array of data Strings
Returns:
the resulting encoded String
See Also:
decode(String), CodecUtilities.encode(String[]), CodecUtilities.encode(Stringable[])

decode

public String[] decode(String data)
                throws ParseException
Decodes the given compound data String into an array of data Strings using the encoding scheme for this class.

Parameters:
data - an encoded data String
Returns:
the resulting array of data Strings
Throws:
ParseException - if the data was not encoded using this scheme
See Also:
encode(String[]), CodecUtilities.decode(String)

getPrefix

public String getPrefix()
Returns the unique three character prefix used to identify the encoding scheme for this class