|
xmlBlaster 2.2.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.xmlBlaster.util.MsgUnit
public final class MsgUnit
Encapsulates the parsed xmlKey and QoS, and the raw content.
The constructor arguments are checked to be not null and corrected to "" or 'new byte[0]' if they are null
Field Summary | |
---|---|
private byte[] |
content
|
private static byte[] |
EMPTY_BYTEARR
|
private Global |
glob
|
private KeyData |
keyData
|
private QosData |
qosData
|
private static long |
serialVersionUID
|
Constructor Summary | |
---|---|
MsgUnit(Global glob,
MsgUnitRaw msgUnitRaw,
MethodName methodName)
|
|
MsgUnit(Global glob,
java.lang.String key,
byte[] content,
java.lang.String qos)
Assumes a PUBLISH. |
|
MsgUnit(Global glob,
java.lang.String key,
byte[] content,
java.lang.String qos,
MethodName methodName)
The normal constructor. |
|
MsgUnit(Global glob,
java.lang.String key,
java.lang.String contentAsString,
java.lang.String qos)
Assumes a PUBLISH. |
|
MsgUnit(KeyData key,
byte[] content,
QosData qos)
Create a MsgUnit with pre-parsed parameters. |
|
MsgUnit(MsgUnit old,
KeyData key,
byte[] content,
QosData qos)
Clone this message unit (but not the content). |
|
MsgUnit(PublishKey key,
byte[] content,
PublishQos qos)
This is a constructor suitable for clients. |
|
MsgUnit(PublishKey key,
java.lang.String contentAsString,
PublishQos qos)
This is a constructor suitable for clients. |
|
MsgUnit(java.lang.String key,
byte[] content,
java.lang.String qos)
Uses the default global and assumes a PUBLISH. |
|
MsgUnit(java.lang.String key,
java.lang.String contentAsString,
java.lang.String qos)
Uses the default global and assumes a PUBLISH. |
Method Summary | |
---|---|
MsgUnit |
getClone()
Deep clone this message unit. |
byte[] |
getContent()
Get the raw content. |
java.lang.String |
getContentMime()
|
java.lang.String |
getContentMimeExtended()
|
java.lang.String |
getContentStr()
Convenience method to get the raw content as a string, the encoding is UTF-8 if not specified by clientProperty Constants.CLIENTPROPERTY_CONTENT_CHARSET , |
java.lang.String |
getContentStrNoEx()
|
java.lang.String |
getDomain()
|
Global |
getGlobal()
|
java.lang.String |
getKey()
The raw XML string for PUBLISH/UPDATE never null, otherwise it may be null |
KeyData |
getKeyData()
The parsed key. |
java.lang.String |
getKeyOid()
The key oid, can be null if not a PUBLISH or UPDATE |
java.lang.String |
getLogId()
|
MethodName |
getMethodName()
|
MsgUnitRaw |
getMsgUnitRaw()
|
java.lang.String |
getQos()
The QoS XML string. |
byte[] |
getQosBytes()
|
QosData |
getQosData()
The parsed QoS. |
boolean |
hasDomain()
|
boolean |
sameContent(byte[] newContent)
Compares bytes if the given content is identical to the internal content |
void |
setContent(byte[] content)
Used internally and my be used by publish mime plugin |
void |
setGlobal(Global glob)
|
long |
size()
The number of bytes of qos+key+content |
java.lang.String |
toString()
|
java.lang.String |
toXml()
Dump state of this object into a XML ASCII string. |
void |
toXml(java.io.OutputStream out,
java.util.Properties props)
|
java.lang.String |
toXml(java.lang.String extraOffset)
Dump state of this object into a XML ASCII string. |
java.lang.String |
toXml(java.lang.String extraOffset,
boolean forceReadable)
Overwrite QosData.toXml() |
java.lang.String |
toXml(java.lang.String extraOffset,
int maxContentLen,
boolean forceReadable)
Dump state of this object into a XML ASCII string. |
private void |
toXml(java.lang.String extraOffset,
java.io.OutputStream out,
java.util.Properties props)
Dump status as XML to outstream. |
java.lang.String |
toXml(java.lang.String extraOffset,
java.util.Properties props)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final long serialVersionUID
private static final transient byte[] EMPTY_BYTEARR
private transient Global glob
private QosData qosData
private byte[] content
private KeyData keyData
Constructor Detail |
---|
public MsgUnit(java.lang.String key, byte[] content, java.lang.String qos) throws XmlBlasterException
XmlBlasterException
MsgUnit(Global, String, byte[], String, MethodName)
public MsgUnit(Global glob, java.lang.String key, byte[] content, java.lang.String qos) throws XmlBlasterException
XmlBlasterException
MsgUnit(Global, String, byte[], String, MethodName)
public MsgUnit(Global glob, MsgUnitRaw msgUnitRaw, MethodName methodName) throws XmlBlasterException
XmlBlasterException
MsgUnit(Global, String, byte[], String, MethodName)
public MsgUnit(Global glob, java.lang.String key, byte[] content, java.lang.String qos, MethodName methodName) throws XmlBlasterException
glob
- The specific Global handlekey
- The XML keyqos
- The XML qosmethodName
- The method you want to invoked (like PUBLISH or SUBSCRIBE)
XmlBlasterException
public MsgUnit(java.lang.String key, java.lang.String contentAsString, java.lang.String qos) throws XmlBlasterException
XmlBlasterException
MsgUnit(Global, String, byte[], String, MethodName)
public MsgUnit(Global glob, java.lang.String key, java.lang.String contentAsString, java.lang.String qos) throws XmlBlasterException
XmlBlasterException
MsgUnit(Global, String, byte[], String, MethodName)
public MsgUnit(PublishKey key, java.lang.String contentAsString, PublishQos qos)
public MsgUnit(PublishKey key, byte[] content, PublishQos qos)
public MsgUnit(KeyData key, byte[] content, QosData qos)
key
- can be nullcontent
- can be nullqos
- Never null!public MsgUnit(MsgUnit old, KeyData key, byte[] content, QosData qos)
In order to keep up with performance we don't encapsulate the content in an immutable object. Keep in mind however that you should never (ever) change the content of a MsgUnit since such a change would affect the messages to all other reference of this message (e.g. subscribers) and therefore it might lead to unpredictable (and undesired) results.
Example:
byte[] content = msgUnit.getContent(); content[6] = (byte)'A'; // NOT ALLOWED !
old
- The MsgUnit to clonekey
- The new key to use, if you pass 'null' the old is shallow clonedcontent
- If you pass null note that the byte[] is a reference
to the original and you should not manipulate itqos
- The new qos to use, if you pass 'null' the old is shallow clonedMethod Detail |
---|
public Global getGlobal()
public void setGlobal(Global glob)
public MethodName getMethodName()
public void setContent(byte[] content)
public java.lang.String getKeyOid()
public java.lang.String getKey()
public byte[] getContent()
For performance reasons you get a reference to the internal byte[] buffer and no copy. Note that you are not allowed to manipulate the returned byte[].
public java.lang.String getContentStr() throws XmlBlasterException
Constants.CLIENTPROPERTY_CONTENT_CHARSET
,
XmlBlasterException
public java.lang.String getContentStrNoEx()
public java.lang.String getQos()
public byte[] getQosBytes()
public KeyData getKeyData()
public QosData getQosData()
public java.lang.String getLogId()
public java.lang.String getContentMime()
public java.lang.String getContentMimeExtended()
public boolean hasDomain()
public java.lang.String getDomain()
public MsgUnit getClone()
public MsgUnitRaw getMsgUnitRaw()
public boolean sameContent(byte[] newContent)
public long size()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toXml()
public java.lang.String toXml(java.lang.String extraOffset)
extraOffset
- indenting of tags for nice output
public java.lang.String toXml(java.lang.String extraOffset, boolean forceReadable)
extraOffset
- forceReadable
-
public java.lang.String toXml(java.lang.String extraOffset, int maxContentLen, boolean forceReadable)
extraOffset
- indenting of tags for nice outputmaxContentLen
- For huge content length you can choose to display
only the given size of the content (from the beginning), the rest is not dumped.public java.lang.String toXml(java.lang.String extraOffset, java.util.Properties props)
public final void toXml(java.io.OutputStream out, java.util.Properties props) throws java.io.IOException
java.io.IOException
private final void toXml(java.lang.String extraOffset, java.io.OutputStream out, java.util.Properties props) throws java.io.IOException
extraOffset
- Indenting, can be nullout
- Destinationprops
- Configuration settings
java.io.IOException
|
xmlBlaster 2.2.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |