Exemplo n.º 1
0
    /**
     * Parser calls this for each element in a document.
     *
     * @param namespaceURI the namespace (not used)
     * @param localName the current tag we are parsing
     * @param qName ? (not used)
     * @param atts attributes for the current tag
     * @throws SAXException if there is a problem with the parser
     */
    public void startElement(String namespaceURI, String localName, String qName, Attributes atts)
        throws SAXException {
      currentKey = localName;
      elementBuffer = "";

      if (currentKey.equals("processStep")) {
        currentEntry = new ProvenanceEntry();
      } else if (currentKey.equals("program")) {
        currentEntry.setProgram(atts.getValue("version"), atts.getValue("build"));
      } else if (currentKey.equals("programArguments")) {
        currentEntry.setProgramArguments(atts.getValue("inputs"), atts.getValue("outputs"));
      } else if (currentKey.equals("platform")) {
        currentEntry.setPlatformVersion(atts.getValue("version"));
      } else if (currentKey.equals("compiler")) {
        currentEntry.setJavaVersion(atts.getValue("version"));
      }
    }
Exemplo n.º 2
0
    /**
     * Parser calls this when the end tag of each element is reached. Data collected in the
     * elementbuffer is generally saved to the image info.
     *
     * @param namespaceURI the namespace (not used)
     * @param localName the current tag we are parsing
     * @param qName ? (not used)
     * @throws SAXException if there is a problem with the parser
     */
    public void endElement(String namespaceURI, String localName, String qName)
        throws SAXException {
      currentKey = localName;

      if (currentKey.equals("program")) {
        currentEntry.setProgramName(elementBuffer);
      } else if (currentKey.equals("programArguments")) {
        currentEntry.setAction(elementBuffer);
      } else if (currentKey.equals("timeStamp")) {
        currentEntry.setTimeStamp(elementBuffer);
      } else if (currentKey.equals("user")) {
        currentEntry.setUser(elementBuffer);
      } else if (currentKey.equals("hostName")) {
        currentEntry.setHostName(elementBuffer);
      } else if (currentKey.equals("architecture")) {
        currentEntry.setArchitecture(elementBuffer);
      } else if (currentKey.equals("platform")) {
        currentEntry.setPlatform(elementBuffer);
      } else if (currentKey.equals("compiler")) {
        // last to be read in, so add to ProvenanceHolder
        holder.add(currentEntry);
      }
    }
Exemplo n.º 3
0
  /** Writes the data provenance into xml formatted file */
  public void writeXML() throws IOException {
    FileWriter fw;
    if (file.exists() == true) {
      file.delete();
      file = new File(fileDir + File.separator + fileName);
    }

    try {

      fw = new FileWriter(file);
      bw = new BufferedWriter(fw);

      Vector<XMLAttributes> atVector = new Vector<XMLAttributes>();

      bw.write(XML_HEADER);
      bw.newLine();
      bw.write(DATA_PROVENANCE);
      bw.newLine();

      openTag("provenance", true);

      int numEntries = pHolder.size();

      ProvenanceEntry entry;

      for (int i = 0; i < numEntries; i++) {
        entry = pHolder.elementAt(i);

        openTag("processStep", true);

        atVector.add(new XMLAttributes("version", entry.getMipavVersion()));
        this.closedTag("program", entry.getProgramName(), atVector);

        atVector.add(new XMLAttributes("inputs", entry.getProgramInputs()));
        closedTag("programArguments", entry.getAction(), atVector);

        closedTag("timeStamp", entry.getTimeStamp());

        closedTag("user", entry.getUser());

        closedTag("hostName", entry.getHostName());

        closedTag("architecture", entry.getArchitecture());

        atVector.add(new XMLAttributes("version", entry.getPlatformVersion()));
        closedTag("platform", entry.getPlatform(), atVector);

        atVector.add(new XMLAttributes("version", entry.getJavaVersion()));
        closedTag("compiler", "java", atVector);

        openTag("processStep", false);
      }

      openTag("provenance", false);
      bw.close();
    } catch (Exception e) {
      System.err.println("CAUGHT EXCEPTION WITHIN writeXML() of FileDataProvenance");
      e.printStackTrace();
    }
  }