Package org.apache.poi.poifs.storage

Examples of org.apache.poi.poifs.storage.DataInputBlock


   * This method is currently (Oct 2008) only used by test code. Perhaps it can be deleted
   */
  void read(byte[] buffer, int offset) {
    int len = buffer.length;

    DataInputBlock currentBlock = getDataInputBlock(offset);
   
    int blockAvailable = currentBlock.available();
    if (blockAvailable > len) {
      currentBlock.readFully(buffer, 0, len);
      return;
    }
    // else read big amount in chunks
    int remaining = len;
    int writePos = 0;
    int currentOffset = offset;
    while (remaining > 0) {
      boolean blockIsExpiring = remaining >= blockAvailable;
      int reqSize;
      if (blockIsExpiring) {
        reqSize = blockAvailable;
      } else {
        reqSize = remaining;
      }
      currentBlock.readFully(buffer, writePos, reqSize);
      remaining-=reqSize;
      writePos+=reqSize;
      currentOffset += reqSize;
      if (blockIsExpiring) {
        if (currentOffset == _size) {
          if (remaining > 0) {
            throw new IllegalStateException("reached end of document stream unexpectedly");
          }
          currentBlock = null;
          break;
        }
        currentBlock = getDataInputBlock(currentOffset);
        blockAvailable = currentBlock.available();
      }
    }
  }
View Full Code Here


   * This method is currently (Oct 2008) only used by test code. Perhaps it can be deleted
   */
  void read(byte[] buffer, int offset) {
    int len = buffer.length;

    DataInputBlock currentBlock = getDataInputBlock(offset);

    int blockAvailable = currentBlock.available();
    if (blockAvailable > len) {
      currentBlock.readFully(buffer, 0, len);
      return;
    }
    // else read big amount in chunks
    int remaining = len;
    int writePos = 0;
    int currentOffset = offset;
    while (remaining > 0) {
      boolean blockIsExpiring = remaining >= blockAvailable;
      int reqSize;
      if (blockIsExpiring) {
        reqSize = blockAvailable;
      } else {
        reqSize = remaining;
      }
      currentBlock.readFully(buffer, writePos, reqSize);
      remaining-=reqSize;
      writePos+=reqSize;
      currentOffset += reqSize;
      if (blockIsExpiring) {
        if (currentOffset == _size) {
          if (remaining > 0) {
            throw new IllegalStateException("reached end of document stream unexpectedly");
          }
          currentBlock = null;
          break;
        }
        currentBlock = getDataInputBlock(currentOffset);
        blockAvailable = currentBlock.available();
      }
    }
  }
View Full Code Here

   * This method is currently (Oct 2008) only used by test code. Perhaps it can be deleted
   */
  void read(byte[] buffer, int offset) {
    int len = buffer.length;

    DataInputBlock currentBlock = getDataInputBlock(offset);

    int blockAvailable = currentBlock.available();
    if (blockAvailable > len) {
      currentBlock.readFully(buffer, 0, len);
      return;
    }
    // else read big amount in chunks
    int remaining = len;
    int writePos = 0;
    int currentOffset = offset;
    while (remaining > 0) {
      boolean blockIsExpiring = remaining >= blockAvailable;
      int reqSize;
      if (blockIsExpiring) {
        reqSize = blockAvailable;
      } else {
        reqSize = remaining;
      }
      currentBlock.readFully(buffer, writePos, reqSize);
      remaining-=reqSize;
      writePos+=reqSize;
      currentOffset += reqSize;
      if (blockIsExpiring) {
        if (currentOffset == _size) {
          if (remaining > 0) {
            throw new IllegalStateException("reached end of document stream unexpectedly");
          }
          currentBlock = null;
          break;
        }
        currentBlock = getDataInputBlock(currentOffset);
        blockAvailable = currentBlock.available();
      }
    }
  }
View Full Code Here

    int blockAvailable = _currentBlock.available();
    long result;
    if (blockAvailable > SIZE_LONG) {
      result = _currentBlock.readLongLE();
    } else {
      DataInputBlock nextBlock = getDataInputBlock(_current_offset + blockAvailable);
      if (blockAvailable == SIZE_LONG) {
        result = _currentBlock.readLongLE();
      } else {
        result = nextBlock.readLongLE(_currentBlock, blockAvailable);
      }
      _currentBlock = nextBlock;
    }
    _current_offset += SIZE_LONG;
    return result;
View Full Code Here

    int blockAvailable = _currentBlock.available();
    int result;
    if (blockAvailable > SIZE_INT) {
      result = _currentBlock.readIntLE();
    } else {
      DataInputBlock nextBlock = getDataInputBlock(_current_offset + blockAvailable);
      if (blockAvailable == SIZE_INT) {
        result = _currentBlock.readIntLE();
      } else {
        result = nextBlock.readIntLE(_currentBlock, blockAvailable);
      }
      _currentBlock = nextBlock;
    }
    _current_offset += SIZE_INT;
    return result;
View Full Code Here

    int blockAvailable = _currentBlock.available();
    int result;
    if (blockAvailable > SIZE_SHORT) {
      result = _currentBlock.readUShortLE();
    } else {
      DataInputBlock nextBlock = getDataInputBlock(_current_offset + blockAvailable);
      if (blockAvailable == SIZE_SHORT) {
        result = _currentBlock.readUShortLE();
      } else {
        result = nextBlock.readUShortLE(_currentBlock);
      }
      _currentBlock = nextBlock;
    }
    _current_offset += SIZE_SHORT;
    return result;
View Full Code Here

   * This method is currently (Oct 2008) only used by test code. Perhaps it can be deleted
   */
  void read(byte[] buffer, int offset) {
    int len = buffer.length;

    DataInputBlock currentBlock = getDataInputBlock(offset);

    int blockAvailable = currentBlock.available();
    if (blockAvailable > len) {
      currentBlock.readFully(buffer, 0, len);
      return;
    }
    // else read big amount in chunks
    int remaining = len;
    int writePos = 0;
    int currentOffset = offset;
    while (remaining > 0) {
      boolean blockIsExpiring = remaining >= blockAvailable;
      int reqSize;
      if (blockIsExpiring) {
        reqSize = blockAvailable;
      } else {
        reqSize = remaining;
      }
      currentBlock.readFully(buffer, writePos, reqSize);
      remaining-=reqSize;
      writePos+=reqSize;
      currentOffset += reqSize;
      if (blockIsExpiring) {
        if (currentOffset == _size) {
          if (remaining > 0) {
            throw new IllegalStateException("reached end of document stream unexpectedly");
          }
          currentBlock = null;
          break;
        }
        currentBlock = getDataInputBlock(currentOffset);
        blockAvailable = currentBlock.available();
      }
    }
  }
View Full Code Here

    int blockAvailable = _currentBlock.available();
    long result;
    if (blockAvailable > SIZE_LONG) {
      result = _currentBlock.readLongLE();
    } else {
      DataInputBlock nextBlock = getDataInputBlock(_current_offset + blockAvailable);
      if (blockAvailable == SIZE_LONG) {
        result = _currentBlock.readLongLE();
      } else {
        result = nextBlock.readLongLE(_currentBlock, blockAvailable);
      }
      _currentBlock = nextBlock;
    }
    _current_offset += SIZE_LONG;
    return result;
View Full Code Here

    int blockAvailable = _currentBlock.available();
    int result;
    if (blockAvailable > SIZE_INT) {
      result = _currentBlock.readIntLE();
    } else {
      DataInputBlock nextBlock = getDataInputBlock(_current_offset + blockAvailable);
      if (blockAvailable == SIZE_INT) {
        result = _currentBlock.readIntLE();
      } else {
        result = nextBlock.readIntLE(_currentBlock, blockAvailable);
      }
      _currentBlock = nextBlock;
    }
    _current_offset += SIZE_INT;
    return result;
View Full Code Here

    int blockAvailable = _currentBlock.available();
    int result;
    if (blockAvailable > SIZE_SHORT) {
      result = _currentBlock.readUShortLE();
    } else {
      DataInputBlock nextBlock = getDataInputBlock(_current_offset + blockAvailable);
      if (blockAvailable == SIZE_SHORT) {
        result = _currentBlock.readUShortLE();
      } else {
        result = nextBlock.readUShortLE(_currentBlock);
      }
      _currentBlock = nextBlock;
    }
    _current_offset += SIZE_SHORT;
    return result;
View Full Code Here

TOP

Related Classes of org.apache.poi.poifs.storage.DataInputBlock

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.