Class URIUtils.EncodingUtils

  • Enclosing class:
    URIUtils

    private static class URIUtils.EncodingUtils
    extends java.lang.Object
    Internal character encoding utilities.

    This was forked from some needed methods such as #getBytes(...) and #getAsciiString(...) in org.apache.commons.httpclient.util.EncodingUtil, in order to not be dependent on HttpClient v3 API, when generating and handling GenericURLFileNames, but it should work with any different HTTP backend provider implementations.

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private EncodingUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) static java.lang.String getAsciiString​(byte[] data, int offset, int length)
      Converts the byte array of ASCII characters to a string.
      (package private) static byte[] getBytes​(java.lang.String data, java.lang.String charsetName)
      Converts the specified string to a byte array.
      • Methods inherited from class java.lang.Object

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

      • EncodingUtils

        private EncodingUtils()
    • Method Detail

      • getAsciiString

        static java.lang.String getAsciiString​(byte[] data,
                                               int offset,
                                               int length)
        Converts the byte array of ASCII characters to a string. This method is to be used when decoding content of HTTP elements (such as response headers)
        Parameters:
        data - the byte array to be encoded
        offset - the index of the first byte to encode
        length - the number of bytes to encode
        Returns:
        The string representation of the byte array
      • getBytes

        static byte[] getBytes​(java.lang.String data,
                               java.lang.String charsetName)
        Converts the specified string to a byte array. If the charset is not supported the default system charset is used.
        Parameters:
        data - the string to be encoded
        charsetName - the desired character encoding
        Returns:
        The resulting byte array.