Examples of XmlWriter


Examples of jimm.util.XMLWriter

* Writes the contents of this report as an XML file.
*
* @param fileName a file name string
*/
public void writeFile(String fileName) {
    XMLWriter out = null;
    try {
  out = new XMLWriter(new OutputStreamWriter(new FileOutputStream(fileName),
                  XML_JAVA_ENCODING));
  writeXML(out);
  out.close();
    }
    catch (IOException ioe) {
  ErrorHandler.error(I18N.get("Report.write_err") + ' ' + fileName, ioe,
         I18N.get("Report.write_err_title"));
    }
    finally {
  if (out != null) out.close();
    }
}
View Full Code Here

Examples of jreepad.io.XmlWriter

            encoding = document.getEncoding();

          // Write to either HJT or XML
          JreepadWriter writer;
          if(fileType == JreepadPrefs.FILETYPE_XML)
            writer = new XmlWriter();
          else if (fileType == JreepadPrefs.FILETYPE_XML_ENCRYPTED)
          {
              String password = document.getPassword();
              if (password == null || askForFilename)
                  password = PasswordDialog.showPasswordDialog(true);
              if (password == null)
              {
                  successful = false; // "Cancel" was pressed
                  return;
              }
              EncryptedWriter encryptedWriter = new EncryptedWriter(new XmlWriter());
              encryptedWriter.setPassword(password);
              writer = encryptedWriter;
              document.setPassword(password);
          }
          else
View Full Code Here

Examples of net.n3.nanoxml.XMLWriter

  {
    BufferedOutputStream os =
      new BufferedOutputStream(new FileOutputStream(file));
    try
    {
      XMLWriter wtr = new XMLWriter(os);
      wtr.write(_rootElement, true);
    }
    finally
    {
      os.close();
    }
View Full Code Here

Examples of net.sf.joafip.util.XmlWriter

      throw new StoreException(exception);
    }
    final BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(
        outputStream);
    try {
      xmlWriter = new XmlWriter(bufferedOutputStream);
    } catch (XmlWriterException exception) {
      try {
        outputStream.close();
      } catch (IOException exception2) {
        logger.error("closing after error", exception2);
View Full Code Here

Examples of net.sf.myjaut.xml.XmlWriter

   @Override
   public StringBuffer getXml() throws PagingException {
      try {
         return new StringWriter() {
            {
               new XmlWriter(this) {
                  {
                     openTag(xt.getTableName());
                     for (int row = getIndexFirstRecordOnPage() - 1; row < getIndexLastRecordOnPage(); row++)
                        ((XmlWriter)this).write(xt.get(row).getXml().toString());
                     closeTag(xt.getTableName());
View Full Code Here

Examples of net.sf.robocode.serialization.XmlWriter

    FileOutputStream fos = null;
    BufferedOutputStream bos = null;
    ZipOutputStream zos = null;
    ObjectOutputStream oos = null;
    OutputStreamWriter osw = null;
    XmlWriter xwr = null;

    FileInputStream fis = null;
    BufferedInputStream bis = null;
    ObjectInputStream ois = null;

    final boolean isbin = format == BattleRecordFormat.BINARY || format == BattleRecordFormat.BINARY_ZIP;
    final boolean isxml = format == BattleRecordFormat.XML || format == BattleRecordFormat.XML_ZIP;
    Calendar calendar = Calendar.getInstance();

    try {
      fos = new FileOutputStream(recordFilename);
      bos = new BufferedOutputStream(fos, 1024 * 1024);

      if (format == BattleRecordFormat.BINARY) {
        oos = new ObjectOutputStream(bos);
      } else if (format == BattleRecordFormat.BINARY_ZIP) {
        zos = new ZipOutputStream(bos);
        zos.putNextEntry(new ZipEntry(dateFormat.format(calendar.getTime()) + "-robocode.br"));
        oos = new ObjectOutputStream(zos);
      } else if (format == BattleRecordFormat.XML) {
        final Charset utf8 = Charset.forName("UTF-8");

        osw = new OutputStreamWriter(bos, utf8);
        xwr = new XmlWriter(osw, true);
      } else if (format == BattleRecordFormat.XML_ZIP) {
        final Charset utf8 = Charset.forName("UTF-8");

        zos = new ZipOutputStream(bos);
        zos.putNextEntry(new ZipEntry(dateFormat.format(calendar.getTime()) + "-robocode.xml"));

        osw = new OutputStreamWriter(zos, utf8);
        xwr = new XmlWriter(osw, false);
      }

      if (isbin) {
        oos.writeObject(recordInfo);
      } else if (isxml) {
        xwr.startDocument();
        xwr.startElement("record");
        xwr.writeAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
        if (options.shortAttributes) {
          xwr.writeAttribute("xsi:noNamespaceSchemaLocation", "battleRecordS.xsd");
        } else {
          xwr.writeAttribute("xsi:noNamespaceSchemaLocation", "battleRecord.xsd");
        }
        recordInfo.writeXml(xwr, options);
        xwr.startElement("turns");
      }

      if (recordInfo.turnsInRounds != null) {
        fis = new FileInputStream(tempFile);
        bis = new BufferedInputStream(fis, 1024 * 1024);
        ois = new ObjectInputStream(bis);

        for (int i = 0; i < recordInfo.turnsInRounds.length; i++) {
          if (recordInfo.turnsInRounds[i] > 0) {
            for (int j = 0; j <= recordInfo.turnsInRounds[i] - 1; j++) {
              try {
                TurnSnapshot turn = (TurnSnapshot) ois.readObject();

                if (j != turn.getTurn()) {
                  throw new Error("Something rotten");
                }

                if (isbin) {
                  turn.stripDetails(options);
                  oos.writeObject(turn);
                } else if (isxml) {
                  turn.writeXml(xwr, options);
                }
              } catch (ClassNotFoundException e) {
                logError(e);
              }
            }
            if (isbin) {
              oos.flush();
            } else if (isxml) {
              osw.flush();
            }
            bos.flush();
            fos.flush();
          }
        }
        if (isxml) {
          xwr.endElement(); // turns
          xwr.endElement(); // record
          osw.flush();
        }
      }

    } catch (IOException e) {
View Full Code Here

Examples of net.sf.webdav.fromcatalina.XMLWriter

        // String relativePath = getRelativePath(req);

        HashMap<String, String> namespaces = new HashMap<String, String>();
        namespaces.put("DAV:", "D");

        XMLWriter generatedXML = new XMLWriter(namespaces);
        generatedXML.writeXMLHeader();

        generatedXML.writeElement("DAV::multistatus", XMLWriter.OPENING);

        Enumeration<String> pathList = errorList.keys();
        while (pathList.hasMoreElements()) {

            String errorPath = (String) pathList.nextElement();
            int errorCode = ((Integer) errorList.get(errorPath)).intValue();

            generatedXML.writeElement("DAV::response", XMLWriter.OPENING);

            generatedXML.writeElement("DAV::href", XMLWriter.OPENING);
            String toAppend = null;
            if (absoluteUri.endsWith(errorPath)) {
                toAppend = absoluteUri;

            } else if (absoluteUri.contains(errorPath)) {

                int endIndex = absoluteUri.indexOf(errorPath)
                        + errorPath.length();
                toAppend = absoluteUri.substring(0, endIndex);
            }
            if (!toAppend.startsWith("/") && !toAppend.startsWith("http:"))
                toAppend = "/" + toAppend;
            generatedXML.writeText(errorPath);
            generatedXML.writeElement("DAV::href", XMLWriter.CLOSING);
            generatedXML.writeElement("DAV::status", XMLWriter.OPENING);
            generatedXML.writeText("HTTP/1.1 " + errorCode + " "
                    + WebdavStatus.getStatusText(errorCode));
            generatedXML.writeElement("DAV::status", XMLWriter.CLOSING);

            generatedXML.writeElement("DAV::response", XMLWriter.CLOSING);

        }

        generatedXML.writeElement("DAV::multistatus", XMLWriter.CLOSING);

        Writer writer = resp.getWriter();
        writer.write(generatedXML.toString());
        writer.close();

    }
View Full Code Here

Examples of nexj.core.util.XMLWriter

      String sDescriptorFile = getProperty("meta.descfile");

      if (sDescriptorFile != null && sDescriptorFile.length() != 0)
      {
         StringWriter swriter = new StringWriter(0x2000);
         XMLWriter writer = new XMLWriter(swriter);

         if (s_logger.isDebugEnabled())
         {
            s_logger.debug("Writing the repository descriptor to file \"" + sDescriptorFile + "\"");
         }

         writer.openElement("Metadata");
         writer.writeAttribute("version", "0");
         writer.closeElement();

         writer.startElement("Classes");

         List metaclassList = new ArrayList(metadata.getMetaclassCount());

         for (Iterator itr = metadata.getMetaclassIterator(); itr.hasNext();)
         {
            metaclassList.add(itr.next());
         }

         Collections.sort(metaclassList, new Comparator()
         {
            public int compare(Object o1, Object o2)
            {
               return ((Metaclass)o1).getName().compareToIgnoreCase(((Metaclass)o2).getName());
            }
         });

         for (int i = 0; i < metaclassList.size(); ++i)
         {
            writer.openElement("ClassRef");
            writer.writeAttribute("resource", "classes/" +
               ((Metaclass)metaclassList.get(i)).getName() + ".meta");
            writer.closeEmptyElement();
         }

         writer.endElement("Classes");
         writer.startElement("DataSources");
         writer.openElement("DataSourceRef");
         writer.writeAttribute("resource", "datasources/" + m_database.getName() + ".datasource");
         writer.closeEmptyElement();
         writer.endElement("DataSources");
         writer.endElement("Metadata");

         Writer fwriter = new OutputStreamWriter(new BufferedOutputStream(new FileOutputStream(sDescriptorFile)), XMLUtil.ENCODING);

         try
         {
View Full Code Here

Examples of nl.flotsam.pecia.builder.xml.XmlWriter

     * @param out   The {@link OutputStream} receiving the document.
     */
    public static <T> void document(Codec<T> codec, DocumentType type,
                                    OutputStream out) {
        WstxOutputFactory documentFactory = new WstxOutputFactory();
        XmlWriter writer;
        try {
            writer = new StreamingXmlWriter(documentFactory
                    .createXMLStreamWriter(out));
            DefaultDocumentBuilder builder = type.createDocumentBuilder(writer);
            ArticleDocument document = new DefaultArticleDocument(builder,
View Full Code Here

Examples of org.apache.catalina.util.XMLWriter

        resp.setStatus(WebdavStatus.SC_MULTI_STATUS);

        String absoluteUri = req.getRequestURI();
        String relativePath = getRelativePath(req);

        XMLWriter generatedXML = new XMLWriter();
        generatedXML.writeXMLHeader();

        generatedXML.writeElement(null, "multistatus"
                                  + generateNamespaceDeclarations(),
                                  XMLWriter.OPENING);

        Enumeration pathList = errorList.keys();
        while (pathList.hasMoreElements()) {

            String errorPath = (String) pathList.nextElement();
            int errorCode = ((Integer) errorList.get(errorPath)).intValue();

            generatedXML.writeElement(null, "response", XMLWriter.OPENING);

            generatedXML.writeElement(null, "href", XMLWriter.OPENING);
            String toAppend = errorPath.substring(relativePath.length());
            if (!toAppend.startsWith("/"))
                toAppend = "/" + toAppend;
            generatedXML.writeText(absoluteUri + toAppend);
            generatedXML.writeElement(null, "href", XMLWriter.CLOSING);
            generatedXML.writeElement(null, "status", XMLWriter.OPENING);
            generatedXML
                .writeText("HTTP/1.1 " + errorCode + " "
                           + WebdavStatus.getStatusText(errorCode));
            generatedXML.writeElement(null, "status", XMLWriter.CLOSING);

            generatedXML.writeElement(null, "response", XMLWriter.CLOSING);

        }

        generatedXML.writeElement(null, "multistatus", XMLWriter.CLOSING);

        Writer writer = resp.getWriter();
        writer.write(generatedXML.toString());
        writer.close();

    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.