com.ibm.portal.resolver.streams.helper
Class DefaultMultipartEntry

java.lang.Object
  extended by com.ibm.portal.resolver.streams.helper.DefaultMultipartEntry
All Implemented Interfaces:
IterableListModel<java.util.Map.Entry<java.lang.String,java.lang.String>>, ListModel<java.util.Map.Entry<java.lang.String,java.lang.String>>, MetaData<java.lang.String,java.util.Map.Entry<java.lang.String,java.lang.String>>, MultipartStream.Entry, java.lang.Iterable<java.util.Map.Entry<java.lang.String,java.lang.String>>

public class DefaultMultipartEntry
extends java.lang.Object
implements MultipartStream.Entry

Default implementation for a MultipartStream.Entry. This implementation is useful to produce multipart streams via the MultipartOutputStream object. This class is designed such that it can be used to repeatedly write multipart entries. Call the clear() method to initialize the class between calls.

Example:

  final MultipartOutputStream multiOut = ...
  // dummy entry
  final DefaultMultipartEntry entry = new DefaultMultipartEntry();
  entry.clear();
  entry.setContentType("text/plain");
  entry.setHeader("Content-ID", partURI.toString());
  entry.setHeader("some-header", "Carsten");
  // create the entry
  multiOut.putNextEntry(entry);
  multiOut.write("Carsten".getBytes());
  // create the entry
  multiOut.putNextEntry(entry);
  multiOut.write("Carsten".getBytes());
 

Since:
6.1
Note:
This interface is designed to be implemented by clients.

Field Summary
static java.lang.String HTTP_CONTENT_TYPE_HEADER
          content type header name
static java.lang.String HTTP_TRANSFER_ENCODING_BASE64
          bas64 transfer encoding *
static java.lang.String HTTP_TRANSFER_ENCODING_BINARY
          binary transfer encoding *
static java.lang.String HTTP_TRANSFER_ENCODING_HEADER
          transfer encoding header name
static java.lang.String HTTP_TRANSFER_ENCODING_QUOTED_PRINTABLE
          quoted printable transfer encoding *
static java.lang.String HTTP_TRANSFER_ENCODING_UUENCODE
          uuencode transfer encoding *
 
Constructor Summary
DefaultMultipartEntry()
           
 
Method Summary
 void clear()
          clears all headers
 boolean containsHeader(java.lang.String name)
          Returns a boolean indicating whether the named header has already been set.
 java.lang.String getContentType()
          Mime type of the data.
protected  java.util.Map<java.lang.String,java.lang.String> getHeaders()
          Returns a modifiable map of the headers
 IterableListModel<java.lang.String> getNames()
          Returns a list of the names of meta data entries.
 java.lang.String getValue(java.lang.String aName)
          Returns the value of a meta data entry for the given parameter name.
 java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>> iterator()
          Returns an interator over elements of the list.
 void setContentType(java.lang.String aContentType)
          Associates the mime-type of the data
 void setDateHeader(java.lang.String key, java.util.Date date)
          Adds a new date header and formats the date automatically according to the specification
 void setDateHeader(java.lang.String key, long date)
          Adds a new date header and formats the date automatically according to the specification
 void setEntry(MultipartStream.Entry entry)
          Copies the data from the entry
 void setHeader(Header header)
          Adds this header via the Header interface
 void setHeader(java.lang.String key, java.lang.String value)
          Sets the specified header
 void setIntHeader(java.lang.String key, int value)
          Adds a new header and formats the integer value.
 void setTransferEncoding(java.lang.String aEncoding)
          Specifies the transfer encoding
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HTTP_CONTENT_TYPE_HEADER

public static final java.lang.String HTTP_CONTENT_TYPE_HEADER
content type header name

See Also:
Constant Field Values

HTTP_TRANSFER_ENCODING_BASE64

public static final java.lang.String HTTP_TRANSFER_ENCODING_BASE64
bas64 transfer encoding *

See Also:
Constant Field Values

HTTP_TRANSFER_ENCODING_BINARY

public static final java.lang.String HTTP_TRANSFER_ENCODING_BINARY
binary transfer encoding *

See Also:
Constant Field Values

HTTP_TRANSFER_ENCODING_HEADER

public static final java.lang.String HTTP_TRANSFER_ENCODING_HEADER
transfer encoding header name

See Also:
Constant Field Values

HTTP_TRANSFER_ENCODING_QUOTED_PRINTABLE

public static final java.lang.String HTTP_TRANSFER_ENCODING_QUOTED_PRINTABLE
quoted printable transfer encoding *

See Also:
Constant Field Values

HTTP_TRANSFER_ENCODING_UUENCODE

public static final java.lang.String HTTP_TRANSFER_ENCODING_UUENCODE
uuencode transfer encoding *

See Also:
Constant Field Values
Constructor Detail

DefaultMultipartEntry

public DefaultMultipartEntry()
Method Detail

clear

public void clear()
clears all headers


containsHeader

public boolean containsHeader(java.lang.String name)
Returns a boolean indicating whether the named header has already been set.

Parameters:
name - the header name
Returns:
true if the header has already been set, false otherwise

getContentType

public java.lang.String getContentType()
Description copied from interface: MultipartStream.Entry
Mime type of the data. The return value must be a registered mime type

Specified by:
getContentType in interface MultipartStream.Entry
Returns:
mime type string

getHeaders

protected java.util.Map<java.lang.String,java.lang.String> getHeaders()
Returns a modifiable map of the headers

Returns:
Returns the headers.

getNames

public IterableListModel<java.lang.String> getNames()
Description copied from interface: MetaData
Returns a list of the names of meta data entries.

Specified by:
getNames in interface MetaData<java.lang.String,java.util.Map.Entry<java.lang.String,java.lang.String>>
Specified by:
getNames in interface MultipartStream.Entry
Returns:
the list of names.

getValue

public java.lang.String getValue(java.lang.String aName)
Description copied from interface: MetaData
Returns the value of a meta data entry for the given parameter name.

Specified by:
getValue in interface MetaData<java.lang.String,java.util.Map.Entry<java.lang.String,java.lang.String>>
Parameters:
aName - the parameter name
Returns:
the value of the meta data entry for the given name, or null if none exists

iterator

public java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>> iterator()
Description copied from interface: IterableListModel
Returns an interator over elements of the list. To be compatible with both ListModel and java.util.Iterable, this method does not declare any exceptions

Specified by:
iterator in interface IterableListModel<java.util.Map.Entry<java.lang.String,java.lang.String>>
Specified by:
iterator in interface ListModel<java.util.Map.Entry<java.lang.String,java.lang.String>>
Specified by:
iterator in interface MetaData<java.lang.String,java.util.Map.Entry<java.lang.String,java.lang.String>>
Specified by:
iterator in interface MultipartStream.Entry
Specified by:
iterator in interface java.lang.Iterable<java.util.Map.Entry<java.lang.String,java.lang.String>>
Returns:
an iterator

setContentType

public void setContentType(java.lang.String aContentType)
Associates the mime-type of the data

Parameters:
aContentType - mime type string

setDateHeader

public void setDateHeader(java.lang.String key,
                          java.util.Date date)
Adds a new date header and formats the date automatically according to the specification

Parameters:
key - name of the header, not null
date - date value of the header, not null

setDateHeader

public void setDateHeader(java.lang.String key,
                          long date)
Adds a new date header and formats the date automatically according to the specification

Parameters:
key - name of the header
date - the milliseconds since January 1, 1970, 00:00:00 GMT.

setEntry

public void setEntry(MultipartStream.Entry entry)
Copies the data from the entry

Parameters:
entry -

setHeader

public void setHeader(Header header)
Adds this header via the Header interface

Parameters:
header - header to add

setHeader

public void setHeader(java.lang.String key,
                      java.lang.String value)
Sets the specified header

Parameters:
key - header name
value - header value

setIntHeader

public void setIntHeader(java.lang.String key,
                         int value)
Adds a new header and formats the integer value.

Parameters:
key - name of the header, not null
value - integer value of the header

setTransferEncoding

public void setTransferEncoding(java.lang.String aEncoding)
Specifies the transfer encoding

Parameters:
aEncoding - name idenfification of the transfer encoding, not null