uk.org.blankaspect.nlf
Interface Chunk.Encoder

All Known Implementing Classes:
Chunk.Base64Encoder
Enclosing class:
Chunk

public static interface Chunk.Encoder

This interface specifies the methods that must be implemented by a class that encodes chunk data as character data for use as a text node of an XML file. The encoder is used by the chunk's toXml(org.w3c.dom.Document) method.

Since:
1.0
See Also:
Chunk.getEncoder(), Chunk.setEncoder(Chunk.Encoder)

Method Summary
 java.lang.String encode(byte[] data, int offset, int length, boolean endOfInput)
          Encodes the specified byte data as a string.
 int getInputLength(long size)
          Returns the length of a block of input data that the encode method expects to receive.
 void reset()
          Resets the chunk encoder before any encoding is performed.
 

Method Detail

reset

void reset()
Resets the chunk encoder before any encoding is performed.

Since:
1.0

getInputLength

int getInputLength(long size)
Returns the length of a block of input data that the encode method expects to receive. A value of zero indicates that the encode method will accept a block of any length.

Parameters:
size - the size of the chunk data.
Returns:
the length of a block of input data that the encode method expects to receive; 0, if the encode method will accept a block of any length.
Since:
1.0

encode

java.lang.String encode(byte[] data,
                        int offset,
                        int length,
                        boolean endOfInput)
                        throws java.lang.IllegalArgumentException
Encodes the specified byte data as a string. When the encoder is used by the chunk's toXml(org.w3c.dom.Document) method, this method will be called on successive blocks of the chunk data.

Parameters:
data - the data that are to be encoded.
offset - the offset to data at which the input data begin.
length - the length of the input data.
endOfInput - true if the input data are the last that are to be encoded; false otherwise.
Returns:
the string that results from encoding the input data.
Throws:
java.lang.IllegalArgumentException - if
  • any of the arguments are invalid, or
  • the input data are malformed or otherwise illegal.
Since:
1.0