Examples of Utf8StringBuilder


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

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

Examples of org.eclipse.jetty.util.Utf8StringBuilder

        _writer.write(data);
        assertEquals("787878F0909080787878",TypeUtil.toHexString(BufferUtil.toArray(_bytes)));
        assertArrayEquals(data.getBytes(StandardCharsets.UTF_8),BufferUtil.toArray(_bytes));
        assertEquals(3+4+3,_bytes.remaining());

        Utf8StringBuilder buf = new Utf8StringBuilder();
        buf.append(BufferUtil.toArray(_bytes),0,_bytes.remaining());
        assertEquals(data,buf.toString());
    }
View Full Code Here

Examples of org.eclipse.jetty.util.Utf8StringBuilder

            if (data.remaining() > 0)
            {
                // Reason
                try
                {
                    Utf8StringBuilder utf = new Utf8StringBuilder();
                    utf.append(data);
                    reason = utf.toString();
                }
                catch (NotUtf8Exception e)
                {
                    if (validate)
                    {
View Full Code Here

Examples of org.eclipse.jetty.util.Utf8StringBuilder

    protected boolean finished;

    public SimpleTextMessage(EventDriver onEvent)
    {
        this.onEvent = onEvent;
        this.utf = new Utf8StringBuilder(1024);
        size = 0;
        finished = false;
    }
View Full Code Here

Examples of org.eclipse.jetty.util.Utf8StringBuilder

    public void testDetectBadUTF8()
    {
        byte buf[] = new byte[]
        { (byte)0xC2, (byte)0xC3 };

        Utf8StringBuilder utf = new Utf8StringBuilder();
        utf.append(buf,0,buf.length);
    }
View Full Code Here

Examples of org.eclipse.jetty.util.Utf8StringBuilder

            if (data.remaining() > 0)
            {
                // Reason
                try
                {
                    Utf8StringBuilder utf = new Utf8StringBuilder();
                    utf.append(data);
                    reason = utf.toString();
                }
                catch (NotUtf8Exception e)
                {
                    if (validate)
                    {
View Full Code Here

Examples of org.eclipse.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
TOP
Copyright © 2018 www.massapi.com. 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.