|
||||||||||
| 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)
Create an encoder, using the DEFAULT_ENCODING encoding. |
|
ByteArrayEncoderHTTP(UploadPolicy uploadPolicy,
java.lang.String bound)
Create an encoder, and specifies the encoding to use. |
|
ByteArrayEncoderHTTP(UploadPolicy uploadPolicy,
java.lang.String bound,
java.lang.String encoding)
Create an encoder, and specifies the boundary and 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(int b)
Append a byte, to be encoded at the current end of the byte array. he byte to be written is the eight low-order bits of the argument b. |
ByteArrayEncoder |
append(java.lang.String str)
Append a string, to be encoded at the current end of the byte array. |
ByteArrayEncoder |
appendEndPropertyList()
Finish a property list. |
ByteArrayEncoder |
appendFormVariables(java.lang.String formname)
Add to the current encoder all properties contained in the given HTML form. |
ByteArrayEncoder |
appendTextProperty(java.lang.String name,
java.lang.String value)
Append a property, name and value. |
void |
close()
Closes the encoding writer, and prepares the encoded length and byte array. |
java.lang.String |
getBoundary()
Gets the HTTP boundary, that separate the form variables. |
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 bound,
java.lang.String encoding)
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)
throws JUploadIOException
uploadPolicy - The current upload policy
JUploadIOException - Any IO exception
public ByteArrayEncoderHTTP(UploadPolicy uploadPolicy,
java.lang.String bound)
throws JUploadIOException
uploadPolicy - The current upload policybound - Any specific boundary. May be null: in this case a default
boundary is used.
JUploadIOException - Any IO exception
public ByteArrayEncoderHTTP(UploadPolicy uploadPolicy,
java.lang.String bound,
java.lang.String encoding)
throws JUploadIOException
uploadPolicy - The current upload policybound - Any specific boundary. May be null: in this case a default
boundary is used.encoding - The encoding to use. For instance, "UTF-8".
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(int b)
throws JUploadIOException
append in interface ByteArrayEncoderb - Writes the specified byte to this output stream.
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 appendTextProperty(java.lang.String name,
java.lang.String value)
throws JUploadIOException
ByteArrayEncoder.appendEndPropertyList(), to properly finish the property list.
In HTTP mode, it will add the last boundary, at a specific format.
appendTextProperty 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.
JUploadIOExceptionByteArrayEncoder.appendEndPropertyList()
public ByteArrayEncoder appendEndPropertyList()
throws JUploadIOException
appendEndPropertyList in interface ByteArrayEncoderJUploadIOException
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 java.lang.String getBoundary()
getBoundary in interface ByteArrayEncoderpublic 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 bound,
java.lang.String encoding)
throws JUploadIOException
JUploadIOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||