/** * 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 is UnparseableExtraFieldData) { unparseableExtra = (UnparseableExtraFieldData)ze; } else { if (extraFields == null) { extraFields = new java.util.LinkedHashMap <ZipShort, ZipExtraField>(); } extraFields.put(ze.getHeaderId(), ze); } setExtra(); }
/** * Replaces all currently attached extra fields with the new array. * @param fields an array of extra fields */ public void setExtraFields(ZipExtraField[] fields) { extraFields = new java.util.LinkedHashMap <ZipShort, ZipExtraField>(); for (int i = 0; i < fields.Length; i++) { if (fields[i] is UnparseableExtraFieldData) { unparseableExtra = (UnparseableExtraFieldData)fields[i]; } else { extraFields.put(fields[i].getHeaderId(), fields[i]); } } setExtra(); }
/** * 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 is UnparseableExtraFieldData) { unparseableExtra = (UnparseableExtraFieldData)ze; } else { java.util.LinkedHashMap <ZipShort, ZipExtraField> copy = extraFields; extraFields = new java.util.LinkedHashMap <ZipShort, ZipExtraField>(); extraFields.put(ze.getHeaderId(), ze); if (copy != null) { copy.remove(ze.getHeaderId()); extraFields.putAll(copy); } } setExtra(); }