edu.neu.ccs.codec
Class CountPrefixCodec

java.lang.Object
  extended byedu.neu.ccs.codec.CountPrefixCodec
All Implemented Interfaces:
Codec, Serializable

public class CountPrefixCodec
extends Object
implements Codec, Serializable

CODEC implementation whose encoding scheme prefixes data with character and element counts. This CODEC does not make use of data compression, and does not result in any data loss. This CODEC produces encoded data that is easily readable at low levels of recursion, but is often difficult to read at high levels of recursion.

The unique three letter identifier for this CODEC is "CPC". This CODEC is automatically installed by the JPT, and is the deafult CODEC for use with the JPT.

Since:
1.0
Version:
2.2
See Also:
CodecUtilities, Serialized Form

Constructor Summary
CountPrefixCodec()
          Constructs an object capable of encoding and decoding data using the "Count-prefix" encoding scheme.
 
Method Summary
 String[] decode(String data)
          Decodes the given compound data String into an array of data Strings using the "Count-prefix" encoding scheme.
 String encode(String[] data)
          Encodes the given array of data Strings into a single compound data String using the "Count-prefix" encoding scheme.
 String getPrefix()
          Returns the unique identifier for this encoding scheme: the String "CPC".
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CountPrefixCodec

public CountPrefixCodec()
Constructs an object capable of encoding and decoding data using the "Count-prefix" encoding scheme.

Method Detail

encode

public String encode(String[] data)
Encodes the given array of data Strings into a single compound data String using the "Count-prefix" encoding scheme.

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

decode

public String[] decode(String data)
                throws ParseException
Decodes the given compound data String into an array of data Strings using the "Count-prefix" encoding scheme.

Specified by:
decode in interface Codec
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), Codec

getPrefix

public String getPrefix()
Returns the unique identifier for this encoding scheme: the String "CPC".

Specified by:
getPrefix in interface Codec
See Also:
CodecUtilities.installCodec(Codec), CodecUtilities.getDefaultCodec(), Codec