예제 #1
0
 /**
  * Adds an extra field - replacing an already present extra field of the same type.
  *
  * <p>The new extra field will be the first one.
  *
  * @param ze an extra field
  */
 public void addAsFirstExtraField(ZipExtraField ze) {
   if (ze instanceof UnparseableExtraFieldData) {
     unparseableExtra = (UnparseableExtraFieldData) ze;
   } else {
     if (getExtraField(ze.getHeaderId()) != null) {
       removeExtraField(ze.getHeaderId());
     }
     ZipExtraField[] copy = extraFields;
     int newLen = extraFields != null ? extraFields.length + 1 : 1;
     extraFields = new ZipExtraField[newLen];
     extraFields[0] = ze;
     if (copy != null) {
       System.arraycopy(copy, 0, extraFields, 1, extraFields.length - 1);
     }
   }
   setExtra();
 }
예제 #2
0
 /**
  * Adds an extra field - replacing an already present extra field of the same type.
  *
  * <p>If no extra field of the same type exists, the field will be added as last field.
  *
  * @param ze an extra field
  */
 public void addExtraField(ZipExtraField ze) {
   if (ze instanceof UnparseableExtraFieldData) {
     unparseableExtra = (UnparseableExtraFieldData) ze;
   } else {
     if (extraFields == null) {
       extraFields = new ZipExtraField[] {ze};
     } else {
       if (getExtraField(ze.getHeaderId()) != null) {
         removeExtraField(ze.getHeaderId());
       }
       final ZipExtraField[] zipExtraFields = copyOf(extraFields, extraFields.length + 1);
       zipExtraFields[zipExtraFields.length - 1] = ze;
       extraFields = zipExtraFields;
     }
   }
   setExtra();
 }