Esri Geoportal Server
1.2.9

com.esri.gpt.agp.multipart2
Class MPart

java.lang.Object
  extended by com.esri.gpt.agp.multipart2.MPart
Direct Known Subclasses:
AgpDPart

public class MPart
extends Object

A part of an HTTP multi-part request.

Based upon Apache HttpClient 3.1: org.apache.commons.httpclient.methods.multipart


Constructor Summary
MPart()
          Default constructor.
MPart(String name, byte[] data, String fileName, String contentType, String charset)
          Constructor.
MPart(String name, String data)
          Constructor.
MPart(String name, String data, String contentType)
          Constructor.
 
Method Summary
protected  long dataLength()
          Determine the length of the part data in bytes (-1 if unknown).
protected  byte[] getAsciiBytes(String value)
          Gets the US-ASCII bytes for a value
 String getBoundary()
          Gets the boundary string.
 String getCharset()
          Gets the character set.
 String getContentType()
          Gets the content type.
 byte[] getData()
          Gets the data.
 String getFileName()
          Gets the file name.
 String getName()
          Gets the part name.
 String getTransferEncoding()
          Gets the transfer encoding.
 boolean isRepeatable()
          True if the part can be written to the output stream more than once.
 long partLength()
          Determine the length of the part in bytes (-1 if unknown).
 void send(OutputStream out)
          Write the part to the stream.
protected  void sendContentTypeHeader(OutputStream out)
          Write the Content-Type to the stream.
protected  void sendData(OutputStream out)
          Write the part data to the stream.
protected  void sendDispositionHeader(OutputStream out)
          Write the Content-Disposition to the stream.
protected  void sendEnd(OutputStream out)
          Write the bytes that end a part to the stream.
protected  void sendEndOfHeader(OutputStream out)
          Write the bytes that end a part header to the stream.
protected  void sendStart(OutputStream out)
          Write the bytes that start a part to the stream.
protected  void sendTransferEncodingHeader(OutputStream out)
          Write the content Content-Transfer-Encoding to the stream.
 void setBoundary(String boundary)
          Sets the boundary string.
 void setCharset(String charset)
          Sets the character set.
 void setContentType(String contentType)
          Sets the content type.
 void setData(byte[] data)
          Sets the data.
 void setFileName(String fileName)
          Sets the file name.
 void setName(String name)
          Sets the part name.
 void setTransferEncoding(String transferEncoding)
          Sets the transfer encoding.
protected  long streamData(InputStream source, OutputStream destination)
          Stream data from an input to an output.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MPart

public MPart()
Default constructor.


MPart

public MPart(String name,
             String data)
Constructor.

Parameters:
name - the part name
data - the data

MPart

public MPart(String name,
             String data,
             String contentType)
Constructor.

Parameters:
name - the part name
data - the data
contentType - the content type

MPart

public MPart(String name,
             byte[] data,
             String fileName,
             String contentType,
             String charset)
Constructor.

Parameters:
name - the part name
data - the data
fileName - the file name
contentType - the content type
charset - the character set
Method Detail

getBoundary

public String getBoundary()
Gets the boundary string.

Returns:
the boundary

setBoundary

public void setBoundary(String boundary)
Sets the boundary string.

Parameters:
boundary - the boundary

getCharset

public String getCharset()
Gets the character set.

Returns:
the character set

setCharset

public void setCharset(String charset)
Sets the character set.

Parameters:
charset - the character set

getContentType

public String getContentType()
Gets the content type.

Returns:
the content type

setContentType

public void setContentType(String contentType)
Sets the content type.

Parameters:
contentType - the content type

getData

public byte[] getData()
Gets the data.

Returns:
the data

setData

public void setData(byte[] data)
Sets the data.

Parameters:
data - the data

getFileName

public String getFileName()
Gets the file name.

Returns:
the file name

setFileName

public void setFileName(String fileName)
Sets the file name.

Parameters:
fileName - the file name

getName

public String getName()
Gets the part name.

Returns:
the part name

setName

public void setName(String name)
Sets the part name.

Parameters:
name - the part name

getTransferEncoding

public String getTransferEncoding()
Gets the transfer encoding.

Returns:
the transfer encoding

setTransferEncoding

public void setTransferEncoding(String transferEncoding)
Sets the transfer encoding.

Parameters:
transferEncoding - the transfer encoding

dataLength

protected long dataLength()
                   throws IOException
Determine the length of the part data in bytes (-1 if unknown).
This should be overridden if the data is not a string or byte array.

Returns:
the data length
Throws:
IOException - if an exception occurs

getAsciiBytes

protected byte[] getAsciiBytes(String value)
                        throws UnsupportedEncodingException
Gets the US-ASCII bytes for a value

Parameters:
value - the value
Returns:
the bytes
Throws:
UnsupportedEncodingException - if the encoding is unsupported

isRepeatable

public boolean isRepeatable()
True if the part can be written to the output stream more than once.

Returns:
true if repeatable

partLength

public long partLength()
                throws IOException
Determine the length of the part in bytes (-1 if unknown).

Returns:
the length of the part
Throws:
IOException - if an exception occurs

send

public void send(OutputStream out)
          throws IOException
Write the part to the stream.

Parameters:
out - the output stream
Throws:
IOException - if an exception occurs

sendContentTypeHeader

protected void sendContentTypeHeader(OutputStream out)
                              throws IOException
Write the Content-Type to the stream.

Parameters:
out - the output stream
Throws:
IOException - if an exception occurs

sendData

protected void sendData(OutputStream out)
                 throws IOException
Write the part data to the stream.

Parameters:
out - the output stream
Throws:
IOException - if an exception occurs

sendDispositionHeader

protected void sendDispositionHeader(OutputStream out)
                              throws IOException
Write the Content-Disposition to the stream.

Parameters:
out - the output stream
Throws:
IOException - if an exception occurs

sendEnd

protected void sendEnd(OutputStream out)
                throws IOException
Write the bytes that end a part to the stream.

Parameters:
out - the output stream
Throws:
IOException - if an exception occurs

sendEndOfHeader

protected void sendEndOfHeader(OutputStream out)
                        throws IOException
Write the bytes that end a part header to the stream.

Parameters:
out - the output stream
Throws:
IOException - if an exception occurs

sendStart

protected void sendStart(OutputStream out)
                  throws IOException
Write the bytes that start a part to the stream.

Parameters:
out - the output stream
Throws:
IOException - if an exception occurs

sendTransferEncodingHeader

protected void sendTransferEncodingHeader(OutputStream out)
                                   throws IOException
Write the content Content-Transfer-Encoding to the stream.

Parameters:
out - the output stream
Throws:
IOException - if an exception occurs

streamData

protected long streamData(InputStream source,
                          OutputStream destination)
                   throws IOException
Stream data from an input to an output.

Parameters:
source - the input stream
destination - the output stream
Throws:
IOException - if an exception occurs

Esri Geoportal Server
1.2.9

Copyright 2011 Environmental Systems Research Institute. All rights reserved. Use is subject to license terms.