/** Get the data in this map as a ByteBuffer */
  @Override
  public void setData(int length, ByteBuffer data) {
    // read the table size values
    firstCode = data.getShort();
    entryCount = data.getShort();

    glyphIndexArray = new short[entryCount];
    for (int i = 0; i < glyphIndexArray.length; i++) {
      glyphIndexArray[i] = data.getShort();
      glyphLookup.put(new Short(glyphIndexArray[i]), new Short((short) (i + firstCode)));
    }
  }
  /**
   * Open a specific pdf file. Creates a DocumentInfo from the file, and opens that.
   *
   * <p><b>Note:</b> Mapping the file locks the file until the PDFFile is closed.
   *
   * @param file the file to open
   * @throws IOException
   */
  public void openFile(File file, String password) throws IOException {
    // first open the file for random access
    RandomAccessFile raf = new RandomAccessFile(file, "r");

    // extract a file channel
    FileChannel channel = raf.getChannel();

    // now memory-map a byte-buffer
    ByteBuffer bb = ByteBuffer.NEW(channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size()));
    // create a PDFFile from the data
    if (password == null) mPdfFile = new PDFFile(bb);
    else mPdfFile = new PDFFile(bb, new PDFPassword(password));

    mGraphView.showText("Anzahl Seiten:" + mPdfFile.getNumPages());
  }
  /** Get the data in the map as a byte buffer */
  @Override
  public ByteBuffer getData() {
    ByteBuffer buf = ByteBuffer.allocate(getLength());

    // write the header
    buf.putShort(getFormat());
    buf.putShort((short) getLength());
    buf.putShort(getLanguage());

    // write the various values
    buf.putShort(firstCode);
    buf.putShort(entryCount);

    // write the endCodes
    for (int i = 0; i < glyphIndexArray.length; i++) {
      buf.putShort(glyphIndexArray[i]);
    }
    // reset the data pointer
    buf.flip();

    return buf;
  }