Package com.ibm.commons.util.io

Examples of com.ibm.commons.util.io.ByteStreamCache$Block


    }

    private ArrayList<Block> getBlocksAroundBlockByState(int column, int row, BlockState blockState){
        ArrayList<Block> blocksWithBlockState = new ArrayList<Block>();
        for(Direction direction : Direction.values()){
            Block block = getBlockFromDirection(column, row, direction);
            if(block!=null && block.getBlockState()!=null && block.getBlockState()== blockState)
                blocksWithBlockState.add(block);
        }
        return blocksWithBlockState;
    }
View Full Code Here


    private void generateBlocks(int columns, int rows) {
        blocks = new Block[columns][rows];
        for(int c=0; c<columns; c++)
            for(int r=0; r<rows; r++)
                blocks[c][r] = new Block(c*blockSize, r*blockSize, blockSize, blockSize);
    }
View Full Code Here

                else
                    g.drawImage(emptyFieldImage, 0, 0,null);

                for(int c=0; c<mineSweeper.getBlocks().length; c++)
                    for(int r=0; r<mineSweeper.getBlocks()[0].length; r++) {
                        Block block = mineSweeper.getBlocks()[c][r];

                        if(block.getBlockNumber()!=null){
                            g.setColor(block.getBlockNumber().getColor());
                            g.drawString(""+block.getBlockNumber().getNumber(), block.x+4, block.y+12);
                        }
                        if(block.getBlockState()!=null)
                            switch(block.getBlockState()){
                                case FLAG:      g.drawImage(flagBlock, block.x, block.y, null);
                                    break;
                                case BOMB:      g.drawImage(bombBlock, block.x, block.y, null);
                                    break;
                                case EMPTY:     if(block.getBlockNumber()==null)
                                    g.drawImage(emptyBlock, block.x, block.y, null);
                            }
                    }

            }
View Full Code Here

  }

  protected byte[] toByteArray(Object object) throws CredentialStoreException {
    try {
      if(object!=null) {
        ByteStreamCache bs = new ByteStreamCache(1024);
        ObjectOutputStream os = new ObjectOutputStream(bs.getOutputStream());
        try {
          os.writeObject(object);
          return bs.toByteArray();
        } finally {
          os.close();
        }
      }
      return null;
View Full Code Here

    try {
      // When no length is specified, the HTTP client core forces Transfert-Encoding: chunked
      // The code bellow shows a workaround, although we should avoid that
      if(false) {
        if(length<0) {
          ByteStreamCache bs = new ByteStreamCache();
          bs.copyFrom(request.getInputStream());
          HttpEntity payloadEntity = new InputStreamEntity(bs.getInputStream(), bs.getLength());
          ((HttpEntityEnclosingRequest) method).setEntity(payloadEntity);
          return method;
        }
      }
      // Regular code
View Full Code Here

       
        JarEntry entry = new JarEntry( entryName );
        entry.setMethod( ZipEntry.DEFLATED );
       
        CRC32 checksumCalculator= new CRC32();
        ByteStreamCache bsc = new ByteStreamCache();
        entry.setSize( StreamUtil.copyStream( is, bsc.getOutputStream() ));
        checksumCalculator.update( bsc.toByteArray() );
        entry.setCrc(checksumCalculator.getValue());
       
        jarOS.putNextEntry( entry );
        //Now that we have the correct size, we can copy it to the jar stream
        StreamUtil.copyStream( bsc.getInputStream(), jarOS );
       
        entriesSet.add( entryName );
    }
View Full Code Here

  }
 
  private void emit(HttpServletResponse resp, String text, String contentType) throws IOException {
    resp.setStatus(200);
    resp.setContentType(contentType);
    ByteStreamCache bs = new ByteStreamCache();
    InputStream is = new ReaderInputStream(new StringReader(text),"utf-8");
    bs.copyFrom(is);
    resp.setContentLength((int)bs.getLength());
    OutputStream os = resp.getOutputStream();
    bs.copyTo(os);
    os.flush();
  }
View Full Code Here

    } else return entityHeight;
  }

  @Override
  public AlmostBoolean isBlockSolid(final int id) {
    final Block block = Block.byId[id];
    if (block == null || block.material == null) return AlmostBoolean.MAYBE;
    else return AlmostBoolean.match(block.material.isSolid());
  }
View Full Code Here

    else return AlmostBoolean.match(block.material.isSolid());
  }

  @Override
  public AlmostBoolean isBlockLiquid(final int id) {
    final Block block = Block.byId[id];
    if (block == null || block.material == null) return AlmostBoolean.MAYBE;
    else return AlmostBoolean.match(block.material.isLiquid());
  }
View Full Code Here

    } else return entityHeight;
  }

  @Override
  public AlmostBoolean isBlockSolid(final int id) {
    final Block block = Block.byId[id];
    if (block == null || block.material == null) return AlmostBoolean.MAYBE;
    else return AlmostBoolean.match(block.material.isSolid());
  }
View Full Code Here

TOP

Related Classes of com.ibm.commons.util.io.ByteStreamCache$Block

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.