Ejemplo n.º 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;
    }
  }
Ejemplo n.º 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();
		}
		
	}
Ejemplo n.º 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");
		}		
	}
Ejemplo n.º 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());
  }
Ejemplo n.º 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);
    }
  }
Ejemplo n.º 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]);
  }
Ejemplo n.º 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");
		}

	}
Ejemplo n.º 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);
      }
    }
  }
Ejemplo n.º 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);
		}
	}