public String getAttribute(String ns, String name) throws MbException { MbElement attr = getAttributeElement(ns, name); if (attr != null) { return attr.getValue().toString(); } else { return null; } }
private Object getProperty(String area, String name) throws MbException { MbElement valueElm = getMbElement().getFirstElementByPath(area + "/" + name); if (valueElm == null) { return null; } else { return valueElm.getValue(); } }
public static Rfh2Header remove(MbMessage msg) throws MbException { MbElement elm = msg.getRootElement().getFirstElementByPath("/MQRFH2"); if (elm != null) { elm.detach(); return new Rfh2Header(elm, true); } else { throw new NiceMbException("Failed to find Rfh2Header"); } }
public XmlElement createLastChild(String ns, String name) throws MbException { MbElement parent = getMbElement(); MbElement elm = parent.createElementAsLastChild(XmlUtil.getFolderElementType(parent), name, null); if (ns != null) { elm.setNamespace(ns); } return new XmlElement(elm, isReadOnly()); }
public void setAttribute(String ns, String name, String value) throws MbException { MbElement attr = getAttributeElement(ns, name); if (attr == null) { attr = getMbElement() .createElementAsFirstChild(XmlUtil.getAttributeType(getMbElement()), name, value); if (ns != null) { attr.setNamespace(ns); } } else { attr.setValue(value); } }
public XmlElement[] getChildByName(String ns, String name) throws MbException { // TODO change to XPath impl MbElement child = getMbElement().getFirstChild(); List childList = new ArrayList(); while (child != null) { if (name.equals(child.getName())) { if (ns != null && ns.equals(child.getNamespace())) { childList.add(new XmlElement(child, isReadOnly())); } } child = child.getNextSibling(); } return (XmlElement[]) childList.toArray(new XmlElement[0]); }
public static Rfh2Header create(MbMessage msg) throws MbException { if (has(msg)) { throw new NiceMbException("Already have RFH2 header"); } if (MqmdHeader.has(msg)) { MqmdHeader mqmd = MqmdHeader.wrap(msg, false); mqmd.setFormat(WmqFormat.MQ_RFH2); MbElement mqmdElm = mqmd.getMbElement(); MbElement elm = mqmdElm.createElementAfter("MQHRF2"); return new Rfh2Header(elm, false); } else { throw new NiceMbException("Can not find MQMD"); } }
public void evaluate(MbElement inElm, MbElement outElm) throws MbException { Object result = inElm.evaluateXPath(xpath); if (result instanceof List) { Iterator iterator = ((List) result).iterator(); while (iterator.hasNext()) { MbElement node = (MbElement) iterator.next(); forEachElement(node, outElm); } } }
private void setProperty(String area, String name, Object value) throws MbException { checkReadOnly(); MbElement areaElm = getMbElement().getFirstElementByPath(area); if (areaElm == null) { areaElm = getMbElement().createElementAsLastChild(MbElement.TYPE_NAME); areaElm.setName(area); } MbElement valueElm = areaElm.getFirstElementByPath(name); if (valueElm == null) { areaElm.createElementAsLastChild(MbElement.TYPE_NAME, name, value); } else { valueElm.setValue(value); } }