org.productivity.java.syslog4j.impl.message.structured
Class StructuredSyslogMessage

java.lang.Object
  extended by org.productivity.java.syslog4j.impl.message.AbstractSyslogMessage
      extended by org.productivity.java.syslog4j.impl.message.structured.StructuredSyslogMessage
All Implemented Interfaces:
java.io.Serializable, StructuredSyslogMessageIF, SyslogMessageIF

public class StructuredSyslogMessage
extends AbstractSyslogMessage
implements StructuredSyslogMessageIF

SyslogStructuredMessage extends AbstractSyslogMessage's ability to provide support for turning POJO (Plain Ol' Java Objects) into Syslog messages. It adds support for structured syslog messages as specified by draft-ietf-syslog-protocol-23. More information here:

http://tools.ietf.org/html/draft-ietf-syslog-protocol-23#section-6

Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy of the LGPL license is available in the META-INF folder in all distributions of Syslog4j and in the base directory of the "doc" ZIP.

Version:
$Id: StructuredSyslogMessage.java,v 1.5 2010/09/11 16:49:24 cvs Exp $
Author:
Manish Motwani
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.productivity.java.syslog4j.impl.message.AbstractSyslogMessage
DEFAULT_DATE_FORMAT, DEFAULT_DELIMITER, DEFAULT_REPLACE_DELIMITER, DEFAULT_TIME_FORMAT, UNDEFINED
 
Constructor Summary
StructuredSyslogMessage(java.lang.String messageId, java.util.Map structuredData, java.lang.String message)
          Constructs the StructuredSyslogMessage using MSGID, STRUCTURED-DATA and MSG fields, as described in:
 
Method Summary
static boolean checkIsPrintable(java.lang.String value)
           
 java.lang.String createMessage()
           
 boolean equals(java.lang.Object obj)
           
static StructuredSyslogMessage fromString(java.lang.String syslogMessageStr)
          Parses and loads a StructuredSyslogMessage from string.
 java.lang.String getMessage()
          Returns the MSG field of the structured message format, as described in:
 java.lang.String getMessageId()
          Returns the MSGID field of the structured message format, as described in:
 java.util.Map getStructuredData()
          Returns the structured data map.
 int hashCode()
           
static java.lang.String nilProtect(java.lang.String value)
           
static void sdEscape(java.lang.StringBuffer sb, java.lang.String value)
           
 java.lang.String toString()
           
 
Methods inherited from class org.productivity.java.syslog4j.impl.message.AbstractSyslogMessage
generateDate, generateDateAndTime, generateLocalHostName, generateTime, getDateFormat, getDelimiter, getReplaceDelimiter, getTimeFormat, nullOrEmpty, replaceDelimiter
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StructuredSyslogMessage

public StructuredSyslogMessage(java.lang.String messageId,
                               java.util.Map structuredData,
                               java.lang.String message)
Constructs the StructuredSyslogMessage using MSGID, STRUCTURED-DATA and MSG fields, as described in:

http://tools.ietf.org/html/draft-ietf-syslog-protocol-23#section-6

The Map must be a String -> (Map of String -> String), which encompasses the STRUCTURED-DATA field described in above document.

Parameters:
messageId -
structuredData -
message -
Method Detail

fromString

public static StructuredSyslogMessage fromString(java.lang.String syslogMessageStr)
Parses and loads a StructuredSyslogMessage from string.

Parameters:
syslogMessageStr -
Returns:
Returns an instance of StructuredSyslogMessage.

getMessageId

public java.lang.String getMessageId()
Returns the MSGID field of the structured message format, as described in:

http://tools.ietf.org/html/draft-ietf-syslog-protocol-23#section-6

Returns:
Returns the MSG ID field.

getStructuredData

public java.util.Map getStructuredData()
Returns the structured data map. The Map is a String -> (Map of String -> String), which encompasses the STRUCTURED-DATA field, as described in:

http://tools.ietf.org/html/draft-ietf-syslog-protocol-23#section-6

Returns:
Returns a Map object containing structured data.

getMessage

public java.lang.String getMessage()
Returns the MSG field of the structured message format, as described in:

http://tools.ietf.org/html/draft-ietf-syslog-protocol-23#section-6

Returns:
Returns the MSG field.

createMessage

public java.lang.String createMessage()
Specified by:
createMessage in interface SyslogMessageIF
Specified by:
createMessage in class AbstractSyslogMessage

sdEscape

public static void sdEscape(java.lang.StringBuffer sb,
                            java.lang.String value)

checkIsPrintable

public static boolean checkIsPrintable(java.lang.String value)

nilProtect

public static java.lang.String nilProtect(java.lang.String value)

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object