예제 #1
0
  @Override
  public VPackage parse() {

    logger.debug("Starting parsing package: " + xmlFile.getAbsolutePath());

    long startParsing = System.currentTimeMillis();

    try {
      Document document = getDocument();
      Element root = document.getDocumentElement();

      _package = new VPackage(xmlFile);

      Node name = root.getElementsByTagName(EL_NAME).item(0);
      _package.setName(name.getTextContent());
      Node descr = root.getElementsByTagName(EL_DESCRIPTION).item(0);
      _package.setDescription(descr.getTextContent());

      NodeList list = root.getElementsByTagName(EL_CLASS);

      boolean initPainters = false;
      for (int i = 0; i < list.getLength(); i++) {
        PackageClass pc = parseClass((Element) list.item(i));
        if (pc.getPainterName() != null) {
          initPainters = true;
        }
      }

      if (initPainters) {
        _package.initPainters();
      }

      logger.info(
          "Parsing the package '{}' finished in {}ms.\n",
          _package.getName(),
          (System.currentTimeMillis() - startParsing));
    } catch (Exception e) {
      collector.collectDiagnostic(e.getMessage(), true);
      if (RuntimeProperties.isLogDebugEnabled()) {
        e.printStackTrace();
      }
    }

    try {
      checkProblems("Error parsing package file " + xmlFile.getName());
    } catch (Exception e) {
      return null;
    }

    return _package;
  }
예제 #2
0
 public double getDoubleContent(double defaultValue) {
   String c = node.getTextContent();
   if (c != null) {
     try {
       return Double.parseDouble(c);
     } catch (NumberFormatException nfe) {
     }
   }
   return defaultValue;
 }
예제 #3
0
 public long getLongContent(long defaultValue) {
   String c = node.getTextContent();
   if (c != null) {
     try {
       return Long.parseLong(c);
     } catch (NumberFormatException nfe) {
     }
   }
   return defaultValue;
 }
예제 #4
0
 /** @param defaultValue the default value of the attribute */
 public float getFloatContent(float defaultValue) {
   return PApplet.parseFloat(node.getTextContent(), defaultValue);
 }
예제 #5
0
 /** @param defaultValue the default value of the attribute */
 public int getIntContent(int defaultValue) {
   return PApplet.parseInt(node.getTextContent(), defaultValue);
 }
예제 #6
0
 public String getContent(String defaultValue) {
   String s = node.getTextContent();
   return (s != null) ? s : defaultValue;
 }
예제 #7
0
 /**
  * Return the #PCDATA content of the element. If the element has a combination of #PCDATA content
  * and child elements, the #PCDATA sections can be retrieved as unnamed child objects. In this
  * case, this method returns null.
  *
  * @webref xml:method
  * @brief Gets the content of an element
  * @return the content.
  * @see XML#getIntContent()
  * @see XML#getFloatContent()
  */
 public String getContent() {
   return node.getTextContent();
 }