Package com.facebook.presto.jdbc.internal.jetty.util

Examples of com.facebook.presto.jdbc.internal.jetty.util.Utf8StringBuilder


    public String getDecodedPath()
    {
        if (_path==_param)
            return null;

        Utf8StringBuilder utf8b=null;

        for (int i=_path;i<_param;i++)
        {
            byte b = _raw[i];

            if (b=='%')
            {
                if (utf8b==null)
                {
                    utf8b=new Utf8StringBuilder();
                    utf8b.append(_raw,_path,i-_path);
                }
               
                if ((i+2)>=_param)
                    throw new IllegalArgumentException("Bad % encoding: "+this);
                if (_raw[i+1]=='u')
                {
                    if ((i+5)>=_param)
                        throw new IllegalArgumentException("Bad %u encoding: "+this);
                    try
                    {
                        String unicode = new String(Character.toChars(TypeUtil.parseInt(_raw,i+2,4,16)));
                        utf8b.getStringBuilder().append(unicode);
                        i+=5;
                    }
                    catch(Exception e)
                    {
                        throw new RuntimeException(e);
                    }
                }
                else
                {
                    b=(byte)(0xff&TypeUtil.parseInt(_raw,i+1,2,16));
                    utf8b.append(b);
                    i+=2;
                }
                continue;
            }
            else if (utf8b!=null)
            {
                utf8b.append(b);
            }
        }

        if (utf8b==null)
            return StringUtil.toUTF8String(_raw, _path, _param-_path);
        return utf8b.toString();
    }
View Full Code Here


    public String getDecodedPath()
    {
        if (_path==_param)
            return null;

        Utf8StringBuilder utf8b=null;

        for (int i=_path;i<_param;i++)
        {
            byte b = _raw[i];

            if (b=='%')
            {
                if (utf8b==null)
                {
                    utf8b=new Utf8StringBuilder();
                    utf8b.append(_raw,_path,i-_path);
                }
               
                if ((i+2)>=_param)
                    throw new IllegalArgumentException("Bad % encoding: "+this);
                if (_raw[i+1]=='u')
                {
                    if ((i+5)>=_param)
                        throw new IllegalArgumentException("Bad %u encoding: "+this);
                    try
                    {
                        String unicode = new String(Character.toChars(TypeUtil.parseInt(_raw,i+2,4,16)));
                        utf8b.getStringBuilder().append(unicode);
                        i+=5;
                    }
                    catch(Exception e)
                    {
                        throw new RuntimeException(e);
                    }
                }
                else
                {
                    b=(byte)(0xff&TypeUtil.parseInt(_raw,i+1,2,16));
                    utf8b.append(b);
                    i+=2;
                }
                continue;
            }
            else if (utf8b!=null)
            {
                utf8b.append(b);
            }
        }

        if (utf8b==null)
            return StringUtil.toUTF8String(_raw, _path, _param-_path);
        return utf8b.toString();
    }
View Full Code Here

TOP

Related Classes of com.facebook.presto.jdbc.internal.jetty.util.Utf8StringBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.