|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectwjhk.jupload2.upload.helper.ByteArrayEncoderHTTP
public class ByteArrayEncoderHTTP
This class is a utility, which provide easy encoding for HTTP queries. The way to use this class is:
| Field Summary | |
|---|---|
private java.io.ByteArrayOutputStream |
baos
The actual array, which will collect the encoded bytes. |
private java.lang.String |
bound
The boundary, to put between to post variables. |
private boolean |
closed
Indicate whether the encoder is closed or not. |
private static java.lang.String |
DEFAULT_ENCODING
The default encoding. |
private byte[] |
encodedByteArray
The encoded byte array. |
private int |
encodedLength
The byte array length. |
private java.lang.String |
encoding
The current encoding. |
private UploadPolicy |
uploadPolicy
The current upload policy. |
private java.io.Writer |
writer
The writer, that will encode the input parameters to baos. |
| Constructor Summary | |
|---|---|
ByteArrayEncoderHTTP(UploadPolicy uploadPolicy,
java.lang.String bound)
Create an encoder, using the DEFAULT_ENCODING encoding. |
|
ByteArrayEncoderHTTP(UploadPolicy uploadPolicy,
java.lang.String encoding,
java.lang.String bound)
Create an encoder, and specifies the encoding to use. |
|
| Method Summary | |
|---|---|
ByteArrayEncoder |
append(byte[] b)
Append a stream, to be encoded at the current end of the byte array. |
ByteArrayEncoder |
append(ByteArrayEncoder bae)
Append a string, to be encoded at the current end of the byte array. |
ByteArrayEncoder |
append(java.lang.String str)
Append a string, to be encoded at the current end of the byte array. |
ByteArrayEncoder |
appendFileProperty(java.lang.String name,
java.lang.String value)
Append a property, name and value. |
ByteArrayEncoder |
appendFormVariables(java.lang.String formname)
Add to the current encoder all properties contained in the given HTML form. |
void |
close()
Closes the encoding writer, and prepares the encoded length and byte array. |
static java.lang.String |
getDefaultEncoding()
* |
byte[] |
getEncodedByteArray()
Get the encoded result. |
int |
getEncodedLength()
Get the length of the encoded result. |
java.lang.String |
getEncoding()
|
java.lang.String |
getString()
Get the String that matches the encoded result. |
private void |
init(UploadPolicy uploadPolicy,
java.lang.String encoding,
java.lang.String bound)
Initialization: called by the constructors. |
boolean |
isClosed()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final java.lang.String DEFAULT_ENCODING
getDefaultEncoding().
private java.lang.String bound
private java.lang.String encoding
private boolean closed
private java.io.ByteArrayOutputStream baos
private int encodedLength
private byte[] encodedByteArray
private UploadPolicy uploadPolicy
private java.io.Writer writer
baos.
| Constructor Detail |
|---|
public ByteArrayEncoderHTTP(UploadPolicy uploadPolicy,
java.lang.String bound)
throws JUploadIOException
uploadPolicy - The current upload policybound - The HTTP boundary. Can be null, if not used.
JUploadIOException - Any IO exception
public ByteArrayEncoderHTTP(UploadPolicy uploadPolicy,
java.lang.String encoding,
java.lang.String bound)
throws JUploadIOException
uploadPolicy - The current upload policyencoding - The encoding to use. For instance, "UTF-8".bound - The HTTP boundary. Can be null, if not used.
JUploadIOException - Any IO exception| Method Detail |
|---|
public void close()
throws JUploadIOException
ByteArrayEncoderByteArrayEncoder.getEncodedLength() and ByteArrayEncoder.getEncodedByteArray(). Note:
After a call to this method, you can not append any new data to the
encoder.
close in interface ByteArrayEncoderJUploadIOExceptionByteArrayEncoder.close()
public ByteArrayEncoder append(java.lang.String str)
throws JUploadIOException
append in interface ByteArrayEncoderstr - The string to append and encode.
JUploadIOException
public ByteArrayEncoder append(byte[] b)
throws JUploadIOException
append in interface ByteArrayEncoderJUploadIOException
public ByteArrayEncoder append(ByteArrayEncoder bae)
throws JUploadIOException
append in interface ByteArrayEncoderbae - The ByteArrayEncoder whose encoding result should be appended
to the current encoder. bae must be closed, before being
appended.
JUploadIOException - This exception is thrown when this method is
called on a non-closed encoder.
public ByteArrayEncoder appendFileProperty(java.lang.String name,
java.lang.String value)
throws JUploadIOException
appendFileProperty in interface ByteArrayEncodername - Name of the property to be addedvalue - Value of this property for the current file. It's up to the
caller to call this method at the right time.
JUploadIOException
public ByteArrayEncoder appendFormVariables(java.lang.String formname)
throws JUploadIOException
appendFormVariables in interface ByteArrayEncoderformname - The HTML form name. This method will get the data from
this form, by using the UploadPolicy.getApplet()
method.
JUploadIOExceptionpublic static java.lang.String getDefaultEncoding()
public boolean isClosed()
isClosed in interface ByteArrayEncoderpublic java.lang.String getEncoding()
getEncoding in interface ByteArrayEncoder
public int getEncodedLength()
throws JUploadIOException
getEncodedLength in interface ByteArrayEncoderJUploadIOException - This exception is thrown when this method is
called on a non-closed encoder.
public byte[] getEncodedByteArray()
throws JUploadIOException
getEncodedByteArray in interface ByteArrayEncoderJUploadIOException - This exception is thrown when this method is
called on a non-closed encoder.
public java.lang.String getString()
throws JUploadIOException
getString in interface ByteArrayEncoderJUploadIOException - This exception is thrown when this method is
called on a non-closed encoder.
private void init(UploadPolicy uploadPolicy,
java.lang.String encoding,
java.lang.String bound)
throws JUploadIOException
JUploadIOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||