|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectuk.org.blankaspect.nlf.Chunk.Base64Encoder
public static class Chunk.Base64Encoder
This singleton class implements a Base64 encoder for chunk data. It is set as the default encoder on all general chunks (ie, chunks that do not have a reserved identifier). The length of a line of output from the encoder and the string that terminates each line can both be set on the single instance of the class. The default line length of zero means that no line separators will be appended to the encoded output.
A chunk's encoder is used by the toXml(org.w3c.dom.Document)
method to encode the chunk data as the character data of an XML element.
Chunk.Encoder
Method Summary | |
---|---|
java.lang.String |
encode(byte[] data,
int offset,
int length,
boolean endOfInput)
Encodes the specified byte data as a Base64 string. |
int |
getInputLength(long size)
Returns the length of a block of input data that the encode(byte[], int, int, boolean) method expects to receive. |
static Chunk.Base64Encoder |
getInstance()
Returns the single instance of Base64Encoder . |
int |
getLineLength()
Returns the length of a line of encoded output. |
java.lang.String |
getLineSeparator()
Returns the string that is appended to each line of encoded output. |
void |
reset()
Resets the chunk encoder before any encoding is performed: does nothing. |
void |
setLineLength(int lineLength)
Sets the length of a Base64-encoded line. |
void |
setLineSeparator(java.lang.String lineSeparator)
Sets the string that will be appended to each line of encoded output. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static Chunk.Base64Encoder getInstance()
Base64Encoder
.
Base64Encoder
.public void reset()
reset
in interface Chunk.Encoder
public int getInputLength(long size)
encode(byte[], int, int, boolean)
method expects to receive.
getInputLength
in interface Chunk.Encoder
size
- the size of the chunk data.
encode(byte[], int, int, boolean)
method expects to receive.public java.lang.String encode(byte[] data, int offset, int length, boolean endOfInput) throws java.lang.IllegalArgumentException
setLineLength(int)
and setLineSeparator(java.lang.String)
respectively.
encode
in interface Chunk.Encoder
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.
java.lang.IllegalArgumentException
- if
data
is null
, or(offset < 0)
or (offset > data.length)
, or(length < 0)
or (length > data.length - offset)
.public int getLineLength()
setLineLength(int)
public java.lang.String getLineSeparator()
setLineSeparator(String)
public void setLineLength(int lineLength) throws java.lang.IllegalArgumentException
4
.
lineLength
- the length of a Base64-encoded line, or 0
if no line separators are
to be appended to the encoded output. The length must be a multiple of
4
.
java.lang.IllegalArgumentException
- if lineLength
is negative or is not a multiple of 4
.getLineLength()
public void setLineSeparator(java.lang.String lineSeparator)
lineSeparator
- the string that is to be appended to each line of encoded output. If
lineSeparator
is null
, the line separator is set to the
value of the system property line.separator
.getLineSeparator()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |