예제 #1
0
  public String getAttribute(String ns, String name) throws MbException {
    MbElement attr = getAttributeElement(ns, name);

    if (attr != null) {
      return attr.getValue().toString();
    } else {
      return null;
    }
  }
예제 #2
0
	private Object getProperty(String area, String name) throws MbException {
		MbElement valueElm = getMbElement().getFirstElementByPath(area + "/" + name);
		
		if (valueElm == null) {
			return null;
		} else {
			return valueElm.getValue();
		}
		
	}
예제 #3
0
	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");
		}		
	}
예제 #4
0
  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());
  }
예제 #5
0
  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);
    }
  }
예제 #6
0
  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]);
  }
예제 #7
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");
		}

	}
예제 #8
0
  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);
      }
    }
  }
예제 #9
0
	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);
		}
	}