Examples of CharChunk


Examples of com.googlecode.mcvaadin.external.apache.CharChunk

    public static byte[] base64Decode(byte[] data) {
        ByteChunk bchunk = new ByteChunk();
        try {
            bchunk.append(data, 0, data.length);
            CharChunk ret = new CharChunk();
            Base64.decode(bchunk, ret);
            return ret.toStringInternal().getBytes(DEFAULT_STRING_ENCODING);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
View Full Code Here

Examples of com.sun.grizzly.util.buf.CharChunk

     */
    protected void convertURI(MessageBytes uri)
            throws Exception {

        ByteChunk bc = uri.getByteChunk();
        CharChunk cc = uri.getCharChunk();
        int length = bc.getLength();
        cc.allocate(length, -1);

        String enc = connector.getURIEncoding();
        if (enc != null && !enc.isEmpty() &&
                !Globals.ISO_8859_1_ENCODING.equalsIgnoreCase(enc)) {
            B2CConverter conv = getURIConverter();
            try {
                if (conv == null) {
                    conv = new B2CConverter(enc);
                    setURIConverter(conv);
                }
            } catch (IOException e) {
                // Ignore
                log.severe("Invalid URI encoding; using HTTP default");
                connector.setURIEncoding(null);
            }
            if (conv != null) {
                try {
                    conv.convert(bc, cc, cc.getBuffer().length - cc.getEnd());
                    uri.setChars(cc.getBuffer(), cc.getStart(),
                            cc.getLength());
                    return;
                } catch (IOException e) {
                    log.severe("Invalid URI character encoding; trying ascii");
                    cc.recycle();
                }
            }
        }

        // Default encoding: fast conversion
        byte[] bbuf = bc.getBuffer();
        char[] cbuf = cc.getBuffer();
        int start = bc.getStart();
        for (int i = 0; i < length; i++) {
            cbuf[i] = (char) (bbuf[i + start] & 0xff);
        }
        uri.setChars(cbuf, 0, length);
View Full Code Here

Examples of org.apache.tomcat.util.buf.CharChunk

          }
      }

      // Acquire references to objects we will need to evaluate
      MessageBytes uriMB = MessageBytes.newInstance();
      CharChunk uriCC = uriMB.getCharChunk();
      uriCC.setLimit(-1);
      String contextPath = request.getContextPath();
      String requestURI = request.getDecodedRequestURI();

      // Is this the action request from the login page?
      boolean loginAction =
View Full Code Here

Examples of org.apache.tomcat.util.buf.CharChunk

          }
      }

      // Acquire references to objects we will need to evaluate
      MessageBytes uriMB = MessageBytes.newInstance();
      CharChunk uriCC = uriMB.getCharChunk();
      uriCC.setLimit(-1);
      String contextPath = request.getContextPath();
      String requestURI = request.getDecodedRequestURI();

      // Is this the action request from the login page?
      boolean loginAction =
View Full Code Here

Examples of org.apache.tomcat.util.buf.CharChunk

            }
        }

        // Acquire references to objects we will need to evaluate
        MessageBytes uriMB = MessageBytes.newInstance();
        CharChunk uriCC = uriMB.getCharChunk();
        uriCC.setLimit(-1);
        String contextPath = request.getContextPath();
        String requestURI = request.getDecodedRequestURI();

        // Is this the action request from the login page?
        boolean loginAction =
View Full Code Here

Examples of org.apache.tomcat.util.buf.CharChunk

                return is.read();
            }

            public String read(int len) throws IOException {
                ByteChunk bc = new ByteChunk(125);
                CharChunk cc = new CharChunk(125);
                int read = 0;
                while (read < len) {
                    read = read + is.read(bc.getBytes(), read, len - read);
                }

                bc.setEnd(len);
                b2c.convert(bc, cc, true);
                return cc.toString();
            }
View Full Code Here

Examples of org.apache.tomcat.util.buf.CharChunk

                return cc.toString();
            }

            public String readLine() throws IOException {
                ByteChunk bc = new ByteChunk(125);
                CharChunk cc = new CharChunk(125);
                int i = is.read();
                int read = 0;
                while (i != -1) {
                    if (i != '\r' && i != '\n') {
                        bc.append((byte)i);
                        read++;
                    } else if (i == '\n') {
                        break;
                    } else if (i == '\r') {
                        if (markSupported) {
                            is.mark(2);
                        }
                        i = read();
                        if (i == -1) {
                            break;
                        } else {
                            if (i == '\n') {
                                break;
                            } else {
                                if (markSupported) {
                                    is.reset();
                                }
                            }
                        }
                    }
                    i = is.read();
                }
                bc.setEnd(read);
                b2c.convert(bc, cc, true);
                return cc.toString();
            }
View Full Code Here

Examples of org.apache.tomcat.util.buf.CharChunk

        }

        private void sendMessage(String message, boolean finalFragment)
                throws IOException {
            ByteChunk bc = new ByteChunk(8192);
            CharChunk cc = new CharChunk(8192);
            C2BConverter c2b = new C2BConverter("UTF-8");
            cc.append(message);
            c2b.convert(cc, bc);

            int len = bc.getLength();
            assertTrue(len < 126);
View Full Code Here

Examples of org.apache.tomcat.util.buf.CharChunk

    protected void convertURI(MessageBytes uri, Request request)
        throws Exception {

        ByteChunk bc = uri.getByteChunk();
        int length = bc.getLength();
        CharChunk cc = uri.getCharChunk();
        cc.allocate(length, -1);

        String enc = connector.getURIEncoding();
        if (enc != null) {
            B2CConverter conv = request.getURIConverter();
            try {
                if (conv == null) {
                    conv = new B2CConverter(enc);
                    request.setURIConverter(conv);
                }
            } catch (IOException e) {
                // Ignore
                log.error("Invalid URI encoding; using HTTP default");
                connector.setURIEncoding(null);
            }
            if (conv != null) {
                try {
                    conv.convert(bc, cc);
                    uri.setChars(cc.getBuffer(), cc.getStart(),
                                 cc.getLength());
                    return;
                } catch (IOException e) {
                    log.error("Invalid URI character encoding; trying ascii");
                    cc.recycle();
                }
            }
        }

        // Default encoding: fast conversion
        byte[] bbuf = bc.getBuffer();
        char[] cbuf = cc.getBuffer();
        int start = bc.getStart();
        for (int i = 0; i < length; i++) {
            cbuf[i] = (char) (bbuf[i + start] & 0xff);
        }
        uri.setChars(cbuf, 0, length);
View Full Code Here

Examples of org.apache.tomcat.util.buf.CharChunk

        // This is of course only meaningful for bytes
        if (mb.getType() != MessageBytes.T_BYTES)
            return;
       
        ByteChunk bc = mb.getByteChunk();
        CharChunk cc = mb.getCharChunk();
        int length = bc.getLength();
        cc.allocate(length, -1);

        // Default encoding: fast conversion
        byte[] bbuf = bc.getBuffer();
        char[] cbuf = cc.getBuffer();
        int start = bc.getStart();
        for (int i = 0; i < length; i++) {
            cbuf[i] = (char) (bbuf[i + start] & 0xff);
        }
        mb.setChars(cbuf, 0, length);
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.