Class Encoded


  • public final class Encoded
    extends java.lang.Object
    Buffer for UTF-8 encoded string. See http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 for the UTF-8 encoding.
    Author:
    Kohsuke Kawaguchi
    • Field Summary

      Fields 
      Modifier and Type Field Description
      byte[] buf  
      int len  
    • Constructor Summary

      Constructors 
      Constructor Description
      Encoded()  
      Encoded​(java.lang.String text)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void append​(char b)
      Appends a new character to the end of the buffer.
      void compact()
      Reallocate the buffer to the exact size of the data to reduce the memory footprint.
      void ensureSize​(int size)  
      void set​(java.lang.String text)  
      void setEscape​(java.lang.String text, boolean isAttribute)
      Fill in the buffer by encoding the specified characters while escaping characters like <
      void write​(UTF8XmlOutput out)
      Writes the encoded bytes to the given output stream.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • buf

        public byte[] buf
      • len

        public int len
    • Constructor Detail

      • Encoded

        public Encoded()
      • Encoded

        public Encoded​(java.lang.String text)
    • Method Detail

      • ensureSize

        public void ensureSize​(int size)
      • set

        public final void set​(java.lang.String text)
      • setEscape

        public final void setEscape​(java.lang.String text,
                                    boolean isAttribute)
        Fill in the buffer by encoding the specified characters while escaping characters like <
        Parameters:
        isAttribute - if true, characters like \t, \r, and \n are also escaped.
      • write

        public final void write​(UTF8XmlOutput out)
                         throws java.io.IOException
        Writes the encoded bytes to the given output stream.
        Throws:
        java.io.IOException
      • append

        public void append​(char b)
        Appends a new character to the end of the buffer. This assumes that you have enough space in the buffer.
      • compact

        public void compact()
        Reallocate the buffer to the exact size of the data to reduce the memory footprint.