Пример #1
0
 /**
  * Try to load the root
  *
  * @return
  */
 private static XMLElement getSettingsXMLRoot() {
   XMLElement e = new XMLElement();
   try {
     URL url = classLoaderInstance.getClass().getClassLoader().getResource("settings.xml");
     e.parseFromReader(new InputStreamReader(url.openConnection().getInputStream()));
   } catch (Exception ex) {
     ex.printStackTrace();
   }
   return e;
 }
Пример #2
0
 /**
  * Get the tools out of the root element
  *
  * @param root
  * @return
  */
 public static XMLElement getToolsXML() {
   XMLElement root = getSettingsXMLRoot();
   Vector<XMLElement> children = root.getChildren();
   for (XMLElement curElement : children) {
     if (curElement.getName().equalsIgnoreCase("TOOLS")) {
       return curElement;
     }
   }
   return null;
 }
 private static XMLElement loadXML(final String pAbsoluteFilePath) {
   final XMLElement mLocalXML = new XMLElement(new Hashtable(), false, false);
   try {
     mLocalXML.parseFromReader(
         new InputStreamReader(werkzeug.Util.getInputStream(pAbsoluteFilePath)));
   } catch (IOException ex) {
     System.err.println("### ERROR / couldn t read XML file." + ex);
   }
   return mLocalXML;
 }
 private static void saveXML(final String pAbsoluteFilePath, final XMLElement pXML) {
   try {
     final FileWriter mWriter = new FileWriter(new File(pAbsoluteFilePath));
     //            final String HEADER = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
     //            mWriter.append(HEADER);
     pXML.write(mWriter);
     mWriter.close();
   } catch (IOException ex) {
     ex.printStackTrace();
   }
 }
Пример #5
0
 public XMLElement serialize() {
   XMLElement element = new XMLElement();
   element.setName("svnrelease");
   element.addChild(releaseUrl.serialize());
   return element;
 }
Пример #6
0
 public void deserialize(XMLElement element) {
   if (element.getName().equalsIgnoreCase("svnrelease")) {
     releaseUrl = new StringNode();
     releaseUrl.deserialize(findChild(element, "releaseurl"));
   }
 }
  public HadoopInputDirGenerator(String propFileName, int noDataSet, boolean debug)
      throws Exception {
    this.propFileName = propFileName;
    this.debug = debug;

    Properties properties = new Properties();
    try {
      properties.load(new FileInputStream(this.propFileName));

    } catch (FileNotFoundException e) {
      // TODO Auto-generated catch block
      System.out.println("here");
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      System.out.println("here2");
      e.printStackTrace();
    }

    XMLParser xmlParser = new XMLParser();
    // Getting the path of the Dataset
    String graphsPath = properties.getProperty("path");
    // parsing the test set
    String testGraphsListPath = properties.getProperty("source");
    // parsing the training set
    String trainingGraphsListPath = properties.getProperty("target");

    XMLElement testXML = new XMLElement();
    FileReader testReader = new FileReader(testGraphsListPath);
    testXML.parseFromReader(testReader);
    Vector testListchildren = testXML.getChildren();
    XMLElement testRoot = (XMLElement) testListchildren.get(0);
    Enumeration testEnumerator = testRoot.enumerateChildren();
    String testGraphFileName = "";
    String testGraphClass = "";

    XMLElement trainingXML = new XMLElement();
    FileReader trainingReader = new FileReader(trainingGraphsListPath);
    trainingXML.parseFromReader(trainingReader);
    Vector trainingListchildren = trainingXML.getChildren();
    XMLElement trainingRoot = (XMLElement) trainingListchildren.get(0);

    String trainingGraphFileName = "";
    String trainingGraphClass = "";
    // Preparing the txt file ...
    PrintStream ps;

    File theDir = new File(properties.getProperty("path") + "inputs");

    // if the directory does not exist, create it
    if (!theDir.exists()) {
      System.out.println("creating directory: ");
      boolean result = theDir.mkdir();
      if (result) {
        System.out.println("DIR created");
      }
    }

    while (testEnumerator.hasMoreElements()) {
      XMLElement testChild = (XMLElement) testEnumerator.nextElement();
      testGraphFileName = (String) testChild.getAttribute("file", null);
      testGraphClass = (String) testChild.getAttribute("class", "NO_CLASS");
      Enumeration trainingEnumerator = trainingRoot.enumerateChildren();

      while (trainingEnumerator.hasMoreElements()) {
        XMLElement trainingChild = (XMLElement) trainingEnumerator.nextElement();
        trainingGraphFileName = (String) trainingChild.getAttribute("file", null);
        trainingGraphClass = (String) trainingChild.getAttribute("class", "NO_CLASS");
        ps =
            new PrintStream(
                properties.getProperty("path")
                    + "inputs/"
                    + testGraphFileName
                    + "-"
                    + trainingGraphFileName
                    + ".txt");
        System.out.println(
            noDataSet
                + "	"
                + testGraphFileName
                + "	"
                + trainingGraphFileName
                + "	"
                + testGraphClass
                + "	"
                + trainingGraphClass);
        ps.println(
            noDataSet
                + "	"
                + testGraphFileName
                + "	"
                + trainingGraphFileName
                + "	"
                + testGraphClass
                + "	"
                + trainingGraphClass);
        ps.close();
      }
    }
  }
 void addNode(final XMLElement pXMLNode) {
   mXML.addChild(pXMLNode);
 }
 public static void setVector3f(final XMLElement pXMLElement, Vector3f p) {
   pXMLElement.setAttribute("x", p.x);
   pXMLElement.setAttribute("y", p.y);
   pXMLElement.setAttribute("z", p.z);
 }