public byte [] getBlock(final int index, final boolean read)
  {
    int start=index*BLOCKSIZE;
    if((index < 0)||(start >= endOffset))
    {
      return null;
    }
    if(index < buffer.size())
    {
      Object block=buffer.elementAt(index);
      if(block != null)
      {
        if(block.getClass().isArray())
        {
          return (byte[])block;
        }
        block=getFromReference(block);
        if(block != null)
        {
          if(read && (cacheAccessArray[cacheAccessIndex%cacheAccessArray.length] != block))
          {
            cacheAccessArray[cacheAccessIndex++%cacheAccessArray.length]=block;
          }
          return (byte[])block;
        }
      }
    }
    return read?readBlock(index):null;
  }