Class XmlWriter

java.lang.Object
org.openstreetmap.josm.io.XmlWriter
All Implemented Interfaces:
Closeable, AutoCloseable
Direct Known Subclasses:
GpxWriter, NoteWriter, OsmWriter, PreferencesWriter, ValidatorErrorWriter

public class XmlWriter extends Object implements Closeable
Helper class to use for xml outputting classes.
  • Field Details

  • Constructor Details

    • XmlWriter

      public XmlWriter(PrintWriter out)
      Constructs a new XmlWriter.
      Parameters:
      out - print writer
  • Method Details

    • flush

      public void flush()
      Flushes the stream.
    • encode

      public static String encode(String unencoded)
      Encode the given string in XML1.0 format. Optimized to fast pass strings that don't need encoding (normal case).
      Parameters:
      unencoded - the unencoded input string
      Returns:
      XML1.0 string
    • encode

      public static String encode(String unencoded, boolean keepApos)
      Encode the given string in XML1.0 format. Optimized to fast pass strings that don't need encoding (normal case).
      Parameters:
      unencoded - the unencoded input string
      keepApos - true if apostrophe sign should stay as it is (in order to work around a Java bug that renders new JLabel("<html>&apos;</html>") literally as 6 character string, see #7558)
      Returns:
      XML1.0 string
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException