|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.yenc.YEncDecoder
Decodes data encoded with yEnc (http://www.yencode.org). It supports both single and multipart archives. The method to decode the files is the following:
For single part archives:
setInputStream(InputStream)
.setOutputStream(OutputStream)
.decode()
.For multi part archives:
setOutputStream(OutputStream)
.setInputStream(InputStream, false)
.decode()
.org.yenc.ydecode.sortFiles(YEncDecoder, String[])
.
Note that this class is not synchronized.
setInputStream(InputStream)
,
setInputStream(InputStream, boolean)
,
setOutputStream(OutputStream)
,
decode()
,
ydecode.sortFiles(YEncDecoder, String[])
Field Summary | |
int |
MAX_LENGTH
Maximum line length allowed |
Constructor Summary | |
YEncDecoder()
Creates a new instance which can read lines up to 1024 characters of length. |
|
YEncDecoder(int maxlength)
Creates a new instance which can read lines up to maxlength characters of length. |
Method Summary | |
boolean |
debugMessages()
Returns if debug messages are enabled or not. |
void |
debugMessages(boolean enable)
Enables or disables debugging messages to System.out . |
void |
decode()
Read encoded data from the stream set with setInputStream and writes decoded
data to the stream set with setOutputStream . |
protected boolean |
decodeNext()
Decodes the next character. |
java.lang.String |
getFileName()
Returns the filename set in the header. |
int |
getLineNumber()
Returns the actual line number. |
int |
getPartBegin()
Returns the beginning offset of the current part. |
int |
getPartEnd()
Returns the ending offset of the current part. |
int |
getPartNumber()
Returns the current part number set in the header. |
protected boolean |
getProperty(java.lang.String s)
|
long |
getSize()
Returns the file size set in the header. |
int |
getTotalParts()
Returns the total parts number set in the header. |
boolean |
isMultiPart()
Returns true if the current input stream is a
multipart archive. |
protected void |
processHeader(java.util.StringTokenizer tokenizer)
|
protected void |
processHeaderArg(java.util.StringTokenizer tokenizer)
Process the next parameter from the header. |
protected void |
processPart(java.util.StringTokenizer tokenizer)
|
protected void |
processPartArg()
Process the next parameter from the part header. |
protected void |
processTrailer(java.util.StringTokenizer tokenizer)
|
protected void |
processTrailerArg()
Process the next parameter from the trailer. |
protected boolean |
readNextLine(boolean skip)
Reads the next line from the input stream. |
void |
reset()
Resets the instance internal state. |
void |
reset(boolean resetcrc)
Resets the instance internal state. |
void |
setInputStream(java.io.InputStream in)
Sets the input stream from which encoded data is read. |
void |
setInputStream(java.io.InputStream in,
boolean isNextPart)
Sets the input stream from which encoded data is read. |
void |
setOutputStream(java.io.OutputStream out)
Sets the input stream to which decoded data is written. |
protected java.lang.Integer |
strToInt(java.lang.String s,
java.lang.String name)
Converts the string s to an Integer . |
protected java.lang.Long |
strToLong(java.lang.String s,
int radix,
java.lang.String name)
Converts the string s to a Long in the
specified radix. |
protected java.lang.Long |
strToLong(java.lang.String s,
java.lang.String name)
Calls strToLong() with radix equal to 10. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public int MAX_LENGTH
Constructor Detail |
public YEncDecoder()
public YEncDecoder(int maxlength)
maxlength
characters of length.Method Detail |
public void reset()
reset(true)
.reset(boolean)
public void reset(boolean resetcrc)
resetcrc
is true
, then the CRC computed so far is
also reset.protected boolean getProperty(java.lang.String s)
protected java.lang.Integer strToInt(java.lang.String s, java.lang.String name) throws InvalidParameterException
s
to an Integer
. In
case an error occurs, a YEncException
will be thrown
using name
as part of the exception message.protected java.lang.Long strToLong(java.lang.String s, java.lang.String name) throws InvalidParameterException
strToLong()
with radix equal to 10.strToLong(String, int, String)
protected java.lang.Long strToLong(java.lang.String s, int radix, java.lang.String name) throws InvalidParameterException
s
to a Long
in the
specified radix. In case an error occurs, a
YEncException
will be thrown using name
as part of the exception message.protected void processHeaderArg(java.util.StringTokenizer tokenizer) throws InvalidParameterException
getProperty(String)
must be made before calling this
method. The tokenizer is needed as the filename parameter eats up
everything from the parameter definition till the end of the line.protected void processHeader(java.util.StringTokenizer tokenizer) throws InvalidParameterException, MissingParameterException
protected void processTrailerArg() throws InvalidParameterException
getProperty(String)
must be made before calling this
method.protected void processTrailer(java.util.StringTokenizer tokenizer) throws InvalidParameterException, MissingParameterException
protected void processPartArg() throws InvalidParameterException
getProperty(String)
must be made before calling this
method.protected void processPart(java.util.StringTokenizer tokenizer) throws java.io.IOException, InvalidParameterException, MissingParameterException
protected boolean readNextLine(boolean skip) throws java.io.IOException, YEncException
MAX_LENGTH
bytes. The line terminator is "CR*LF" (actually,
the CRs are ignored and LF is the line terminator).skip
is true
, it returns a line with encoded
data or with a header, everything else is skipped. The skipped lines are not
subject to the maximum line length mentioned above; i.e., all headers and
encoded data lines' length must be less than MAX_LENGTH
but
the rest of the lines can be of any length.MAX_LENGTH
protected boolean decodeNext() throws java.io.IOException, YEncException
false
when EOF is
found.public void decode() throws java.io.IOException, YEncException
setInputStream
and writes decoded
data to the stream set with setOutputStream
. If you haven't used those two
methods mentioned to set the input/output streams before calling this method, it
will fail.setInputStream(InputStream)
,
setOutputStream(OutputStream)
public void debugMessages(boolean enable)
System.out
.public boolean debugMessages()
public java.lang.String getFileName() throws java.io.IOException, YEncException
null
.public long getSize() throws java.io.IOException, YEncException
public int getPartNumber() throws java.io.IOException, YEncException
public int getTotalParts() throws java.io.IOException, YEncException
public boolean isMultiPart() throws java.io.IOException, YEncException
true
if the current input stream is a
multipart archive.public int getPartBegin() throws java.io.IOException, YEncException
public int getPartEnd() throws java.io.IOException, YEncException
public int getLineNumber()
public void setInputStream(java.io.InputStream in)
setInputStream(InputStream, false)
.setInputStream(InputStream, boolean)
public void setInputStream(java.io.InputStream in, boolean isNextPart)
isNextPart
determines whether the new input stream is
a new archive or the next part for the previous stream.public void setOutputStream(java.io.OutputStream out)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |