org.beepcore.beep.core
Class StringOutputDataStream

java.lang.Object
  extended byorg.beepcore.beep.core.OutputDataStream
      extended byorg.beepcore.beep.core.StringOutputDataStream

public class StringOutputDataStream
extends OutputDataStream

StringOutputDataStream represents a BEEP message's payload. Allows implementors to treat a String as a DataSream. The String is stored as a byte[] using UTF-8 encoding.

Note that this implementation is not synchronized. If multiple threads access a StringOutputDataStream concurrently, data may be inconsistent or lost.

See Also:
OutputDataStream

Field Summary
 
Fields inherited from class org.beepcore.beep.core.OutputDataStream
mimeHeaders
 
Constructor Summary
StringOutputDataStream(java.lang.String data)
          Creates a StringOutputDataStream with a String and a BEEP_XML_CONTENT_TYPE content type and a transfer encoding of DEFAULT_CONTENT_TRANSFER_ENCODING.
StringOutputDataStream(java.lang.String contentType, java.lang.String data)
          Creates a StringOutputDataStream with a String and a specified content type and a transfer encoding of DEFAULT_CONTENT_TRANSFER_ENCODING.
StringOutputDataStream(java.lang.String contentType, java.lang.String transferEncoding, java.lang.String data)
          Creates a StringOutputDataStream with a String and a specified content type and a transfer encoding of DEFAULT_CONTENT_TRANSFER_ENCODING.
StringOutputDataStream(java.lang.String contentType, java.lang.String transferEncoding, java.lang.String data, java.lang.String enc)
          Creates a StringOutputDataStream with a String and a specified content type and encoding.
 
Method Summary
 java.lang.String getContentType()
          Returns the value of the MIME entity header Content-Type.
 java.lang.String getEncoding()
          Returns the encoding used to convert the String to a bytes[].
 java.util.Enumeration getHeaderNames()
          Returns an Enumeration of all the names of the MIME entity headers in this data stream.
 java.lang.String getHeaderValue(java.lang.String name)
          Retrieves the correspoding value to a given a MIME entity header name.
 java.lang.String getTransferEncoding()
          Returns the value of the MIME entity header Content-Transfer-Encoding.
 boolean isComplete()
          Returns true if no more bytes will be added to those currently available, if any, on this stream.
 boolean removeHeader(java.lang.String name)
          Removes the name and value of a MIME entity header from the data stream.
 void setContentType(java.lang.String contentType)
          Sets the content type of a DataStream.
 void setHeaderValue(java.lang.String name, java.lang.String value)
          Adds a MIME entity header to this data stream.
 void setTransferEncoding(java.lang.String transferEncoding)
          Sets the content transfer encoding of a DataStream
 
Methods inherited from class org.beepcore.beep.core.OutputDataStream
add, close, setComplete
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringOutputDataStream

public StringOutputDataStream(java.lang.String data)
Creates a StringOutputDataStream with a String and a BEEP_XML_CONTENT_TYPE content type and a transfer encoding of DEFAULT_CONTENT_TRANSFER_ENCODING.

Parameters:
data - A String representing a message's payload.

StringOutputDataStream

public StringOutputDataStream(java.lang.String contentType,
                              java.lang.String data)
Creates a StringOutputDataStream with a String and a specified content type and a transfer encoding of DEFAULT_CONTENT_TRANSFER_ENCODING.

Parameters:
contentType - Content type of data
data - A String representing a message's payload.

StringOutputDataStream

public StringOutputDataStream(java.lang.String contentType,
                              java.lang.String transferEncoding,
                              java.lang.String data)
Creates a StringOutputDataStream with a String and a specified content type and a transfer encoding of DEFAULT_CONTENT_TRANSFER_ENCODING.

Parameters:
contentType - Content type of data
transferEncoding - Encoding Transfer encoding type of data.
data - A String representing a message's payload.

StringOutputDataStream

public StringOutputDataStream(java.lang.String contentType,
                              java.lang.String transferEncoding,
                              java.lang.String data,
                              java.lang.String enc)
                       throws java.io.UnsupportedEncodingException
Creates a StringOutputDataStream with a String and a specified content type and encoding.

Parameters:
contentType - Content type of data
transferEncoding - Encoding Transfer encoding type of data.
data - A String representing a message's payload.
enc - The encoding used when converting data to a bytes[].
Method Detail

getEncoding

public java.lang.String getEncoding()
Returns the encoding used to convert the String to a bytes[].


isComplete

public boolean isComplete()
Returns true if no more bytes will be added to those currently available, if any, on this stream. Returns false if more bytes are expected.

Overrides:
isComplete in class OutputDataStream

getContentType

public java.lang.String getContentType()
                                throws BEEPException
Returns the value of the MIME entity header Content-Type.

Throws:
BEEPException

setContentType

public void setContentType(java.lang.String contentType)
Sets the content type of a DataStream.

Parameters:
contentType -

getHeaderNames

public java.util.Enumeration getHeaderNames()
                                     throws BEEPException
Returns an Enumeration of all the names of the MIME entity headers in this data stream. Use this call in conjunction with getHeaderValue to iterate through all the corresponding MIME entity header value(s) in this data stream.

Returns:
An Enumeration of all the MIME entity header names.
Throws:
BEEPException

getHeaderValue

public java.lang.String getHeaderValue(java.lang.String name)
                                throws BEEPException
Retrieves the correspoding value to a given a MIME entity header name.

Parameters:
name - Name of the MIME entity header.
Returns:
The value of the MIME entity header.
Throws:
BEEPException

setHeaderValue

public void setHeaderValue(java.lang.String name,
                           java.lang.String value)
Adds a MIME entity header to this data stream.

Parameters:
name - Name of the MIME enitity header.
value - Value of the MIME entity header.

getTransferEncoding

public java.lang.String getTransferEncoding()
                                     throws BEEPException
Returns the value of the MIME entity header Content-Transfer-Encoding.

Throws:
BEEPException

setTransferEncoding

public void setTransferEncoding(java.lang.String transferEncoding)
Sets the content transfer encoding of a DataStream

Parameters:
transferEncoding -

removeHeader

public boolean removeHeader(java.lang.String name)
Removes the name and value of a MIME entity header from the data stream. Returns true if the name was successfully removed.

Parameters:
name - Name of the header to be removed from the data stream.
Returns:
Returns true if header was removed. Otherwise, returns false.


Copyright ? 2001 Invisible Worlds, Inc. All Rights Reserved.