Ejemplo n.º 1
0
 /** @return <code>null</code> if <tt>offset</tt> points to the end of the document stream */
 DataInputBlock getDataInputBlock(int offset) {
   if (offset >= _size) {
     if (offset > _size) {
       throw new RuntimeException("Request for Offset " + offset + " doc size is " + _size);
     }
     return null;
   }
   if (_property.shouldUseSmallBlocks()) {
     return SmallDocumentBlock.getDataInputBlock(_small_store.getBlocks(), offset);
   }
   return DocumentBlock.getDataInputBlock(_big_store.getBlocks(), offset);
 }
Ejemplo n.º 2
0
  /**
   * Get an array of objects, some of which may implement POIFSViewable
   *
   * @return an array of Object; may not be null, but may be empty
   */
  public Object[] getViewableArray() {
    String result = "<NO DATA>";

    try {
      BlockWritable[] blocks = null;

      if (_big_store.isValid()) {
        blocks = _big_store.getBlocks();
      } else if (_small_store.isValid()) {
        blocks = _small_store.getBlocks();
      }
      if (blocks != null) {
        ByteArrayOutputStream output = new ByteArrayOutputStream();
        for (BlockWritable bw : blocks) {
          bw.writeBlocks(output);
        }
        int length = Math.min(output.size(), _property.getSize());
        result = HexDump.dump(output.toByteArray(), 0, 0, length);
      }
    } catch (IOException e) {
      result = e.getMessage();
    }
    return new String[] {result};
  }