Example #1
0
 public void parseChildren(Element e) {
   try {
     NodeList nl = e.getChildNodes();
     for (int i = 0; i < nl.getLength(); i++) {
       // parse Elements only
       if ((nl.item(i).getNodeType() == Node.ELEMENT_NODE)) {
         Element elm = (Element) nl.item(i);
         String tag = elm.getTagName();
         if (tag.equals("canvas")) {
           parseChildren(elm);
         } else if (tag.equals("label")) {
           parseLabel(elm);
         } else if (tag.equals("textfield")) {
           parseTextField(elm);
         } else if (tag.equals("button")) {
           parseButton(elm);
         } else if (tag.equals("textarea")) {
           parseTextArea(elm);
         } else if (tag.equals("progressbar")) {
           parseProgressBar(elm);
         }
       }
     }
   } catch (Exception ex) {
     ex.printStackTrace();
   }
 }
  /**
   * Runs the test case.
   *
   * @throws Throwable Any uncaught exception causes test to fail
   */
  public void runTest() throws Throwable {
    Document doc;
    NodeList elementList;
    Node employeeNode;
    Node childNode;
    NodeList childNodes;
    int nodeType;
    String childName;
    java.util.List actual = new java.util.ArrayList();

    java.util.List expected = new java.util.ArrayList();
    expected.add("em");
    expected.add("strong");
    expected.add("code");
    expected.add("sup");
    expected.add("var");
    expected.add("acronym");

    doc = (Document) load("hc_staff", false);
    elementList = doc.getElementsByTagName("p");
    employeeNode = elementList.item(1);
    childNodes = employeeNode.getChildNodes();
    for (int indexN1006C = 0; indexN1006C < childNodes.getLength(); indexN1006C++) {
      childNode = (Node) childNodes.item(indexN1006C);
      nodeType = (int) childNode.getNodeType();
      childName = childNode.getNodeName();

      if (equals(1, nodeType)) {
        actual.add(childName);
      } else {
        assertEquals("textNodeType", 3, nodeType);
      }
    }
    assertEqualsAutoCase("element", "elementNames", expected, actual);
  }
  public IXArchElement cloneElement(int depth) {
    synchronized (DOMUtils.getDOMLock(elt)) {
      Document doc = elt.getOwnerDocument();
      if (depth == 0) {
        Element cloneElt = (Element) elt.cloneNode(false);
        cloneElt = (Element) doc.importNode(cloneElt, true);
        AbstractChangeSetImpl cloneImpl = new AbstractChangeSetImpl(cloneElt);
        cloneImpl.setXArch(getXArch());
        return cloneImpl;
      } else if (depth == 1) {
        Element cloneElt = (Element) elt.cloneNode(false);
        cloneElt = (Element) doc.importNode(cloneElt, true);
        AbstractChangeSetImpl cloneImpl = new AbstractChangeSetImpl(cloneElt);
        cloneImpl.setXArch(getXArch());

        NodeList nl = elt.getChildNodes();
        int size = nl.getLength();
        for (int i = 0; i < size; i++) {
          Node n = nl.item(i);
          Node cloneNode = (Node) n.cloneNode(false);
          cloneNode = doc.importNode(cloneNode, true);
          cloneElt.appendChild(cloneNode);
        }
        return cloneImpl;
      } else /* depth = infinity */ {
        Element cloneElt = (Element) elt.cloneNode(true);
        cloneElt = (Element) doc.importNode(cloneElt, true);
        AbstractChangeSetImpl cloneImpl = new AbstractChangeSetImpl(cloneElt);
        cloneImpl.setXArch(getXArch());
        return cloneImpl;
      }
    }
  }
  /** childNodes, hasChildNodes. */
  public void testChildNodeList() {
    Document doc = Document.get();
    BodyElement body = doc.getBody();

    // <div>foo<button/>bar</div>
    DivElement div = doc.createDivElement();
    Text txt0 = doc.createTextNode("foo");
    ButtonElement btn0 = doc.createButtonElement();
    Text txt1 = doc.createTextNode("bar");

    body.appendChild(div);
    div.appendChild(txt0);
    div.appendChild(btn0);
    div.appendChild(txt1);

    NodeList<Node> children = div.getChildNodes();
    assertEquals(3, children.getLength());
    assertEquals(txt0, children.getItem(0));
    assertEquals(btn0, children.getItem(1));
    assertEquals(txt1, children.getItem(2));

    assertEquals(3, div.getChildCount());
    assertEquals(txt0, div.getChild(0));
    assertEquals(btn0, div.getChild(1));
    assertEquals(txt1, div.getChild(2));

    assertFalse(txt0.hasChildNodes());
    assertTrue(div.hasChildNodes());
  }
  /**
   * Pretty prints a node.
   *
   * @param doc The document the node comes from.
   * @param node The node that should be pretty printed.
   * @param prefix The prefix the node should get.
   */
  private static void prettyPrint(Document doc, Node node, String prefix) {
    String childPrefix = prefix + "  ";

    // Add the indenting to the children
    NodeList childList = node.getChildNodes();
    boolean hasChildren = false;
    for (int i = childList.getLength() - 1; i >= 0; i--) {
      Node child = childList.item(i);
      boolean isNormalNode = (!child.getNodeName().startsWith("#"));
      if (isNormalNode) {
        // Add the indenting to this node
        Node textNode = doc.createTextNode(childPrefix);
        node.insertBefore(textNode, child);

        // pretty print the child's children
        prettyPrint(doc, child, childPrefix);

        hasChildren = true;
      }
    }

    // Add the indenting to the end tag
    if (hasChildren) {
      Node textNode = doc.createTextNode(prefix);
      node.appendChild(textNode);
    }
  }
  // factory
  private static GenerationTarget createTarget(File templateFile, File root) {
    GenerationTarget target;

    // read XML document
    DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
    try {
      DocumentBuilder docBuilder = dbfac.newDocumentBuilder();
      Document doc = docBuilder.parse(templateFile);

      // get name
      NodeList nodes = doc.getElementsByTagName("templates");
      Node node = nodes.item(0);
      NamedNodeMap attrs = node.getAttributes();
      Node attr = attrs.getNamedItem("name");
      String templateName = attr.getNodeValue();
      target = new GenerationTarget(templateFile, root, templateName);

      // get class directives
      nodes = doc.getElementsByTagName("project");
      int nb = nodes.getLength();
      for (int i = 0; i < nb; i++) {
        node = nodes.item(i);
        createProjectDirective(target, node);
      }

    } catch (ParserConfigurationException ex) {
      target = null;
    } catch (IOException ex) {
      target = null;
    } catch (SAXException ex) {
      target = null;
    } // end try

    return target;
  }
Example #7
0
 public static String text(NodeList nodeList) {
   StringBuffer sb = new StringBuffer();
   for (int i = 0; i < nodeList.getLength(); i++) {
     sb.append(text(nodeList.item(i)));
   }
   return sb.toString();
 }
  /**
   * Runs the test case.
   *
   * @throws Throwable Any uncaught exception causes test to fail
   */
  public void runTest() throws Throwable {
    Document doc;
    NodeList genderList;
    Node genderNode;
    Node entText;
    EntityReference entReference;
    Node appendedChild;
    doc = (Document) load("staff", true);
    genderList = doc.getElementsByTagName("gender");
    genderNode = genderList.item(2);
    entReference = doc.createEntityReference("ent3");
    assertNotNull("createdEntRefNotNull", entReference);
    appendedChild = genderNode.appendChild(entReference);
    entText = entReference.getFirstChild();
    assertNotNull("entTextNotNull", entText);

    {
      boolean success = false;
      try {
        ((CharacterData) /*Node */ entText).deleteData(1, 3);
      } catch (DOMException ex) {
        success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR);
      }
      assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success);
    }
  }
Example #9
0
 private void checkReceived() {
   OnDemandData onDemandData;
   synchronized (aClass19_1370) {
     onDemandData = (OnDemandData) aClass19_1370.popHead();
   }
   while (onDemandData != null) {
     waiting = true;
     byte abyte0[] = null;
     if (clientInstance.caches[0] != null)
       abyte0 = clientInstance.caches[onDemandData.dataType + 1].decompress(onDemandData.id);
     if (!crcMatches(
         versions[onDemandData.dataType][onDemandData.id],
         crcs[onDemandData.dataType][onDemandData.id],
         abyte0)) abyte0 = null;
     synchronized (aClass19_1370) {
       if (abyte0 == null) {
         aClass19_1368.insertHead(onDemandData);
       } else {
         onDemandData.buffer = abyte0;
         synchronized (aClass19_1358) {
           aClass19_1358.insertHead(onDemandData);
         }
       }
       onDemandData = (OnDemandData) aClass19_1370.popHead();
     }
   }
 }
 private void validateRequires(Element parent) {
   NodeList list = getChildrenByName(parent, "requires"); // $NON-NLS-1$
   if (list.getLength() > 0) {
     validateImports((Element) list.item(0));
     reportExtraneousElements(list, 1);
   }
 }
Example #11
0
 public void load(Element domElement) {
   NodeList ch_list = domElement.getElementsByTagName("OGLParameter");
   for (int i = 0; i < ch_list.getLength(); ++i) {
     Element chEle = (Element) ch_list.item(i);
     addParameter(chEle.getAttribute("name"), chEle.getTextContent());
   }
 }
 /** @param element */
 private void validatePlugins(Element parent) {
   NodeList list = getChildrenByName(parent, "plugin"); // $NON-NLS-1$
   for (int i = 0; i < list.getLength(); i++) {
     if (fMonitor.isCanceled()) return;
     Element plugin = (Element) list.item(i);
     assertAttributeDefined(plugin, "id", CompilerFlags.ERROR); // $NON-NLS-1$
     assertAttributeDefined(plugin, "version", CompilerFlags.ERROR); // $NON-NLS-1$
     NamedNodeMap attributes = plugin.getAttributes();
     boolean isFragment =
         plugin.getAttribute("fragment").equals("true"); // $NON-NLS-1$ //$NON-NLS-2$
     for (int j = 0; j < attributes.getLength(); j++) {
       Attr attr = (Attr) attributes.item(j);
       String name = attr.getName();
       if (name.equals("id")) { // $NON-NLS-1$
         validatePluginID(plugin, attr, isFragment);
       } else if (name.equals("version")) { // $NON-NLS-1$
         validateVersionAttribute(plugin, attr);
         validateVersion(plugin, attr);
       } else if (name.equals("fragment") || name.equals("unpack")) { // $NON-NLS-1$ //$NON-NLS-2$
         validateBoolean(plugin, attr);
       } else if (!name.equals("os")
           && !name.equals("ws")
           && !name.equals("nl") // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
           && !name.equals("arch")
           && !name.equals("download-size") // $NON-NLS-1$ //$NON-NLS-2$
           && !name.equals("install-size")
           && !name.equals("filter")) { // $NON-NLS-1$ //$NON-NLS-2$
         reportUnknownAttribute(plugin, name, CompilerFlags.ERROR);
       }
     }
     validateUnpack(plugin);
   }
 }
Example #13
0
 private boolean existeAlbum(String titreAlbum, String nomArtiste, int anneeAlbum) {
   NodeList listeAlbums = document.getElementsByTagName("album");
   if (listeAlbums != null) {
     for (int i = 0; i < listeAlbums.getLength(); ++i) {
       String titre =
           ((Element) listeAlbums.item(i)).getElementsByTagName("titre").item(0).getTextContent();
       String artiste =
           ((Element) listeAlbums.item(i))
               .getElementsByTagName("artiste")
               .item(0)
               .getTextContent();
       int annee =
           Integer.parseInt(
               ((Element) listeAlbums.item(i))
                   .getElementsByTagName("annee")
                   .item(0)
                   .getTextContent());
       if (titre.equals(titreAlbum) && artiste.equals(nomArtiste) && annee == anneeAlbum)
         return true;
     }
   } else {
     return true;
   }
   return false;
 }
  // Lee la configuracion que se encuentra en conf/RegistryConf
  private void readConfXml() {
    try {
      File inputFile = new File("src/java/Conf/RegistryConf.xml");
      DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
      DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
      Document doc = dBuilder.parse(inputFile);
      doc.getDocumentElement().normalize();
      NodeList nList = doc.getElementsByTagName("RegistryConf");
      for (int i = 0; i < nList.getLength(); i++) {
        Node nNode = nList.item(i);
        if (nNode.getNodeType() == Node.ELEMENT_NODE) {
          Element eElement = (Element) nNode;
          RegistryConf reg = new RegistryConf();
          String aux;
          int idSensor;
          int value;
          aux = eElement.getElementsByTagName("idSensor").item(0).getTextContent();
          idSensor = Integer.parseInt(aux);
          reg.setIdSensor(idSensor);

          aux = eElement.getElementsByTagName("saveType").item(0).getTextContent();
          reg.setSaveTypeString(aux);

          aux = eElement.getElementsByTagName("value").item(0).getTextContent();
          value = Integer.parseInt(aux);
          reg.setValue(value);

          registryConf.add(reg);
          lastRead.put(idSensor, 0);
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Example #15
0
 @Override
 public Void visitFormalParameterList(FormalParameterList node) {
   String groupEnd = null;
   writer.print('(');
   NodeList<FormalParameter> parameters = node.getParameters();
   int size = parameters.size();
   for (int i = 0; i < size; i++) {
     FormalParameter parameter = parameters.get(i);
     if (i > 0) {
       writer.print(", ");
     }
     if (groupEnd == null && parameter instanceof DefaultFormalParameter) {
       if (parameter.getKind() == ParameterKind.NAMED) {
         groupEnd = "}";
         writer.print('{');
       } else {
         groupEnd = "]";
         writer.print('[');
       }
     }
     parameter.accept(this);
   }
   if (groupEnd != null) {
     writer.print(groupEnd);
   }
   writer.print(')');
   return null;
 }
Example #16
0
  private LinkedHashMap[] obtenerMapeos(CliGol cliGol, NodeList variables, String[] excluye) {

    LinkedHashMap<String, Object> mapa = new LinkedHashMap<String, Object>();

    LinkedHashMap<String, String> puntos = new LinkedHashMap<String, String>();

    List<String> ex = Arrays.asList(excluye);

    for (int i = 0; i < variables.getLength(); i++) {

      String nom = variables.item(i).getNodeName();

      if (!ex.contains(nom)) {

        String golMapdijo = GolMap.xmlGol(nom);

        String val = null;
        if (golMapdijo != null) {
          val = buscaValEnCli(golMapdijo, cliGol);
          mapa.put(nom, val);

          puntos.put(nom, variables.item(i).getTextContent());
        }
      }
    }

    return new LinkedHashMap[] {mapa, puntos};
  }
Example #17
0
  public static Element[] filterChildElements(Element parent, String ns, String lname) {
    /*
    way too noisy
            if (LOGGER.isDebugEnabled()) {
                StringBuilder buf = new StringBuilder(100);
                buf.append("XmlaUtil.filterChildElements: ");
                buf.append(" ns=\"");
                buf.append(ns);
                buf.append("\", lname=\"");
                buf.append(lname);
                buf.append("\"");
                LOGGER.debug(buf.toString());
            }
    */

    List<Element> elems = new ArrayList<Element>();
    NodeList nlst = parent.getChildNodes();
    for (int i = 0, nlen = nlst.getLength(); i < nlen; i++) {
      Node n = nlst.item(i);
      if (n instanceof Element) {
        Element e = (Element) n;
        if ((ns == null || ns.equals(e.getNamespaceURI()))
            && (lname == null || lname.equals(e.getLocalName()))) {
          elems.add(e);
        }
      }
    }
    return elems.toArray(new Element[elems.size()]);
  }
Example #18
0
  private void processPanel(Session session, Element element, HashMap additionalInformation) {
    panelElementPresent = true;
    String panelName = element.getAttribute("name");
    if (panelName == null) {
      panelName = "Panel" + panelCounter++;
    }

    List<Track> panelTracks = new ArrayList();
    NodeList elements = element.getChildNodes();
    for (int i = 0; i < elements.getLength(); i++) {
      Node childNode = elements.item(i);
      if (childNode.getNodeName().equalsIgnoreCase(SessionElement.DATA_TRACK.getText())
          || // Is this a track?
          childNode.getNodeName().equalsIgnoreCase(SessionElement.TRACK.getText())) {

        List<Track> tracks = processTrack(session, (Element) childNode, additionalInformation);
        if (tracks != null) {
          panelTracks.addAll(tracks);
        }
      } else {
        process(session, childNode, additionalInformation);
      }
    }

    TrackPanel panel = IGV.getInstance().getTrackPanel(panelName);
    panel.addTracks(panelTracks);
  }
Example #19
0
 private static Node xgetAt(Element element, int i) {
   if (hasChildElements(element, "*")) {
     NodeList nodeList = getChildElements(element, "*");
     return nodeList.item(i);
   }
   return null;
 }
Example #20
0
  /*
   * Output this item. Then, if the element has child elements, output each.
   */
  private void outputItem(Element e, PrintWriter out) {
    int chk = 0;
    HashMap collection = new HashMap();
    String key = null;
    Element collectionElement = null;
    log.fine("outputing item for " + e.getAttribute("name") + ":   " + e.getAttribute("query"));
    out.println("<item>");
    out.println("<name>" + e.getAttribute("name") + "</name>");
    if (e.getTagName().equalsIgnoreCase("collection")) {

      // change made by NETTY (change collectionlist to collection)
      out.println(
          "<query>collection="
              + e.getAttribute("col_id")
              + "&amp;xsl=metadata_to_html_full</query>");
    } else {
      out.println(
          "<query>owner=" + e.getAttribute("query") + "&amp;xsl=metadata_to_html_full</query>");
    }
    // now output children

    NodeList children = e.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
      Node child = children.item(i);
      if (child.getNodeType() == Node.ELEMENT_NODE) {
        chk++;
        outputItem((Element) child, out);
      }
    }

    out.println("</item>");
  }
  /**
   * Converts an XML element into an <code>EppCommandRenewXriName</code> object. The caller of this
   * method must make sure that the root node is of an EPP Command Renew entity for EPP XRI I-Name
   * object
   *
   * @param root root node for an <code>EppCommandRenewXriName</code> object in XML format
   * @return an <code>EppCommandRenewXriName</code> object, or null if the node is invalid
   */
  public static EppEntity fromXML(Node root) {
    EppCommandRenewXriName cmd = null;
    String iname = null;
    Calendar curExpDate = null;
    EppPeriod period = null;

    NodeList list = root.getChildNodes();
    for (int i = 0; i < list.getLength(); i++) {
      Node node = list.item(i);
      String name = node.getLocalName();
      if (name == null) {
        continue;
      }
      if (name.equals("iname")) {
        iname = EppUtil.getText(node);
      } else if (name.equals("curExpDate")) {
        curExpDate = EppUtil.getDate(node, true);
      } else if (name.equals("period")) {
        period = (EppPeriod) EppPeriod.fromXML(node);
      }
    }
    if (iname != null) {
      cmd = new EppCommandRenewXriName(iname, curExpDate, period, null);
    }

    return cmd;
  }
Example #22
0
 private void buildHierarchyDOM() {
   TransformerFactory factory = TransformerFactory.newInstance();
   StreamSource src =
       new StreamSource(
           this.getServletContext()
               .getResourceAsStream("/WEB-INF/classes/gpt/search/browse/ownerHierarchy.xml"));
   log.info("initializing src from stream " + src);
   try {
     Transformer t = factory.newTransformer();
     dom = new DOMResult();
     t.transform(src, dom);
     // now go thru tree, setting up the query attribute for each node
     Node tree = dom.getNode();
     NodeList children = tree.getChildNodes();
     log.info("dom tree contains " + children.getLength() + " nodes");
     for (int i = 0; i < children.getLength(); i++) {
       Node child = children.item(i);
       if (child.getNodeType() == Node.ELEMENT_NODE) {
         Element e = (Element) child;
         String query = computeQuery(e);
         e.setAttribute("query", query);
       }
     }
   } catch (Exception e) {
     log.severe("Could not init ownerHierarchy because exception thrown:");
     StringWriter sw = new StringWriter();
     e.printStackTrace(new PrintWriter(sw));
     log.severe(sw.toString());
   }
 }
Example #23
0
  /**
   * Pretty prints a node.
   *
   * @param doc The document the node comes from.
   * @param node The node that should be pretty printed.
   */
  public static void prettyPrint(Document doc, Node node) {
    // Get the text before the node and extract the indenting
    Node parent = node.getParentNode();

    String indenting = "";
    NodeList siblingList = parent.getChildNodes();
    for (int i = 1; i < siblingList.getLength(); i++) {
      Node sibling = siblingList.item(i);
      if (sibling == node) {
        Node nodeBefore = siblingList.item(i - 1);
        // Check whether this is a text node
        if (nodeBefore.getNodeName().equals("#text")) {
          // There is text before the node -> Extract the indenting
          String text = nodeBefore.getNodeValue();
          int newlinePos = text.lastIndexOf('\n');
          if (newlinePos != -1) {
            indenting = text.substring(newlinePos);
            if (indenting.trim().length() != 0) {
              // The indenting is no whitespace -> Forget it
              indenting = "";
            }
          }
        }
        break;
      }
    }

    // Now pretty print the node
    prettyPrint(doc, node, indenting);
  }
Example #24
0
 /*
  * If the element contains an attribute 'makeOnly' with a value of 'true',
  * create a child element before any existing children which will display a node
  * which will display only the elements records.
  * Compute the query attribute, which is the appended result of all of the children
  * appended to this element name. If noQuery=true. then do not generate a query term
  * for this element.
  */
 String computeQuery(Element e) {
   String query = "";
   if (!(e.getAttribute("noQuery").equalsIgnoreCase("true"))) {
     query = e.getAttribute("name");
   }
   String makeOnly = e.getAttribute("makeOnly");
   boolean madeOnly = false;
   NodeList children = e.getChildNodes();
   for (int i = 0; i < children.getLength(); i++) {
     Node child = children.item(i);
     if (child.getNodeType() == Node.ELEMENT_NODE) {
       if (makeOnly.equalsIgnoreCase("true") && !madeOnly) {
         // need to make an ...-Only node and populate it
         String onlyTagName = e.getTagName() + "-Only";
         Element only = ((Document) dom.getNode()).createElement(onlyTagName);
         only.setAttribute("name", e.getAttribute("name") + "-Only");
         only.setAttribute("query", e.getAttribute("name"));
         e.insertBefore(only, child);
         i++;
         madeOnly = true;
       }
       if (query.length() > 0) {
         query += ",";
       }
       query += computeQuery((Element) child);
     }
   }
   log.info("setting query for " + e.getNodeName() + "   " + query);
   e.setAttribute("query", query);
   return query;
 }
Example #25
0
  private void gatherNamespaces(Element element, List<URI> namespaceSources) throws SAXException {
    NamedNodeMap attributes = element.getAttributes();
    int attributeCount = attributes.getLength();

    for (int i = 0; i < attributeCount; i++) {
      Attr attribute = (Attr) attributes.item(i);
      String namespace = attribute.getNamespaceURI();

      if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespace)) {
        try {
          namespaceSources.add(new URI(attribute.getValue()));
        } catch (URISyntaxException e) {
          throw new SAXException(
              "Cannot validate this document with this class.  Namespaces must be valid URIs.  Found Namespace: '"
                  + attribute.getValue()
                  + "'.",
              e);
        }
      }
    }

    NodeList childNodes = element.getChildNodes();
    int childCount = childNodes.getLength();
    for (int i = 0; i < childCount; i++) {
      Node child = childNodes.item(i);

      if (child.getNodeType() == Node.ELEMENT_NODE) {
        gatherNamespaces((Element) child, namespaceSources);
      }
    }
  }
 public void test_creation() {
   ASTNode owner = argumentList();
   NodeList<ASTNode> list = new NodeList<ASTNode>(owner);
   assertNotNull(list);
   assertSize(0, list);
   assertSame(owner, list.getOwner());
 }
  public ArrayList<String> parseXML() throws Exception {
    ArrayList<String> ret = new ArrayList<String>();

    handshake();

    URL url =
        new URL(
            "http://mangaonweb.com/page.do?cdn="
                + cdn
                + "&cpn=book.xml&crcod="
                + crcod
                + "&rid="
                + (int) (Math.random() * 10000));
    String page = DownloaderUtils.getPage(url.toString(), "UTF-8", cookies);

    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    InputSource is = new InputSource(new StringReader(page));
    Document d = builder.parse(is);
    Element doc = d.getDocumentElement();

    NodeList pages = doc.getElementsByTagName("page");
    total = pages.getLength();
    for (int i = 0; i < pages.getLength(); i++) {
      Element e = (Element) pages.item(i);
      ret.add(e.getAttribute("path"));
    }

    return (ret);
  }
  private static Command parseCommand(Node n) {
    NamedNodeMap atts = n.getAttributes();
    String name = atts.getNamedItem("name").getNodeValue();
    String desc = atts.getNamedItem("description").getNodeValue();
    String command = atts.getNamedItem("command").getNodeValue();

    Command com = new Command(name, desc, command);

    NodeList children = n.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
      Node child = children.item(i);

      if (!child.getNodeName().equals("Argument")) continue;

      NamedNodeMap childAtts = child.getAttributes();
      String childName = childAtts.getNamedItem("name").getNodeValue();
      String childDesc = childAtts.getNamedItem("description").getNodeValue();
      String childVal = "";
      if (childAtts.getNamedItem("default") != null)
        childVal = childAtts.getNamedItem("default").getNodeValue();

      Argument arg = new Argument(childName, childDesc, childVal);

      com.addArgument(arg);
    }

    return com;
  }
  public static void vol(int issue_length, NodeList issue_node) {
    for (int i = 0; i < issue_length; i++) {
      Node nnode = issue_node.item(i);
      if (nnode.getNodeType() == Element.ELEMENT_NODE) {
        Element enode = (Element) nnode;

        NodeList article_node = enode.getElementsByTagName("article");
        int article_length = enode.getElementsByTagName("article").getLength();

        for (int j = 0; j < article_length; j++) {
          Node m = article_node.item(j);
          if (m.getNodeType() == Element.ELEMENT_NODE) {
            Element f = (Element) m;
            String title = f.getElementsByTagName("title").item(0).getTextContent();
            // System.out.println(title);
            if (title.equals("Research in Knowledge Base Management Systems.")) {
              // String article = f.getElementsByTagName("title").item(0).getTextContent();
              String endPage = f.getElementsByTagName("endPage").item(0).getTextContent();
              String initPage = f.getElementsByTagName("initPage").item(0).getTextContent();
              String vol_element = enode.getElementsByTagName("volume").item(0).getTextContent();
              String num_element = enode.getElementsByTagName("number").item(0).getTextContent();
              // System.out.println("Title: "+ title);
              System.out.println("Volume: " + vol_element);
              System.out.println("Number: " + num_element);
              System.out.println("Init Page: " + initPage);
              System.out.println("End Page: " + endPage);
            }
          }
        }
      }
    }
  }
Example #30
0
 public static final Map parseFrame(Node node) {
   NodeList bones = node.getChildNodes();
   Map bone_infos = new HashMap();
   for (int i = 0; i < bones.getLength(); i++) {
     Node bone = bones.item(i);
     if (bone.getNodeName().equals("transform")) {
       String name = bone.getAttributes().getNamedItem("name").getNodeValue();
       float[] matrix = new float[16];
       matrix[0 * 4 + 0] = getAttrFloat(bone, "m00");
       matrix[0 * 4 + 1] = getAttrFloat(bone, "m01");
       matrix[0 * 4 + 2] = getAttrFloat(bone, "m02");
       matrix[0 * 4 + 3] = getAttrFloat(bone, "m03");
       matrix[1 * 4 + 0] = getAttrFloat(bone, "m10");
       matrix[1 * 4 + 1] = getAttrFloat(bone, "m11");
       matrix[1 * 4 + 2] = getAttrFloat(bone, "m12");
       matrix[1 * 4 + 3] = getAttrFloat(bone, "m13");
       matrix[2 * 4 + 0] = getAttrFloat(bone, "m20");
       matrix[2 * 4 + 1] = getAttrFloat(bone, "m21");
       matrix[2 * 4 + 2] = getAttrFloat(bone, "m22");
       matrix[2 * 4 + 3] = getAttrFloat(bone, "m23");
       matrix[3 * 4 + 0] = getAttrFloat(bone, "m30");
       matrix[3 * 4 + 1] = getAttrFloat(bone, "m31");
       matrix[3 * 4 + 2] = getAttrFloat(bone, "m32");
       matrix[3 * 4 + 3] = getAttrFloat(bone, "m33");
       bone_infos.put(name, matrix);
     }
   }
   return bone_infos;
 }