Examples of ByteChunk


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

        }
        return null;
    }

    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();
View Full Code Here

Examples of com.sun.enterprise.admin.common.ByteChunk

        {
            String msg = localStrings.getString( "admin.mbeans.ssmb.call_preparedownload_first" );
            throw new MBeanException( new java.lang.IllegalStateException( msg ) );
        }
        // if it is a file of 0, return null bytes
        ByteChunk           byteChunk   = null;
        if (downloadInfo.downloadFile.length() == 0 ) {
            byte[] bytes = new byte[ByteChunk.kChunkMinSize];
            byteChunk = new ByteChunk(bytes,
                             downloadInfo.downloadFile.getAbsolutePath(),
                             true, true);
            unlockAndReset();
            return byteChunk;
        }

        if ((chunkIndex >= downloadInfo.numChunks) || (chunkIndex < 0))
        {
            String msg = localStrings.getString( "admin.mbeans.ssmb.invalid_chunk_index" );
            unlockAndReset();
            throw new MBeanException( new java.lang.IllegalStateException( msg ) );
        }
        RandomAccessFile    raf         = null;
        try
        {
            raf = new RandomAccessFile(downloadInfo.downloadFile, "r");
            byte[] bytes = new byte[ByteChunk.kChunkMaxSize];
            raf.seek(downloadInfo.numBytesRead);
            int actualBytesRead = raf.read(bytes, 0, ByteChunk.kChunkMaxSize);
            /*
            Debug.println("Read " + actualBytesRead + " from " +
                          downloadInfo.numBytesRead);
            */
            if (actualBytesRead < bytes.length)
            {
                byte[] newBytes = new byte[actualBytesRead];
                System.arraycopy(bytes, 0, newBytes, 0, newBytes.length);
                bytes = newBytes;
            }
            downloadInfo.numBytesRead += actualBytesRead;
            boolean isFirstChunk    = (chunkIndex == 0);
            boolean isLastChunk     =
                (chunkIndex == (downloadInfo.numChunks - 1));
            sLogger.log(Level.FINEST, "chunkIndex = " + chunkIndex +
                          " isFirstChunk = " + isFirstChunk +
                          " isLastChunk = " + isLastChunk);
            byteChunk = new ByteChunk(bytes,
                             downloadInfo.downloadFile.getAbsolutePath(),
                             isFirstChunk, isLastChunk);
        }
        catch (IOException ioe)
        {
            sLogger.log(Level.FINE, "mbean.download_failed", ioe);
            unlockAndReset();
            throw new MBeanException(ioe);
        }
        finally
        {
            if (raf != null)
            {
                try { raf.close(); }
                catch (IOException ioe) {}
            }
            if ((byteChunk != null) && (byteChunk.isLast()))
            {
                unlockAndReset();
            }
        }
        return byteChunk;
View Full Code Here

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

        MimeHeaders headers = request.getMimeHeaders();
        // Check connection header
        MessageBytes connectionValueMB = headers.getValue(
                LoadBalancerProxyConstants.HTTP_CONNECTION_HEADER);
        if (connectionValueMB != null) {
            ByteChunk connectionValueBC = connectionValueMB.getByteChunk();
            if (findBytes(connectionValueBC, Constants.CLOSE_BYTES) != -1) {
                keepAlive = false;
            } else if (findBytes(connectionValueBC,
                    Constants.KEEPALIVE_BYTES) != -1) {
                keepAlive = true;
View Full Code Here

Examples of me.daddychurchill.CityWorld.Support.ByteChunk

    try {

      initializeWorldInfo(aWorld);

      // place to work
      ByteChunk byteChunk = new ByteChunk(this, chunkX, chunkZ);
   
      // figure out what everything looks like
      PlatMap platmap = getPlatMap(chunkX, chunkZ);
      if (platmap != null) {
        //CityWorld.reportMessage("generate X,Z = " + chunkX + "," + chunkZ);
View Full Code Here

Examples of org.apache.poi.hsmf.datatypes.ByteChunk

    *  contains a RTF (rich) version.
    * @return The string representation of the 'RTF' version of the body, if available.
    * @throws ChunkNotFoundException
    */
   public String getRtfBody() throws ChunkNotFoundException {
      ByteChunk chunk = mainChunks.rtfBodyChunk;
      if(chunk == null) {
         if(returnNullOnMissingChunk) {
            return null;
         } else {
            throw new ChunkNotFoundException();
         }
      }
     
      try {
         MAPIRtfAttribute rtf = new MAPIRtfAttribute(
               MAPIProperty.RTF_COMPRESSED, Types.BINARY, chunk.getValue()
         );
         return rtf.getDataString();
      } catch(IOException e) {
         throw new RuntimeException("Shouldn't happen", e);
      }
View Full Code Here

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

       }
      
       request.getCoyoteRequest().getParameters().recycle();
      
       if ("POST".equalsIgnoreCase(saved.getMethod())) {
           ByteChunk body = saved.getBody();
          
           if (body != null) {
               request.getCoyoteRequest().action
                   (ActionCode.ACTION_REQ_SET_BODY_REPLAY, body);
  
View Full Code Here

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

           Locale locale = (Locale) locales.nextElement();
           saved.addLocale(locale);
       }

       if ("POST".equalsIgnoreCase(request.getMethod())) {
           ByteChunk body = new ByteChunk();
           body.setLimit(request.getConnector().getMaxSavePostSize());

           byte[] buffer = new byte[4096];
           int bytesRead;
           InputStream is = request.getInputStream();
      
           while ( (bytesRead = is.read(buffer) ) >= 0) {
               body.append(buffer, 0, bytesRead);
           }
           saved.setBody(body);
           saved.setContentType(request.getContentType());
       }
View Full Code Here

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

      Connector connector = new Connector("org.apache.coyote.memory.MemoryProtocolHandler");
      MemoryProtocolHandler handler = (MemoryProtocolHandler) connector.getProtocolHandler();
      server.invoke(name, "addConnector", new Object[] { connector }, new String[] { Connector.class.getName() });
      try
      {
         ByteChunk input = new ByteChunk(1024);
         ByteChunk output = new ByteChunk(1024);
         org.apache.coyote.Request req = new org.apache.coyote.Request();
         req.decodedURI().setString("/webbmtcleanuptest/test1.jsp");
         req.method().setString("GET");
         org.apache.coyote.Response resp = new org.apache.coyote.Response();
         handler.process(req, input, resp, output);
         if (resp.getStatus() != 200)
            throw new Error(output.toString());

         input = new ByteChunk(1024);
         output = new ByteChunk(1024);
         req = new org.apache.coyote.Request();
         req.decodedURI().setString("/webbmtcleanuptest/test2.jsp");
         req.method().setString("GET");
         resp = new org.apache.coyote.Response();
         handler.process(req, input, resp, output);
         if (resp.getStatus() != 200)
            throw new Error(output.toString());
      }
      finally
      {
         try
         {
View Full Code Here

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

            throws IOException {
        MessageBytes authorization =
            request.getCoyoteRequest().getMimeHeaders().getValue("authorization");
        if (authorization != null) {
            authorization.toBytes();
            ByteChunk authorizationBC = authorization.getByteChunk();
            if (authorizationBC.startsWithIgnoreCase("basic ", 0)) {
                return bc.authenticate(request, response, config);
            }
            else if (authorizationBC.startsWithIgnoreCase("oauth ", 0)) {
                return authenticateOAuth(request, response, config);
            }
        }

        return false;
View Full Code Here

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

        // app dir is relative to server home
        tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());

        tomcat.start();

        ByteChunk res = getUrl("http://localhost:" + getPort() +
                "/test/bug45nnn/bug45427.jsp");

        String result = res.toString();
        // Warning: JSP attribute escaping != Java String escaping
        assertEcho(result, "00-hello world");
        assertEcho(result, "01-hello 'world");
        assertEcho(result, "02-hello \"world");
        assertEcho(result, "03-hello world");
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.