Пример #1
0
 /**
  * Looks up an extra field by its header id.
  *
  * @param type the header id
  * @return null if no such field exists.
  */
 public ZipExtraField getExtraField(ZipShort type) {
   if (extraFields != null) {
     for (ZipExtraField extraField : extraFields) {
       if (type.equals(extraField.getHeaderId())) {
         return extraField;
       }
     }
   }
   return null;
 }
Пример #2
0
  /**
   * Remove an extra field.
   *
   * @param type the type of extra field to remove
   */
  public void removeExtraField(ZipShort type) {
    if (extraFields == null) {
      throw new java.util.NoSuchElementException();
    }

    List<ZipExtraField> newResult = new ArrayList<ZipExtraField>();
    for (ZipExtraField extraField : extraFields) {
      if (!type.equals(extraField.getHeaderId())) {
        newResult.add(extraField);
      }
    }
    if (extraFields.length == newResult.size()) {
      throw new java.util.NoSuchElementException();
    }
    extraFields = newResult.toArray(new ZipExtraField[newResult.size()]);
    setExtra();
  }