Package com.attivio.sdk.esb
Class MessageId
- java.lang.Object
-
- com.attivio.sdk.esb.MessageId
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.lang.Comparable<MessageId>
- Direct Known Subclasses:
GroupedMessageId
public class MessageId extends java.lang.Object implements java.lang.Comparable<MessageId>, java.lang.Cloneable, java.io.Serializable
Container for a multi-part message id. MessageIds can have multiple parts which allows for the addition of child messages while maintaining the original order. A multi-part message id can be viewed as an array of integers where the size of the array is the number of parts. All messages which have a part n are considered children of a message with a part n-1. Initially all messages start with a single part. For example:Initial messages:
1
2
3
Then, message 1 adds some children, message 2 adds children which add children (shown sorted):
1
1.1
1.2
2
2.1
2.2
2.2.1
2.2.2
3- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected int[]
id
protected int
numChildren
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MessageId
addChild()
MessageId
clone()
int
compareTo(MessageId o)
a comparison based on the id parts of the message id only.MessageId
createNextSibling()
boolean
equals(java.lang.Object obj)
int
getNumberOfChildren()
int
getNumberOfParts()
int
getPart(int idx)
int[]
getParts()
int
hashCode()
static MessageId
invalidMessageId()
Used for auditing failed message creationboolean
isParentOf(MessageId child)
static int[]
parseMessageId(java.lang.String value)
Parsevalue
as a message id.void
setNumberOfChildren(int numChildren)
Sets the number of expected children.java.lang.String
stringValue()
a non-overridable toString()java.lang.String
toString()
static java.lang.String
toString(int[] value)
Representvalue
as a message id string.static MessageId
valueOf(java.lang.String value)
Converts the result of MessageId.toString() to a MessageId
-
-
-
Constructor Detail
-
MessageId
public MessageId(int... id)
constructor, used to create a single- or multi-part message id.NOTE!! Use of this constructor will not create a multi-part message ids with the correct number of children set. To reliably create children the
addChild()
method should be used on the parent MessageId.- Parameters:
id
- list of parts, none of which can be 0.
-
MessageId
public MessageId(int[] parentParts, int childId)
constructor, used to create a multi-part message id.- Parameters:
parentParts
- the parts for the parentchildId
- the id for the child
-
-
Method Detail
-
invalidMessageId
public static MessageId invalidMessageId()
Used for auditing failed message creation- Returns:
- a MessageId representing a message with no ID when a message ID is required
-
getNumberOfChildren
public int getNumberOfChildren()
- Returns:
- the number of children of this MessageId
-
setNumberOfChildren
public void setNumberOfChildren(int numChildren)
Sets the number of expected children.- Parameters:
numChildren
-
-
getNumberOfParts
public int getNumberOfParts()
- Returns:
- the number of parts for this MessageId
-
isParentOf
public boolean isParentOf(MessageId child)
- Parameters:
child
-- Returns:
- true if this is the parent of
child
.
-
getParts
public int[] getParts()
- Returns:
- the parts for this id. Modification of this return value will change the source MessageId
-
getPart
public int getPart(int idx)
- Parameters:
idx
-- Returns:
- part
idx
of the MessageId
-
createNextSibling
public MessageId createNextSibling()
- Returns:
- the next MessageId having the same number of parts as this MessageId with all parts identical excepting the last which will be incremented by 1.
-
addChild
public MessageId addChild()
- Returns:
- the next child for this MessageId. This MessageId will be updated to indicate it now has an additional child.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
compareTo
public int compareTo(MessageId o)
a comparison based on the id parts of the message id only. children counters are not compared.- Specified by:
compareTo
in interfacejava.lang.Comparable<MessageId>
- Returns:
- -1,0, or 1 suitable for sorting MessageIds
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
stringValue
public final java.lang.String stringValue()
a non-overridable toString()- Returns:
- string value of the id
-
valueOf
public static MessageId valueOf(java.lang.String value)
Converts the result of MessageId.toString() to a MessageId
-
toString
public static java.lang.String toString(int[] value)
Representvalue
as a message id string.
-
parseMessageId
public static int[] parseMessageId(java.lang.String value)
Parsevalue
as a message id.
-
clone
public MessageId clone()
- Overrides:
clone
in classjava.lang.Object
-
-