public class ByteArrayEncoderHTTP extends Object implements ByteArrayEncoder
Constructor and Description |
---|
ByteArrayEncoderHTTP(UploadPolicy uploadPolicy)
Create an encoder, using the DEFAULT_ENCODING encoding.
|
ByteArrayEncoderHTTP(UploadPolicy uploadPolicy,
String bound)
Create an encoder, and specifies the encoding to use.
|
ByteArrayEncoderHTTP(UploadPolicy uploadPolicy,
String bound,
String encoding)
Create an encoder, and specifies the boundary and encoding to use.
|
Modifier and Type | Method and Description |
---|---|
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(String str)
Append a string, to be encoded at the current end of the byte array.
|
ByteArrayEncoder |
appendEndPropertyList()
Finish a property list.
|
ByteArrayEncoder |
appendFormVariables(String formname)
Add to the current encoder all properties contained in the given HTML
form.
|
ByteArrayEncoder |
appendTextProperty(String name,
String value,
int index)
Append a property, name and value.
|
void |
close()
Closes the encoding writer, and prepares the encoded length and byte
array.
|
String |
getBoundary()
Gets the HTTP boundary, that separate the form variables.
|
static String |
getDefaultEncoding() |
byte[] |
getEncodedByteArray()
Get the encoded result.
|
int |
getEncodedLength()
Get the length of the encoded result.
|
String |
getEncoding() |
String |
getString()
Get the String that matches the encoded result.
|
boolean |
isClosed() |
public ByteArrayEncoderHTTP(UploadPolicy uploadPolicy) throws JUploadIOException
uploadPolicy
- The current upload policyJUploadIOException
- Any IO exceptionpublic ByteArrayEncoderHTTP(UploadPolicy uploadPolicy, 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 exceptionpublic ByteArrayEncoderHTTP(UploadPolicy uploadPolicy, String bound, 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 exceptionpublic void close() throws JUploadIOException
ByteArrayEncoder
ByteArrayEncoder.getEncodedLength()
and ByteArrayEncoder.getEncodedByteArray()
.
Note: After a call to this method, you can not append any new data
to the encoder.close
in interface ByteArrayEncoder
JUploadIOException
ByteArrayEncoder.close()
public ByteArrayEncoder append(String str) throws JUploadIOException
append
in interface ByteArrayEncoder
str
- The string to append and encode.JUploadIOException
public ByteArrayEncoder append(int b) throws JUploadIOException
append
in interface ByteArrayEncoder
b
- Writes the specified byte to this output stream.JUploadIOException
public ByteArrayEncoder append(byte[] b) throws JUploadIOException
append
in interface ByteArrayEncoder
JUploadIOException
public ByteArrayEncoder append(ByteArrayEncoder bae) throws JUploadIOException
append
in interface ByteArrayEncoder
bae
- 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(String name, String value, int index) 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 ByteArrayEncoder
name
- 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.index
- Index of the file concerned by this value. -1 if this is a
global parameter.JUploadIOException
ByteArrayEncoder.appendEndPropertyList()
public ByteArrayEncoder appendEndPropertyList() throws JUploadIOException
appendEndPropertyList
in interface ByteArrayEncoder
JUploadIOException
public ByteArrayEncoder appendFormVariables(String formname) throws JUploadIOException
ByteArrayEncoder.appendTextProperty(String, String, int)
.appendFormVariables
in interface ByteArrayEncoder
formname
- The HTML form name. This method will get the data from
this form, by using the JUploadContext.getApplet()
method.JUploadIOException
public String getBoundary()
getBoundary
in interface ByteArrayEncoder
public static String getDefaultEncoding()
public boolean isClosed()
isClosed
in interface ByteArrayEncoder
public String getEncoding()
getEncoding
in interface ByteArrayEncoder
public int getEncodedLength() throws JUploadIOException
getEncodedLength
in interface ByteArrayEncoder
JUploadIOException
- This exception is thrown when this method is
called on a non-closed encoder.public byte[] getEncodedByteArray() throws JUploadIOException
getEncodedByteArray
in interface ByteArrayEncoder
JUploadIOException
- This exception is thrown when this method is
called on a non-closed encoder.public String getString() throws JUploadIOException
getString
in interface ByteArrayEncoder
JUploadIOException
- This exception is thrown when this method is
called on a non-closed encoder.Copyright © 2015. All rights reserved.