Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.sf.dropboxmq.messagetranscoders
Class DefaultMessageTranscoder

    java.lang.Object
      net.sf.dropboxmq.messagetranscoders.DefaultMessageTranscoder

All Implemented Interfaces:
  MessageTranscoder

    public class DefaultMessageTranscoder

extends Object
implements MessageTranscoder

Created: 02 Dec 2005

Version:
  $Revision: 231 $, $Date: 2011-08-12 21:50:47 -0600 (Fri, 12 Aug 2011) $
Author:
  Dwayne Schultz

Field Summary
`static char` | `BOOLEAN_TYPE`
`static char` | `BYTE_TYPE`
`static String` | `BYTES_MESSAGE_CLASS`
`static char` | `DOUBLE_TYPE`
`static String` | `EQUALS_SEPARATOR`
`static String` | `FIELD_SEPARATOR`
`static char` | `FLOAT_TYPE`
`static char` | `INTEGER_TYPE`
`static char` | `LONG_TYPE`
`static String` | `MAP_MESSAGE_CLASS`
`static String` | `MESSAGE_CLASS`
`static String` | `MESSAGE_ID_PREFIX`
`static String` | `OBJECT_MESSAGE_CLASS`
`static String` | `PROPERTY_SEPARATOR`
`static char` | `QUEUE_DESTINATION_CLASS`
`static char` | `SHORT_TYPE`
`static String` | `STREAM_MESSAGE_CLASS`
`static char` | `STRING_TYPE`
`static String` | `TEXT_MESSAGE_CLASS`
`static char` | `TOPIC_DESTINATION_CLASS`

Constructor Summary
`DefaultMessageTranscoder(Configuration configuration)`

Method Summary
`protected void` | `appendProperty(String name, Object value, StringBuffer properties)`
`static MessageImpl` | `createMessage(SessionImpl session, String messageClass)`
`static String` | `decode(String in)`
`Message` | `decodeMetadata(SessionImpl session, File messageFile, String originalFilename, boolean priorityAndSelectorOnly, String messageSelector)` Decodes the provided metadata and creates a new emtpy message.
`protected void` | `decodeProperties(String properties, Message message)`
`protected void` | `decodeProperty(String pair, Message message)`
`static String` | `encode(String in)`
`static String` | `encodeMessageClass(Message message)`
`String` | `encodeMetadata(Message message)` Encodes the metadata of a given message.
`protected String` | `encodeProperties(Message message)`
`protected String` | `getEncodedProperties(StringBuffer encodedProperties)` Allows subclasses to use the default property encoding mechanism with a post-encoding mechanism.
`(package private) static String` | `getNextToken(String metadata, int index)`
`(package private) static long` | `parseNumber(String numberString, long defaultNumber)`
`(package private) static void` | `setProperty(String name, char type, String value, Message message)`
`protected String` | `toObjectString()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### MESSAGE_ID_PREFIX

    public static final String MESSAGE_ID_PREFIX

See Also:
  Constant Field Values

### BOOLEAN_TYPE

    public static final char BOOLEAN_TYPE

See Also:
  Constant Field Values

### BYTE_TYPE

    public static final char BYTE_TYPE

See Also:
  Constant Field Values

### SHORT_TYPE

    public static final char SHORT_TYPE

See Also:
  Constant Field Values

### INTEGER_TYPE

    public static final char INTEGER_TYPE

See Also:
  Constant Field Values

### LONG_TYPE

    public static final char LONG_TYPE

See Also:
  Constant Field Values

### FLOAT_TYPE

    public static final char FLOAT_TYPE

See Also:
  Constant Field Values

### DOUBLE_TYPE

    public static final char DOUBLE_TYPE

See Also:
  Constant Field Values

### STRING_TYPE

    public static final char STRING_TYPE

See Also:
  Constant Field Values

### FIELD_SEPARATOR

    public static final String FIELD_SEPARATOR

See Also:
  Constant Field Values

### PROPERTY_SEPARATOR

    public static final String PROPERTY_SEPARATOR

See Also:
  Constant Field Values

### EQUALS_SEPARATOR

    public static final String EQUALS_SEPARATOR

See Also:
  Constant Field Values

### MESSAGE_CLASS

    public static final String MESSAGE_CLASS

See Also:
  Constant Field Values

### BYTES_MESSAGE_CLASS

    public static final String BYTES_MESSAGE_CLASS

See Also:
  Constant Field Values

### MAP_MESSAGE_CLASS

    public static final String MAP_MESSAGE_CLASS

See Also:
  Constant Field Values

### OBJECT_MESSAGE_CLASS

    public static final String OBJECT_MESSAGE_CLASS

See Also:
  Constant Field Values

### STREAM_MESSAGE_CLASS

    public static final String STREAM_MESSAGE_CLASS

See Also:
  Constant Field Values

### TEXT_MESSAGE_CLASS

    public static final String TEXT_MESSAGE_CLASS

See Also:
  Constant Field Values

### QUEUE_DESTINATION_CLASS

    public static final char QUEUE_DESTINATION_CLASS

See Also:
  Constant Field Values

### TOPIC_DESTINATION_CLASS

    public static final char TOPIC_DESTINATION_CLASS

See Also:
  Constant Field Values

Constructor Detail

### DefaultMessageTranscoder

    public DefaultMessageTranscoder(Configuration configuration)

Method Detail

### encode

    public static String encode(String in)
                         throws JMSException

  Throws:
    `JMSException`

### decode

    public static String decode(String in)
                         throws JMSException

  Throws:
    `JMSException`

### encodeMetadata

    public String encodeMetadata(Message message)
                          throws JMSException

  Description copied from interface: `MessageTranscoder`
  Encodes the metadata of a given message. The metadata is used to name the message file.

  Specified by:
    `encodeMetadata` in interface `MessageTranscoder`
  Parameters:
    `message` - the message that is being sent
  Returns:
    a string representation of the messages metadata
  Throws:
    `JMSException` - if the transcoder fails to encode the metadata contained in the message. Such an exception or any RuntimeException will cause the message to not be sent.

### encodeMessageClass

    public static String encodeMessageClass(Message message)

### encodeProperties

    protected String encodeProperties(Message message)
                               throws JMSException

  Throws:
    `JMSException`

### appendProperty

    protected void appendProperty(String name,
                                  Object value,
                                  StringBuffer properties)
                           throws JMSException

  Throws:
    `JMSException`

### getEncodedProperties

    protected String getEncodedProperties(StringBuffer encodedProperties)
                                   throws JMSException

  Allows subclasses to use the default property encoding mechanism with a post-encoding mechanism. Subclasses can override this method to implement such as post-encoding mechanism. The `DefaultMessageTranscoder` implementation simply calls `encodedProperties.toString()`.

  Parameters:
    `encodedProperties` - a `StringBuffer` version of the encoded properties
  Returns:
    a `String` version of the encoded properties
  Throws:
    `JMSException` - if for any reason the properties fail in the post-encoding mechanism. Will cause outgoing messages to not be sent and incoming messages will not have properties.

### decodeMetadata

    public Message decodeMetadata(SessionImpl session,
                                  File messageFile,
                                  String originalFilename,
                                  boolean priorityAndSelectorOnly,
                                  String messageSelector)
                           throws IOException

  Description copied from interface: `MessageTranscoder`
  Decodes the provided metadata and creates a new emtpy message.

  Specified by:
    `decodeMetadata` in interface `MessageTranscoder`
  Parameters:
    `session` - a session that should be used to create a new message that will contain the metadata after it has been decoded
    `messageFile` - the message file containing metadata to be decoded
    `originalFilename` - the original name of the file as it was produced. The name returned by messageFile.getName() has been modified from the original. If a transcoder needs to decode metadata from the message filename, this parameter should be used.
    `priorityAndSelectorOnly` - decodeMetadata() is called twice, first for determining priority and applying any message selectors, and second as a message is consumed; careful transcoders can apply some optimizations to the first call when this value will be set to true
    `messageSelector` - the message selector to be applied to the message. May be used to further optimize the decoding process. If priorityAndSelectorOnly is true and messageSelector is null, transcoders can safely decode the JMS priority and JMS timestamp only. If priorityAndSelectorOnly is true, messageSelector does not contain a specific selection and the decoding of metadata to support the specific selection is costly, transcoders can safely skip the decoding of the specific selection. For instance perhaps decoding the JMS type (@see javax.jms.Message#getJMSType()) requires parsing the message body. A transcoder may scan the message for JMSType and if priorityAndSelectorOnly is true and messageSelector does not contain JMSType, the transcoder can safely choose to not parse the message body.
  Returns:
    the newly created message
  Throws:
    `IOException` - if the transcoder encounters any problems reading the message file, the exception should be passed up to the caller

### getNextToken

    static String getNextToken(String metadata,
                               int index)

### createMessage

    public static MessageImpl createMessage(SessionImpl session,
                                            String messageClass)
                                     throws JMSException

  Throws:
    `JMSException`

### parseNumber

    static long parseNumber(String numberString,
                            long defaultNumber)

### decodeProperties

    protected void decodeProperties(String properties,
                                    Message message)
                             throws JMSException

  Throws:
    `JMSException`

### decodeProperty

    protected void decodeProperty(String pair,
                                  Message message)
                           throws JMSException

  Throws:
    `JMSException`

### setProperty

    static void setProperty(String name,
                            char type,
                            String value,
                            Message message)
                     throws JMSException

  Throws:
    `JMSException`

### toObjectString

    protected final String toObjectString()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD