示例#1
0
  private void escribeArchivo(List<String> lista, String ruta) {
    try {

      BufferedWriter escritor = new BufferedWriter(new FileWriter(ruta));

      for (String s : lista) {
        escritor.write(s);
      }

      escritor.close();

    } catch (IOException ex) {
      Logger.getLogger(Reportador.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
示例#2
0
 // Ende des Dokuments
 public void endDocument() {
   try {
     f.close();
   } catch (IOException e) {
     EfaUtil.foo();
   }
 }
示例#3
0
 // Anfang des Dokuments
 public void startDocument() {
   try {
     f.write("<?xml version=\"1.0\" encoding=\"" + Daten.ENCODING_UTF + "\"?>\n");
   } catch (IOException e) {
     EfaUtil.foo();
   }
 }
示例#4
0
 // Text innerhalb von Elementen
 public void characters(char[] ch, int start, int length) {
   if (skip) return;
   try {
     String s = new String(ch, start, length);
     if (s.indexOf('\n') >= 0 || s.indexOf(10) >= 0 || s.indexOf(13) >= 0) s = s.trim();
     if (s.length() > 0) f.write(s);
   } catch (IOException e) {
   }
 }
示例#5
0
  // Ende eines Elements
  public void endElement(String uri, String localName, String qname) {
    try {
      if (uri.equals("http://www.nmichael.de/elwiz")) { // elwiz-Element
        if (option != null && option.name.equals(localName)) option = null;
        skip = false;
      } else { // Normales Element
        if (skip) return;

        f.write("</" + qname + ">");
      }
    } catch (IOException e) {
    }
  }
示例#6
0
  // Beginn eines Element-Tags
  public void startElement(String uri, String localName, String qname, Attributes atts) {
    try {
      if (uri.equals("http://www.nmichael.de/elwiz")) {

        // Elemente des elwiz-Namensraums

        if (!localName.equals("option")) { // Hauptelement
          // Namen ermitteln
          String name = null;
          for (int i = 0; i < atts.getLength(); i++)
            if (atts.getLocalName(i).equals("name")) name = atts.getValue(i);

          // Element suchen
          for (int i = 0; i < options.size(); i++)
            if (((ElwizOption) options.get(i)).name.equals(name)) {
              this.option = (ElwizOption) options.get(i);
              break;
            }

        } else { // Unterelement

          // Position des Unterelements für Zugriff auf options-Vektor ermitteln
          int pos = -1;
          for (int i = 0; i < atts.getLength(); i++)
            if (atts.getLocalName(i).equals("pos")) pos = EfaUtil.string2int(atts.getValue(i), -1);

          if (option != null)
            switch (option.type) {
              case ElwizOption.O_OPTIONAL: // optional
                JCheckBox o1 = (JCheckBox) option.components.get(pos);
                if (!o1.isSelected()) skip = true;
                break;
              case ElwizOption.O_SELECT: // select
                JRadioButton o2 = (JRadioButton) option.components.get(pos);
                if (!o2.isSelected()) skip = true;
                ElwizSingleOption eso = (ElwizSingleOption) option.options.get(pos);
                if (!skip && eso.value != null) f.write(eso.value);
                break;
              case ElwizOption.O_VALUE: // value
                JTextField o3 = (JTextField) option.components.get(pos);
                f.write(o3.getText().trim());
                break;
            }
        }

      } else {

        // Elemente des XSLT-Namensraums

        if (skip) return; // Element unterdrücken?

        f.write("<" + qname);
        for (int i = 0; i < atts.getLength(); i++) {
          f.write(
              " "
                  + atts.getLocalName(i)
                  + "=\""
                  + EfaUtil.replace(atts.getValue(i), "<", "&lt;", true)
                  + "\"");
        }
        if (localName.equals("stylesheet"))
          f.write(
              " xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" xmlns:fo=\"http://www.w3.org/1999/XSL/Format\"");
        f.write(">");
      }
    } catch (IOException e) {
    }
  }