Class UEncoder

  • public final class UEncoder
    extends java.lang.Object
    Efficient implementation of an UTF-8 encoder. This class is not thread safe - you need one encoder per thread. The encoder will save and recycle the internal objects, avoiding garbage. You can add extra characters that you want preserved, for example while encoding a URL you can add "/".
    Costin Manolache
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  UEncoder.SafeCharsSet  
    • Constructor Summary

      Constructor Description
      UEncoder​(UEncoder.SafeCharsSet safeCharsSet)
      Create a UEncoder with an unmodifiable safe character set.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      CharChunk encodeURL​(java.lang.String s, int start, int end)
      URL Encode string, using a specified encoding.
      protected void urlEncode​(CharChunk out, ByteChunk bb)  
      • Methods inherited from class java.lang.Object

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

      • UEncoder

        public UEncoder​(UEncoder.SafeCharsSet safeCharsSet)
        Create a UEncoder with an unmodifiable safe character set.
        safeCharsSet - safe characters for this encoder
    • Method Detail

      • encodeURL

        public CharChunk encodeURL​(java.lang.String s,
                                   int start,
                                   int end)
        URL Encode string, using a specified encoding.
        s - string to be encoded
        start - the beginning index, inclusive
        end - the ending index, exclusive
        A new CharChunk contained the URL encoded string
        Throws: - If an I/O error occurs
      • urlEncode

        protected void urlEncode​(CharChunk out,
                                 ByteChunk bb)