예제 #1
0
 public static String getXmlNodeValue(Node node) {
   if (node.getNodeType() != Node.ELEMENT_NODE) {
     return null;
   }
   String ret = "";
   NodeList textNodes = node.getChildNodes();
   for (int i = 0; i < textNodes.getLength(); i++) {
     Node n = textNodes.item(i);
     if (n.getNodeType() == Node.TEXT_NODE
         && n.getNodeValue().replaceAll("[ \\n\\t\\r]", "").length() > 0) {
       ret += n.getNodeValue();
     } else if (n.getNodeType() == Node.CDATA_SECTION_NODE) {
       ret += n.getNodeValue();
     }
   }
   return ret.length() == 0 ? null : ret.replaceAll("^\\s+", "").replaceAll("\\s+$", "");
 }
예제 #2
0
    /** return the text content of a tag in a xml document. */
    public static String getXmlNodeValue(Document doc, String tag) {
      if (doc == null) return null;

      NodeList list = doc.getElementsByTagName(tag);
      if (list.getLength() == 0) return null;

      Node node = list.item(0);
      if (node.getNodeType() != Node.ELEMENT_NODE) return null;

      String ret = "";
      NodeList textNodes = node.getChildNodes();
      for (int i = 0; i < textNodes.getLength(); i++) {
        Node n = textNodes.item(i);
        if (n.getNodeType() == Node.TEXT_NODE
            && n.getNodeValue().replaceAll("[ \\n\\t\\r]", "").length() > 0)
          ret += n.getNodeValue();
      }
      return ret.length() == 0 ? null : ret;
    }
예제 #3
0
파일: Feed.java 프로젝트: CzarnyPeter/cxf
    private void parseEntries(@Nonnull final Document document) {
      NodeList entryNodes = document.getElementsByTagName(ENTRY_TAG);

      if (entryNodes != null) {
        Node entryNode;
        for (int i = 0; i < entryNodes.getLength(); i++) {
          entryNode = entryNodes.item(i);
          assert entryNode != null;

          if (entryNode.getNodeType() == ELEMENT_NODE) {
            entries.add(new Entry(entryNodes.item(i)));
          }
        }
        Collections.reverse(entries);
      }
    }
 private void loadSortFields(Element rootNode, HashMap<String, DisplayColumnWidget> displayCols) {
   NodeList nodes = rootNode.getChildNodes();
   for (int index = 0; index < nodes.getLength(); index++) {
     Node node = nodes.item(index);
     if (node.getNodeType() == Node.ELEMENT_NODE
         && node.getNodeName().equalsIgnoreCase(XmlBuilder.NODE_NAME_FIELD)) {
       Element element = (Element) node;
       DisplayColumnWidget widget =
           displayCols.get(element.getAttribute(XmlBuilder.ATTRIBUTE_NAME_NAME));
       int sortOrder =
           Integer.parseInt(element.getAttribute(XmlBuilder.ATTRIBUTE_NAME_SORT_ORDER));
       widget.setSortOrder(sortOrder);
       changeSortOrder(widget, sortOrder);
     }
   }
 }
  private HashMap<String, DisplayColumnWidget> loadDisplayFields(
      Element rootNode, HashMap<String, DisplayColumnWidget> displayCols) {

    NodeList nodes = rootNode.getChildNodes();
    for (int index = 0; index < nodes.getLength(); index++) {
      Node node = nodes.item(index);
      if (node.getNodeType() == Node.ELEMENT_NODE
          && node.getNodeName().equalsIgnoreCase(XmlBuilder.NODE_NAME_FIELD)) {
        Element element = (Element) node;
        DisplayColumnWidget widget = addColumn(this);
        widget.setName(element.getAttribute(XmlBuilder.ATTRIBUTE_NAME_NAME));
        widget.setText(element.getAttribute(XmlBuilder.ATTRIBUTE_NAME_TEXT));
        widget.setAggregateFunction(element.getAttribute(XmlBuilder.ATTRIBUTE_NAME_AGG_FUNC));

        displayCols.put(widget.getName(), widget);
      }
    }

    return displayCols;
  }