示例#1
0
 /**
  * Runs the test case.
  *
  * @throws Throwable Any uncaught exception causes test to fail
  */
 public void runTest() throws Throwable {
   Document doc;
   CDATASection cdata1;
   CDATASection cdata2;
   CDATASection cdata3;
   boolean isEqual;
   doc = (Document) load("hc_staff", false);
   cdata1 = doc.createCDATASection("cdata");
   cdata2 = doc.createCDATASection("cdata");
   cdata3 = doc.createCDATASection("#CDATASection");
   isEqual = cdata1.isEqualNode(cdata2);
   assertTrue("nodeisequalnodeTrue29", isEqual);
   isEqual = cdata1.isEqualNode(cdata3);
   assertFalse("nodeisequalnodeFalse29", isEqual);
 }
示例#2
0
  /** @see com.levelonelabs.aim.XMLizable#writeState(Element) */
  public void writeState(Element emptyStateElement) {
    Document doc = emptyStateElement.getOwnerDocument();
    emptyStateElement.setAttribute("name", this.getName());
    emptyStateElement.setAttribute("group", this.getGroup());
    emptyStateElement.setAttribute("isBanned", Boolean.toString(this.isBanned()));

    Iterator roleit = roles.keySet().iterator();
    while (roleit.hasNext()) {
      String role = (String) roleit.next();
      Element roleElem = doc.createElement("role");
      roleElem.setAttribute("name", role);
      emptyStateElement.appendChild(roleElem);
    }

    Iterator prefs = preferences.keySet().iterator();
    while (prefs.hasNext()) {
      String pref = (String) prefs.next();
      Element prefElem = doc.createElement("preference");
      prefElem.setAttribute("name", pref);
      prefElem.setAttribute("value", (String) preferences.get(pref));
      emptyStateElement.appendChild(prefElem);
    }

    for (int i = 0; i < messages.size(); i++) {
      String message = (String) messages.get(i);
      Element messElem = doc.createElement("message");
      CDATASection data = doc.createCDATASection(message);
      messElem.appendChild(data);
      emptyStateElement.appendChild(messElem);
    }
  }
示例#3
0
  /**
   * Receive notification of cdata.
   *
   * <p>The Parser will call this method to report each chunk of character data. SAX parsers may
   * return all contiguous character data in a single chunk, or they may split it into several
   * chunks; however, all of the characters in any single event must come from the same external
   * entity, so that the Locator provides useful information.
   *
   * <p>The application must not attempt to read from the array outside of the specified range.
   *
   * <p>Note that some parsers will report whitespace using the ignorableWhitespace() method rather
   * than this one (validating parsers must do so).
   *
   * @param ch The characters from the XML document.
   * @param start The start position in the array.
   * @param length The number of characters to read from the array.
   * @see #ignorableWhitespace
   * @see org.xml.sax.Locator
   */
  public void cdata(char ch[], int start, int length) throws org.xml.sax.SAXException {
    if (isOutsideDocElem()
        && org.apache.xml.utils.XMLCharacterRecognizer.isWhiteSpace(ch, start, length))
      return; // avoid DOM006 Hierarchy request error

    String s = new String(ch, start, length);

    append(m_doc.createCDATASection(s));
  }
示例#4
0
  /**
   * Set the text as a CDATA section of a node.
   *
   * @param doc The document the node comes from.
   * @param node The node whichs CDATA section should be changed.
   * @param text The text to set.
   */
  public static void setCData(Document doc, Node node, String text) {
    Node cDataNode = getChild(node, "#cdata-section");

    if (cDataNode == null) {
      CDATASection cDataSection = doc.createCDATASection(text);
      node.appendChild(cDataSection);

    } else {
      cDataNode.setNodeValue(text);
    }
  }
示例#5
0
  /**
   * Retruns the xml string equivalent of this object
   *
   * @param document instance of Xml Document.
   * @return org.w3c.dom.Node
   * @exception FioranoException thrown in case of error.
   */
  protected Node toJXMLString(Document document) throws FioranoException {
    Node root0 = document.createElement("InPort");

    ((Element) root0).setAttribute("isSyncRequestType", "" + isSyncRequestType());

    Node child = null;

    child = XMLDmiUtil.getNodeObject("Name", m_strPortName, document);
    if (child != null) {
      root0.appendChild(child);
    }

    child = XMLDmiUtil.getNodeObject("Description", m_strDscription, document);
    if (child != null) {
      root0.appendChild(child);
    }

    if (m_strXSD != null) {
      Element elem = document.createElement("XSD");
      CDATASection cdata = document.createCDATASection(m_strXSD);

      elem.appendChild(cdata);
      root0.appendChild(elem);
    }

    child = XMLDmiUtil.getNodeObject("JavaClass", m_strJavaClass, document);
    if (child != null) {
      root0.appendChild(child);
    }

    if (m_params != null && m_params.size() > 0) {
      Enumeration _enum = m_params.elements();

      while (_enum.hasMoreElements()) {
        Param param = (Param) _enum.nextElement();
        if (!StringUtil.isEmpty(param.getParamName())
            && !StringUtil.isEmpty(param.getParamValue())) {
          Node paramNode = param.toJXMLString(document);

          root0.appendChild(paramNode);
        }
      }
    }

    return root0;
  }