Class MbElement
- java.lang.Object
-
- com.ibm.broker.plugin.MbElement
-
public class MbElement extends java.lang.ObjectMbElement represents the syntax elements in the logical (hierarchical) view of the message. Methods are provided for navigating and modifying the hierarchy.
When creating a new message from scratch, it is important that the parser-owning folders (elements whose parent is the root element) are created using only the following methods passing in the parser name as the argument:getParent()^ | +-------------+ | |getPreviousSibling()<--| MbElement |-->getNextSibling()| | +-------------+ | | v vgetFirstChild()getLastChild()createElementAfter(parserName)createElementBefore(parserName)createElementAsLastChild(parserName)createElementAsFirstChild(parserName)createElementAsLastChildFromBitstream()
Warning: caching MbElement objects over multiple message flow invocations is unsupported because the internal state may be reset at the end of the current message invocation.
-
-
Field Summary
Fields Modifier and Type Field and Description static intTYPE_NAMEA name element has associated with it a string, which is the name of the element.static intTYPE_NAME_VALUEA name-value element is an optimization of the case where a name element contains only a value element and nothing else.static intTYPE_UNKNOWNThe element type is undefined.static intTYPE_VALUEA value element has a value associated with it.static intVALIDATE_COMPLETEVALIDATE_COMPLETE requests complete validation.static intVALIDATE_CONTENTVALIDATE_CONTENT requests validation of the message content.static intVALIDATE_CONTENT_AND_VALUEVALIDATE_CONTENT_AND_VALUE requests validation of the message content and values.static intVALIDATE_DEFERREDVALIDATE_DEFERRED requests deferred validation.static intVALIDATE_EXCEPTIONVALIDATE_EXCEPTION requests validation failures are thrown as an exception.static intVALIDATE_EXCEPTIONLISTVALIDATE_EXCEPTIONLIST requests validation failures are sent to the ExceptionList.static intVALIDATE_IMMEDIATEVALIDATE_IMMEDIATE requests immediate validation.static intVALIDATE_LOCAL_ERRORVALIDATE_LOCAL_ERROR requests validation failures are logged.static intVALIDATE_NONEVALIDATE_NONE requests no validation is performed.static intVALIDATE_ROOT_BITSTREAMThe Validation constants represent the allowed control options which are used when parsing or writing (between a bitstream and a structure in the logical view of the message).static intVALIDATE_USERTRACEVALIDATE_USERTRACE requests validation failures are logged to UserTrace.static intVALIDATE_VALUEVALIDATE_VALUE requests validation of the message values.static intVALUE_STATE_INVALIDReturned bygetValueState().static intVALUE_STATE_UNDEFINEDReturned bygetValueState().static intVALUE_STATE_VALIDReturned bygetValueState().
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description voidaddAfter(MbElement element)Adds an unattached syntax element after this element.voidaddAsFirstChild(MbElement element)Adds an unattached syntax element as the first of this element.voidaddAsLastChild(MbElement element)Adds an unattached syntax element as the last of this element.voidaddBefore(MbElement element)Adds an unattached syntax element before this element.MbElementcopy()voidcopyElementTree(MbElement element)Copies the element tree from the element passed as an argument to the current element.MbElementcreateElementAfter(int type)Creates a new syntax element and inserts it after this element.MbElementcreateElementAfter(int type, java.lang.String name, java.lang.Object value)Creates a new syntax element and inserts it after this element.MbElementcreateElementAfter(java.lang.String parserName)Creates a new syntax element, inserts it after this element, and associates it with the specified parser class name.MbElementcreateElementAsFirstChild(int type)Creates a new syntax element as the first child of this element.MbElementcreateElementAsFirstChild(int type, java.lang.String name, java.lang.Object value)Creates a new syntax element as the first child of this element.MbElementcreateElementAsFirstChild(java.lang.String parserName)Creates a new syntax element as the first child of this element, and associates it with the specified parser class name.MbElementcreateElementAsLastChild(int type)Creates a new syntax element as the last child of this element.MbElementcreateElementAsLastChild(int type, java.lang.String name, java.lang.Object value)Creates a new syntax element as the last child of this element.MbElementcreateElementAsLastChild(java.lang.String parserName)Creates a new syntax element as the last child of this element, and associates it with the specified parser class name.MbElementcreateElementAsLastChildFromBitstream(byte[] bitstream, java.lang.String parserName, java.lang.String messageType, java.lang.String messageSet, java.lang.String messageFormat, int encoding, int ccsid, int options)Creates a new syntax element tree as the last child of this element, and associates it with the specified parser.MbElementcreateElementBefore(int type)Creates a new syntax element and inserts it before this element.MbElementcreateElementBefore(int type, java.lang.String name, java.lang.Object value)Creates a new syntax element and inserts it before this element.MbElementcreateElementBefore(java.lang.String parserName)Creates a new syntax element, inserts it before this element, and associates it with the specified parser class name.voiddelete()Detaches and destroys a portion of a message tree, allowing its memory to be reused.voiddetach()Detaches this element from the syntax element tree.java.lang.ObjectevaluateXPath(MbXPath xpath)Evaluates the XPath 1.0 expression with the current element as the context node.java.lang.ObjectevaluateXPath(MbXPath xpath, MbXPathVariables xpathVariables)Evaluates the XPath 1.0 expression with the current element as the context node.java.lang.ObjectevaluateXPath(java.lang.String expression)Evaluates the XPath 1.0 expression with the current element as the context node.java.lang.ObjectevaluateXPath(java.lang.String expression, MbNamespaceBindings namespaceBindings)Evaluates the XPath 1.0 expression with the current element as the context node.java.lang.ObjectevaluateXPath(java.lang.String expression, MbNamespaceBindings namespaceBindings, MbXPathVariables xpathVariables)Evaluates the XPath 1.0 expression with the current element as the context node.java.lang.ObjectevaluateXPath(java.lang.String expression, MbXPathVariables xpathVariables)Evaluates the XPath 1.0 expression with the current element as the context node.MbElement[]getAllElementsByPath(java.lang.String path)Deprecated.Path selection should be done using the XPath 1.0 methods.org.w3c.dom.NodegetDOMNode()Returns this MbElement as an instance of the org.w3c.dom.Node interfaceMbElementgetFirstChild()Returns the syntax element representing the first child of this element.MbElementgetFirstElementByPath(java.lang.String path)Gets the first element matching the path specification.MbElementgetLastChild()Returns the syntax element representing the last child of this element.java.lang.StringgetName()Returns the name of the element.java.lang.StringgetNamespace()Returns the namespace URI of the element.MbElementgetNextSibling()Returns the syntax element representing the next sibling (right sibling) of this element.MbElementgetParent()Returns the syntax element representing the parent of this element.java.lang.StringgetParserClassName()Gets the name of the parser associated with the element.intgetParserContext()Deprecated.getSpecificType()should be used instead.MbElementgetPreviousSibling()Returns the syntax element representing the previous sibling (left sibling) of this element.intgetSpecificType()Returns the full type information of this element including the parser specific type.intgetType()Gets the generic type of the element.java.lang.ObjectgetValue()Gets the value of the element as a java Object.java.lang.StringgetValueAsString()Gets the value of the element as a java String.intgetValueState()Gets the state of the value of the element.booleanis(MbElement comparisonElement)is: Returns true if the MbElement actually refers to the same element in the logical message tree.booleanisReadOnly()Returns true if this element is part of the message that is read only.voidsetName(java.lang.String name)Sets the name of the element, any previous name is overwritten.voidsetNamespace(java.lang.String namespace)Sets the namespace URI of the element, any previous namespace is overwritten.voidsetSpecificType(int type)Sets the full type information for this element including the parser specific type.voidsetValue(java.lang.Object value)Sets the value of the element as a java Object.byte[]toBitstream(java.lang.String messageType, java.lang.String messageSet, java.lang.String messageFormat, int encoding, int ccsid, int options)Returns the bit stream representation of the element.java.lang.StringtoString()Returns a String representation of the MbElement.
-
-
-
Field Detail
-
VALUE_STATE_UNDEFINED
public static final int VALUE_STATE_UNDEFINED
Returned bygetValueState(). Indicates the value is undefined.- See Also:
- Constant Field Values
-
VALUE_STATE_VALID
public static final int VALUE_STATE_VALID
Returned bygetValueState(). Indicates the value is valid.- See Also:
- Constant Field Values
-
VALUE_STATE_INVALID
public static final int VALUE_STATE_INVALID
Returned bygetValueState(). Indicates the value is invalid.- See Also:
- Constant Field Values
-
TYPE_UNKNOWN
public static final int TYPE_UNKNOWN
The element type is undefined.- See Also:
- Constant Field Values
-
TYPE_NAME
public static final int TYPE_NAME
A name element has associated with it a string, which is the name of the element.- See Also:
- Constant Field Values
-
TYPE_VALUE
public static final int TYPE_VALUE
A value element has a value associated with it.- See Also:
- Constant Field Values
-
TYPE_NAME_VALUE
public static final int TYPE_NAME_VALUE
A name-value element is an optimization of the case where a name element contains only a value element and nothing else. The element contains both a name and value.- See Also:
- Constant Field Values
-
VALIDATE_ROOT_BITSTREAM
public static final int VALIDATE_ROOT_BITSTREAM
The Validation constants represent the allowed control options which are used when parsing or writing (between a bitstream and a structure in the logical view of the message). Only one option from each of the groups 1 - 4 can be specified, with the exception of ValidateValue and ValidateContent, which can be used together to obtain the content and value validation. If you do not specify an option within a group, the option with the zero value from that group is used. See the topic "Validation properties" in the Knowledge Center (topic: ac18870) for more details. VALIDATE_ROOT_BITSTREAM requests parsing or serializing of an entire message tree. This option belongs to Group 1: Bitstream Options.- See Also:
- Constant Field Values
-
VALIDATE_CONTENT_AND_VALUE
public static final int VALIDATE_CONTENT_AND_VALUE
VALIDATE_CONTENT_AND_VALUE requests validation of the message content and values. This option belongs to Group 2: Validation Options.- See Also:
- Constant Field Values
-
VALIDATE_VALUE
public static final int VALIDATE_VALUE
VALIDATE_VALUE requests validation of the message values. This option belongs to Group 2: Validation Options.- See Also:
- Constant Field Values
-
VALIDATE_CONTENT
public static final int VALIDATE_CONTENT
VALIDATE_CONTENT requests validation of the message content. This option belongs to Group 2: Validation Options.- See Also:
- Constant Field Values
-
VALIDATE_NONE
public static final int VALIDATE_NONE
VALIDATE_NONE requests no validation is performed. This option belongs to Group 2: Validation Options.- See Also:
- Constant Field Values
-
VALIDATE_EXCEPTIONLIST
public static final int VALIDATE_EXCEPTIONLIST
VALIDATE_EXCEPTIONLIST requests validation failures are sent to the ExceptionList. This option belongs to Group 3: Validation Failure Options.- See Also:
- Constant Field Values
-
VALIDATE_EXCEPTION
public static final int VALIDATE_EXCEPTION
VALIDATE_EXCEPTION requests validation failures are thrown as an exception. This option belongs to Group 3: Validation Failure Options.- See Also:
- Constant Field Values
-
VALIDATE_LOCAL_ERROR
public static final int VALIDATE_LOCAL_ERROR
VALIDATE_LOCAL_ERROR requests validation failures are logged. This option belongs to Group 3: Validation Failure Options.- See Also:
- Constant Field Values
-
VALIDATE_USERTRACE
public static final int VALIDATE_USERTRACE
VALIDATE_USERTRACE requests validation failures are logged to UserTrace. This option belongs to Group 3: Validation Failure Options.- See Also:
- Constant Field Values
-
VALIDATE_COMPLETE
public static final int VALIDATE_COMPLETE
VALIDATE_COMPLETE requests complete validation. This option belongs to Group 4: Validation Timing Options.- See Also:
- Constant Field Values
-
VALIDATE_IMMEDIATE
public static final int VALIDATE_IMMEDIATE
VALIDATE_IMMEDIATE requests immediate validation. This option belongs to Group 4: Validation Timing Options.- See Also:
- Constant Field Values
-
VALIDATE_DEFERRED
public static final int VALIDATE_DEFERRED
VALIDATE_DEFERRED requests deferred validation. This option belongs to Group 4: Validation Timing Options.- See Also:
- Constant Field Values
-
-
Method Detail
-
isReadOnly
public boolean isReadOnly()
Returns true if this element is part of the message that is read only.
-
createElementAfter
public MbElement createElementAfter(int type) throws MbException
Creates a new syntax element and inserts it after this element. The new element becomes the next sibling of this element and shares the same parent. Do not use this method when creating a message body folder (such as XML, XMLNS, MRM, MIME, BLOB). This method should be used only when the message body folder has been created. To create the message body folder, usecreateElementAfter(parserName)- Parameters:
type- The type of syntax element to be created. This must be either a valid specific type value for the associated parser or one of the following generic types:-
TYPE_NAME -
TYPE_VALUE -
TYPE_NAME_VALUE
-
- Returns:
- The new element.
- Throws:
MbException
-
createElementAfter
public MbElement createElementAfter(java.lang.String parserName) throws MbException
Creates a new syntax element, inserts it after this element, and associates it with the specified parser class name. The new element becomes the next sibling of this element and shares the same parent.The portion of the syntax element tree that is owned by the parser may only have its effective root at the first generation of elements (that is, as immediate children of root). The user-defined node interface does not restrict the ability to create a subtree that appears to be owned by a different parser. However, it is not possible to serialize these element trees into a bit stream when outputting a message.
- Parameters:
parserName- The name of the parser class. The supplied parser constants give values for some of the IBM supplied parsers. For example,MbBLOB.PARSER_NAME.- Returns:
- The new element.
- Throws:
MbException
-
createElementAfter
public MbElement createElementAfter(int type, java.lang.String name, java.lang.Object value) throws MbException
Creates a new syntax element and inserts it after this element. The new element becomes the next sibling of this element and shares the same parent. Do not use this method when creating a message body folder (such as XML, XMLNS, MRM, MIME, BLOB). This method should be used only when the message body folder has been created. To create the message body folder, usecreateElementAfter(parserName)- Parameters:
type- The type of syntax element to be created. This must be either a valid specific type value for the associated parser or one of the following generic types:-
TYPE_NAME -
TYPE_VALUE -
TYPE_NAME_VALUE
-
name- The name of the new element.value- The value of the new element as a Java Object. This must be one of the types:-
MbDate -
MbTime -
MbTimestamp -
Boolean -
byte[] -
String -
Integer -
Double -
BitSet
-
- Returns:
- The new element.
- Throws:
MbException
-
createElementBefore
public MbElement createElementBefore(int type) throws MbException
Creates a new syntax element and inserts it before this element. The new element becomes the previous sibling of this element and shares the same parent. Do not use this method when creating a message body folder (such as XML, XMLNS, MRM, MIME, BLOB). This method should be used only when the message body folder has been created. To create the message body folder, usecreateElementBefore(parserName)- Parameters:
type- The type of syntax element to be created. This must be either a valid specific type value for the associated parser or one of the following generic types:-
TYPE_NAME -
TYPE_VALUE -
TYPE_NAME_VALUE
-
- Returns:
- The new element.
- Throws:
MbException
-
createElementBefore
public MbElement createElementBefore(java.lang.String parserName) throws MbException
Creates a new syntax element, inserts it before this element, and associates it with the specified parser class name. The new element becomes the previous sibling of this element and shares the same parent.The portion of the syntax element tree that is owned by the parser may only have its effective root at the first generation of elements (that is, as immediate children of root). The user-defined node interface does not restrict the ability to create a subtree that appears to be owned by a different parser. However, it is not possible to serialize these element trees into a bit stream when outputting a message.
- Parameters:
parserName- The name of the parser class. The supplied parser constants give values for some of the IBM supplied parsers. For example,MbBLOB.PARSER_NAME.- Returns:
- The new element.
- Throws:
MbException
-
createElementBefore
public MbElement createElementBefore(int type, java.lang.String name, java.lang.Object value) throws MbException
Creates a new syntax element and inserts it before this element. The new element becomes the previous sibling of this element and shares the same parent. Do not use this method when creating a message body folder (such as XML, XMLNS, MRM, MIME, BLOB). This method should be used only when the message body folder has been created. To create the message body folder, usecreateElementBefore(parserName)- Parameters:
type- The type of syntax element to be created. This must be either a valid specific type value for the associated parser or one of the following generic types:-
TYPE_NAME -
TYPE_VALUE -
TYPE_NAME_VALUE
-
name- The name of the new element.value- The value of the new element as a Java Object. This must be one of the types:-
MbDate -
MbTime -
MbTimestamp -
Boolean -
byte[] -
String -
Integer -
Double -
BitSet
-
- Returns:
- The new element.
- Throws:
MbException
-
createElementAsFirstChild
public MbElement createElementAsFirstChild(int type) throws MbException
Creates a new syntax element as the first child of this element. Do not use this method when creating a message body folder (such as XML, XMLNS, MRM, MIME, BLOB). This method should be used only when the message body folder has been created. To create the message body folder, usecreateElementAsFirstChild(parserName)- Parameters:
type- The type of syntax element to be created. This must be either a valid specific type value for the associated parser or one of the following generic types:-
TYPE_NAME -
TYPE_VALUE -
TYPE_NAME_VALUE
-
- Returns:
- The new element.
- Throws:
MbException
-
createElementAsFirstChild
public MbElement createElementAsFirstChild(java.lang.String parserName) throws MbException
Creates a new syntax element as the first child of this element, and associates it with the specified parser class name.The portion of the syntax element tree that is owned by the parser may only have its effective root at the first generation of elements (that is, as immediate children of root). The user-defined node interface does not restrict the ability to create a subtree that appears to be owned by a different parser. However, it is not possible to serialize these element trees into a bit stream when outputting a message.
- Parameters:
parserName- The name of the parser class. The supplied parser constants give values for some of the IBM supplied parsers. For example,MbBLOB.PARSER_NAME.- Returns:
- The new element.
- Throws:
MbException
-
createElementAsFirstChild
public MbElement createElementAsFirstChild(int type, java.lang.String name, java.lang.Object value) throws MbException
Creates a new syntax element as the first child of this element. Do not use this method when creating a message body folder (such as XML, XMLNS, MRM, MIME, BLOB). This method should be used only when the message body folder has been created. To create the message body folder, usecreateElementAsFirstChild(parserName)- Parameters:
type- The type of syntax element to be created. This must be either a valid specific type value for the associated parser or one of the following generic types:-
TYPE_NAME -
TYPE_VALUE -
TYPE_NAME_VALUE
-
name- The name of the new element.value- The value of the new element as a Java Object. This must be one of the types:-
MbDate -
MbTime -
MbTimestamp -
Boolean -
byte[] -
String -
Integer -
Double -
BitSet
-
- Returns:
- The new element.
- Throws:
MbException
-
createElementAsLastChild
public MbElement createElementAsLastChild(int type) throws MbException
Creates a new syntax element as the last child of this element. Do not use this method when creating a message body folder (such as XML, XMLNS, MRM, MIME, BLOB). This method should be used only when the message body folder has been created. To create the message body folder, usecreateElementAsLastChild(parserName)- Parameters:
type- The type of syntax element to be created. This must be either a valid specific type value for the associated parser or one of the following generic types:-
TYPE_NAME -
TYPE_VALUE -
TYPE_NAME_VALUE
-
- Returns:
- The new element.
- Throws:
MbException
-
createElementAsLastChild
public MbElement createElementAsLastChild(java.lang.String parserName) throws MbException
Creates a new syntax element as the last child of this element, and associates it with the specified parser class name.The portion of the syntax element tree that is owned by the parser may only have its effective root at the first generation of elements (that is, as immediate children of root). The user-defined node interface does not restrict the ability to create a subtree that appears to be owned by a different parser. However, it is not possible to serialize these element trees into a bit stream when outputting a message.
- Parameters:
parserName- The name of the parser class. The supplied parser constants give values for some of the IBM supplied parsers. For example,MbBLOB.PARSER_NAME.- Returns:
- The new element.
- Throws:
MbException
-
createElementAsLastChild
public MbElement createElementAsLastChild(int type, java.lang.String name, java.lang.Object value) throws MbException
Creates a new syntax element as the last child of this element. Do not use this method when creating a message body folder (such as XML, XMLNS, MRM, MIME, BLOB). This method should be used only when the message body folder has been created. To create the message body folder, usecreateElementAsLastChild(parserName)- Parameters:
type- The type of syntax element to be created. This must be either a valid specific type value for the associated parser or one of the following generic types:-
TYPE_NAME -
TYPE_VALUE -
TYPE_NAME_VALUE
-
name- The name of the new element.value- The value of the new element as a Java Object. This must be one of the types:-
MbDate -
MbTime -
MbTimestamp -
Boolean -
byte[] -
String -
Integer -
Double -
BitSet
-
- Returns:
- The new element.
- Throws:
MbException
-
getName
public java.lang.String getName() throws MbExceptionReturns the name of the element.- Returns:
- The name of the element.
- Throws:
MbException
-
setName
public void setName(java.lang.String name) throws MbExceptionSets the name of the element, any previous name is overwritten.- Parameters:
name- The new name of the element.- Throws:
MbException
-
getNamespace
public java.lang.String getNamespace() throws MbExceptionReturns the namespace URI of the element.- Returns:
- The namespace URI of the element.
- Throws:
MbException
-
setNamespace
public void setNamespace(java.lang.String namespace) throws MbExceptionSets the namespace URI of the element, any previous namespace is overwritten.- Parameters:
namespace- The new namespace URI of the element.- Throws:
MbException
-
getType
public int getType() throws MbExceptionGets the generic type of the element. Values are:-
TYPE_NAME -
TYPE_VALUE -
TYPE_NAME_VALUE -
TYPE_UNKNOWN
- Returns:
- Element type.
- Throws:
MbException
-
-
getParserContext
public int getParserContext() throws MbExceptionDeprecated.getSpecificType()should be used instead.Gets parser specific information for this element. In the 'C' interface this is refered to as the Specific Type.- Returns:
- Parser specific information for this element
- Throws:
MbException
-
getSpecificType
public int getSpecificType() throws MbExceptionReturns the full type information of this element including the parser specific type.- Returns:
- The full parser specific type of this element
- Throws:
MbException
-
setSpecificType
public void setSpecificType(int type) throws MbExceptionSets the full type information for this element including the parser specific type. Knowledge of type values for the parser is required to use this method. Type values for the generic XML parsers are given in theMbXML,MbXMLNSandMbXMLNSCclasses.- Parameters:
type- The full parser specific type for this element- Throws:
MbException
-
getValue
public java.lang.Object getValue() throws MbExceptionGets the value of the element as a java Object. This can be one of the types:-
MbDate -
MbTime -
MbTimestamp -
Boolean -
byte[] -
String -
Integer32-bit values. -
Long64-bit values. -
Double -
BigDecimal -
BitSet
- Returns:
- Java object representing the value of the element.
- Throws:
MbException
-
-
getValueAsString
public java.lang.String getValueAsString() throws MbExceptionGets the value of the element as a java String.- Returns:
- Java String representing the value of the element.
- Throws:
MbException
-
setValue
public void setValue(java.lang.Object value) throws MbExceptionSets the value of the element as a java Object. This can be one of the types:-
MbDate -
MbTime -
MbTimestamp -
Boolean -
byte[] -
String -
Integer32-bit values. -
Long64-bit values. -
Double -
BigDecimal -
BitSet
- Parameters:
value- The java Object representing the value of the element.- Throws:
MbException
-
-
getValueState
public int getValueState() throws MbExceptionGets the state of the value of the element. Return values are:-
VALUE_STATE_UNDEFINED -
VALUE_STATE_VALID -
VALUE_STATE_INVALID
- Returns:
- The state of the value.
- Throws:
MbException
-
-
getParserClassName
public java.lang.String getParserClassName() throws MbExceptionGets the name of the parser associated with the element.- Returns:
- The name of the parser, or null of there is no associated parser.
- Throws:
MbException
-
getParent
public MbElement getParent() throws MbException
Returns the syntax element representing the parent of this element.- Returns:
- The parent
MbElement - Throws:
MbException
-
getNextSibling
public MbElement getNextSibling() throws MbException
Returns the syntax element representing the next sibling (right sibling) of this element.- Returns:
- The next sibling MbElement.
- Throws:
MbException
-
getPreviousSibling
public MbElement getPreviousSibling() throws MbException
Returns the syntax element representing the previous sibling (left sibling) of this element.- Returns:
- The previous sibling MbElement.
- Throws:
MbException
-
getFirstChild
public MbElement getFirstChild() throws MbException
Returns the syntax element representing the first child of this element.- Returns:
- The first child of the element.
- Throws:
MbException
-
getLastChild
public MbElement getLastChild() throws MbException
Returns the syntax element representing the last child of this element.- Returns:
- The last child of the element.
- Throws:
MbException
-
evaluateXPath
public java.lang.Object evaluateXPath(java.lang.String expression) throws MbExceptionEvaluates the XPath 1.0 expression with the current element as the context node. The return type depends on the expression and can be one of:BooleanDoubleStringjava.util.Listof MbElement objects representing an XPath 1.0 nodeset
- Parameters:
expression- The XPath 1.0 expression.- Throws:
MbException- - An exception was thrown during the compilation of the expression.
-
evaluateXPath
public java.lang.Object evaluateXPath(java.lang.String expression, MbNamespaceBindings namespaceBindings) throws MbExceptionEvaluates the XPath 1.0 expression with the current element as the context node. The return type depends on the expression and can be one of:BooleanDoubleStringjava.util.Listof MbElement objects representing an XPath 1.0 nodeset
- Parameters:
expression- The XPath 1.0 expression.namespaceBindings- Associated object containing the namespace prefix to URI mappings for this expression.- Throws:
MbException- - An exception was thrown during the compilation of the expression.
-
evaluateXPath
public java.lang.Object evaluateXPath(java.lang.String expression, MbXPathVariables xpathVariables) throws MbExceptionEvaluates the XPath 1.0 expression with the current element as the context node. The return type depends on the expression and can be one of:BooleanDoubleStringjava.util.Listof MbElement objects representing an XPath 1.0 nodeset
- Parameters:
expression- The XPath 1.0 expression.xpathVariables- Associated object containing the variable bindings for this expression.- Throws:
MbException- - An exception was thrown during the compilation of the expression.
-
evaluateXPath
public java.lang.Object evaluateXPath(java.lang.String expression, MbNamespaceBindings namespaceBindings, MbXPathVariables xpathVariables) throws MbExceptionEvaluates the XPath 1.0 expression with the current element as the context node. The return type depends on the expression and can be one of:BooleanDoubleStringjava.util.Listof MbElement objects representing an XPath 1.0 nodeset
If the expression contains variable references, these variables must be assigned values. This is done with the xpathVariables parameter. The MbXPathVariables object must have an entry for each variable used in the XPath expression.
- Parameters:
expression- The XPath 1.0 expression.namespaceBindings- Associated object containing the namespace prefix to URI mappings for this expression.xpathVariables- Associated object containing the variable bindings for this expression.- Throws:
MbException- - An exception was thrown during the compilation of the expression.
-
evaluateXPath
public java.lang.Object evaluateXPath(MbXPath xpath) throws MbException
Evaluates the XPath 1.0 expression with the current element as the context node. The return type depends on the expression and can be one of:BooleanDoubleStringjava.util.Listof MbElement objects representing an XPath 1.0 nodeset
- Parameters:
xpath- The MbXPath object representing the XPath 1.0 expression.- Throws:
MbException- - An exception was thrown during the compilation of the expression.
-
evaluateXPath
public java.lang.Object evaluateXPath(MbXPath xpath, MbXPathVariables xpathVariables) throws MbException
Evaluates the XPath 1.0 expression with the current element as the context node. The return type depends on the expression and can be one of:BooleanDoubleStringjava.util.Listof MbElement objects representing an XPath 1.0 nodeset
- Parameters:
xpath- The MbXPath object representing the XPath 1.0 expression.xpathVariables- Associated object containing the variable bindings for this expression.- Throws:
MbException- - An exception was thrown during the compilation of the expression.
-
getFirstElementByPath
public MbElement getFirstElementByPath(java.lang.String path) throws MbException
Gets the first element matching the path specification.The format of the path specification is the same as that described in
getAllElementsByPathexcept that the descendant separator ('//') is not supported. This method returns the first element matched by the path specification only and is intended for use when you know the exact unique path to an element in the tree. In this case, this method is far more efficient than callinggetAllElementsByPathand selecting the first element from the array.Example paths:
itemselect the first child element named 'item' of the current element. /MQMD/ReplyToQselect the element representing the reply-to queue in the MQMD header. - Returns:
- The element specified by the path
- Throws:
MbException
-
getAllElementsByPath
public MbElement[] getAllElementsByPath(java.lang.String path) throws MbException
Deprecated. Path selection should be done using the XPath 1.0 methods.Get all the elements matching the path specificationThe path is a list of steps separated by a slash '/' character. Each step moves the selection pointer further into the element tree using the following rules:
name selects all children of the current element whose name attribute is name. * selects all children of the current element. . selects the current element. .. selects the parent of the current element. The steps can also be separated by a double slash ('//'), which causes all descendants of the current node to be searched rather than just the children. Descendants are children, children of children and so on.
Paths are relative to the current element unless they start with a /, in which case they are absolute (that is, they are relative to the root element of the message).
Examples: (click on (xml...) to show the result on an XML message)
itemselects all the child elements named 'item' of the current element. (xml...) order/itemselects all grandchildren named 'item' that have a parent named 'order'. (xml...) ../itemselects all siblings named 'item' (children of the parent). (xml...) order//itemselects all 'item' descendants of all children named 'order'. (xml...) order/*selects all the children of all children named 'order'. (xml...) //itemselects all elements named 'item' in the whole message. (xml...) .//itemselects all elements named 'item' which are descendants of the current element. (xml...) /MQMD/ReplyToQselect the element representing the reply-to queue in the MQMD header. - Returns:
- An array of all elements matched by the path specification.
- Throws:
MbException
-
addAfter
public void addAfter(MbElement element) throws MbException
Adds an unattached syntax element after this element. The currently unattached syntax element, and any child elements it might possess, is connected to the syntax element tree after the target (this) element. The newly added element becomes the next sibling of this element. The target (this) element must be attached to a tree (that is, it must have a parent element).- Parameters:
element- The currently unattached element to be added.- Throws:
MbException
-
addBefore
public void addBefore(MbElement element) throws MbException
Adds an unattached syntax element before this element. The currently unattached syntax element, and any child elements it might possess, is connected to the syntax element tree before the target (this) element. The newly added element becomes the previous sibling of this element. The target (this) element must be attached to a tree (that is, it must have a parent element).- Parameters:
element- The currently unattached element to be added.- Throws:
MbException
-
addAsFirstChild
public void addAsFirstChild(MbElement element) throws MbException
Adds an unattached syntax element as the first of this element. The currently unattached syntax element, and any child elements it might possess, is connected to the syntax element tree as the first child of the target (this) element. The target (this) element need not be attached.- Parameters:
element- The currently unattached element to be added.- Throws:
MbException
-
addAsLastChild
public void addAsLastChild(MbElement element) throws MbException
Adds an unattached syntax element as the last of this element. The currently unattached syntax element, and any child elements it might possess, is connected to the syntax element tree as the last child of the target (this) element. The target (this) element need not be attached.- Parameters:
element- The currently unattached element to be added.- Throws:
MbException
-
copy
public MbElement copy() throws MbException
- Throws:
MbException
-
copyElementTree
public void copyElementTree(MbElement element) throws MbException
Copies the element tree from the element passed as an argument to the current element. Only the child elements of the source element are copied. Before the copy is performed, all existing child elements of the target (this) element are deleted, to be replaced by the child elements of the source element.- Parameters:
element- Source element for copy.- Throws:
MbException
-
detach
public void detach() throws MbExceptionDetaches this element from the syntax element tree. The element is detached from its parent and siblings, but any child elements are left attached. Calling detach on the root element of a message or an element that is already detached will have no effect.- Throws:
MbException
-
delete
public void delete() throws MbExceptionDetaches and destroys a portion of a message tree, allowing its memory to be reused. This method is particularly useful when handling very large messages.- Throws:
MbException
-
is
public boolean is(MbElement comparisonElement)
is: Returns true if the MbElement actually refers to the same element in the logical message tree.- Parameters:
comparisonElement- The element being compared.- Returns:
- The boolean indicating if they are the same.
-
toBitstream
public byte[] toBitstream(java.lang.String messageType, java.lang.String messageSet, java.lang.String messageFormat, int encoding, int ccsid, int options) throws MbExceptionReturns the bit stream representation of the element. This method causes the parser associated with the element to serialize the element and all its children. This method can only be called on the message body, i.e. the last child of the message root.- Parameters:
messageType- The message type definition used to create the bit stream from the element tree. A value of null will cause this parameter to be ignored.messageSet- The message set definition used to create the bit stream from the element tree. A value of null will cause this parameter to be ignored.messageFormat- The message format definition used to create the bit stream from the element tree. A value of null will cause this parameter to be ignored.encoding- The encoding to use when writing the bit stream. A special value of 0 may be supplied to indicate that the queue manager's encoding should be used.ccsid- The coded character set identifier to use when writing the bit stream. A special value of 0 may be supplied to indicate that the queue manager's ccsid should be used. A ccsid of -1 indicates that the bit stream is to be generated using ccsid information contained in the subtree consisting of the field pointed to by the element and its children. Currently no parsers support this option.options- This parameter controls the validation options used when creating the bitstream. A value of 0 means no validation is to be performed. For a list of valid options see the VALIDATE_* constants defined in MbElement.- Returns:
- The message bit stream.
- Throws:
MbException
-
createElementAsLastChildFromBitstream
public MbElement createElementAsLastChildFromBitstream(byte[] bitstream, java.lang.String parserName, java.lang.String messageType, java.lang.String messageSet, java.lang.String messageFormat, int encoding, int ccsid, int options) throws MbException
Creates a new syntax element tree as the last child of this element, and associates it with the specified parser. The new syntax element tree is populated by parsing the specified bit stream. This method can only be used to create a message body i.e. last child of message root.- Parameters:
bitstream- The bit stream to be parsed and added to the element tree.parserName- The name of the parser class to use to parse the bit stream. The same parser must be used to parse the whole bit stream.messageType- The message type definition used to create the element tree from the bit stream. A value of null will cause this parameter to be ignored.messageSet- The message set definition used to create the element tree from the bit stream. A value of null will cause this parameter to be ignored.messageFormat- The message format definition used to create the element tree from the bit stream. A value of null will cause this parameter to be ignored.encoding- The encoding to use when parsing the bit stream. A special value of 0 may be supplied to indicate that the queue manager's encoding should be used.ccsid- The coded character set identifier to use when parsing the bit stream. This parameter is mandatory. A special value of 0 may be supplied to indicate that the queue manager's ccsid should be used.options- This parameter controls the validation options used when parsing the bitstream. A value of 0 means no validation is to be performed. For a list of valid options see the VALIDATE_* constants defined in MbElement.- Throws:
MbException
-
getDOMNode
public org.w3c.dom.Node getDOMNode() throws MbExceptionReturns this MbElement as an instance of the org.w3c.dom.Node interface- Throws:
MbException
-
toString
public java.lang.String toString()
Returns a String representation of the MbElement. This string is for debug use only; its format is not guaranteed to stay the same between releases.- Overrides:
toStringin classjava.lang.Object- Returns:
- String representing the element.
-
-