/* Copyright (c) 2001, Oracle Corporation. All rights reserved. */
package oracle.portal.utils.v1;

import java.io.*;
import oracle.webdb.utils.SimpleStringBuffer;
import oracle.webdb.utils.HTTPUtils;

/**
 * The class contains a utility method for decoding an arbitrary
 * <code>String</code> encoded using the same scheme as {@link
 * MultiByteEncoder}.
 */
public final class MultiByteDecoder
{

    /**
     * Decodes a String encoded using a {@link MultiByteEncoder}.
     *
     * @param value <code>String</code> to be translated.
     * @param encoding the IANA character encoding to be used to convert byte
     * sequences into characters(e.g. <code>"UTF-8"</code>).
     * @return the translated <code>String</code>.
     * @exception UnsupportedEncodingException if the given encoding is not a
     * supported IANA character encoding.
     */
    public static String decode(String value, String encoding)
        throws UnsupportedEncodingException
    {
        return HTTPUtils.decode(value, encoding);
    }

    /**
     * Decodes a String encoded using a {@link MultiByteEncoder}.  Defaults
     * the encoding to UTF-8
     *
     * @param value <code>String</code> to be translated.
     * @return the translated <code>String</code>.
     */
    public static String decodeUTF(String value)
    {
        return HTTPUtils.decodeUTF(value);
    }

    public static final boolean needsDecoding(String token)
    {
        return HTTPUtils.needsDecoding(token);
    }

}    
