/[classpath]/classpath/java/net/URLDecoder.java
ViewVC logotype

Diff of /classpath/java/net/URLDecoder.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8 by mark, Fri Oct 25 23:16:16 2002 UTC revision 1.9 by mark, Thu Oct 31 22:50:12 2002 UTC
# Line 39  package java.net; Line 39  package java.net;
39    
40  import java.io.UnsupportedEncodingException;  import java.io.UnsupportedEncodingException;
41    
42   /**  /**
43    * This utility class contains static methods that converts a   * This utility class contains static methods that converts a
44    * string encoded in the x-www-form-urlencoded format to the original   * string encoded in the x-www-form-urlencoded format to the original
45    * text.  The x-www-form-urlencoded format replaces certain disallowed   * text.  The x-www-form-urlencoded format replaces certain disallowed
46    * characters with encoded equivalents.  All upper case and lower case   * characters with encoded equivalents.  All upper case and lower case
47    * letters in the US alphabet remain as is, the space character (' ')   * letters in the US alphabet remain as is, the space character (' ')
48    * is replaced with '+' sign, and all other characters are converted to a   * is replaced with '+' sign, and all other characters are converted to a
49    * "%XX" format where XX is the hexadecimal representation of that character   * "%XX" format where XX is the hexadecimal representation of that character
50    * in a given character encoding (default is "UTF-8").   * in a given character encoding (default is "UTF-8").
51    * <p>   * <p>
52    * This method is very useful for decoding strings sent to CGI scripts   * This method is very useful for decoding strings sent to CGI scripts
53    *   *
54    * Written using on-line Java Platform 1.2/1.4 API Specification.   * Written using on-line Java Platform 1.2/1.4 API Specification.
55    * Status:  Believed complete and correct.   * Status:  Believed complete and correct.
56    *   *
57    * @since 1.2   * @since 1.2
58    *   *
59    * @author Warren Levy <warrenl@cygnus.com>   * @author Warren Levy <warrenl@cygnus.com>
60    * @author Aaron M. Renn (arenn@urbanophile.com) (documentation comments)   * @author Aaron M. Renn (arenn@urbanophile.com) (documentation comments)
61    * @author Mark Wielaard (mark@klomp.org)   * @author Mark Wielaard (mark@klomp.org)
62    */   */
63  public class URLDecoder  public class URLDecoder
64  {  {
65   /**    /**
66    * This method translates the passed in string from x-www-form-urlencoded     * Public contructor. Note that this class has only static methods.
67    * format using the default encoding "UTF-8" to decode the hex encoded     */
68    * unsafe characters.    public URLDecoder ()
69    *    {
70    * @param s the String to convert    }
71    *  
72    * @return the converted String    /**
73    */     * This method translates the passed in string from x-www-form-urlencoded
74       * format using the default encoding "UTF-8" to decode the hex encoded
75       * unsafe characters.
76       *
77       * @param s the String to convert
78       *
79       * @return the converted String
80       */
81    public static String decode(String s)    public static String decode(String s)
82    {    {
83      try      try
# Line 84  public class URLDecoder Line 91  public class URLDecoder
91        }        }
92    }    }
93    
94   /**    /**
95    * This method translates the passed in string from x-www-form-urlencoded     * This method translates the passed in string from x-www-form-urlencoded
96    * format using the given character encoding to decode the hex encoded     * format using the given character encoding to decode the hex encoded
97    * unsafe characters.     * unsafe characters.
98    * <p>     *
99    * This implementation will decode the string even if it contains     * This implementation will decode the string even if it contains
100    * unsafe characters (characters that should have been encoded) or if the     * unsafe characters (characters that should have been encoded) or if the
101    * two characters following a % do not represent a hex encoded byte.     * two characters following a % do not represent a hex encoded byte.
102    * In those cases the unsafe character or the % character will be added     * In those cases the unsafe character or the % character will be added
103    * verbatim to the decoded result.     * verbatim to the decoded result.
104    *     *
105    * @param s the String to convert     * @param s the String to convert
106    * @param encoding the character encoding to use the decode the hex encoded     * @param encoding the character encoding to use the decode the hex encoded
107    *        unsafe characters     *        unsafe characters
108    *     *
109    * @return the converted String     * @return the converted String
110    *     *
111    * @since 1.4     * @exception UnsupportedEncodingException If the named encoding is not
112    */     * supported
113       *
114       * @since 1.4
115       */
116    public static String decode(String s, String encoding)    public static String decode(String s, String encoding)
117      throws UnsupportedEncodingException      throws UnsupportedEncodingException
118    {    {

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26