Ejemplo n.º 1
0
  /**
   * merges two dictionaries.
   *
   * @param dest
   * @param source
   */
  private void mergeDictionary(
      COSName name, COSDictionary dest, COSDictionary source, Map objectNameMap) {
    COSDictionary destDict = (COSDictionary) dest.getDictionaryObject(name);
    COSDictionary sourceDict = (COSDictionary) source.getDictionaryObject(name);

    if (destDict == null) {
      destDict = new COSDictionary();
      dest.setItem(name, destDict);
    }
    if (sourceDict != null) {

      for (Map.Entry<COSName, COSBase> entry : sourceDict.entrySet()) {
        COSName mappedKey = (COSName) objectNameMap.get(entry.getKey().getName());
        if (mappedKey != null) {
          destDict.setItem(mappedKey, entry.getValue());
        }
      }
    }
  }