/** * @param data the array of bytes. * @param offset the source location in the data array. * @param length the number of bytes to use in the data array. */ public void parseFromCentralDirectoryData(byte[] data, int offset, int length) { byte[] tmp = new byte[length]; System.arraycopy(data, offset, tmp, 0, length); setCentralDirectoryData(tmp); if (localData == null) { setLocalFileDataData(tmp); } }
/** * Create an instance of the appropriate ExtraField, falls back to * {@link UnrecognizedExtraField UnrecognizedExtraField}. * @param headerId the header identifier * @return an instance of the appropriate ExtraField * @exception InstantiationException if unable to instantiate the class * @exception IllegalAccessException if not allowed to instantiate the class * @since 1.1 */ public static ZipExtraField createExtraField(ZipShort headerId) throws InstantiationException, IllegalAccessException { Class<?> c = implementations.get(headerId); if (c != null) { return (ZipExtraField) c.newInstance(); } UnrecognizedExtraField u = new UnrecognizedExtraField(); u.setHeaderId(headerId); return u; }
/** * @param data the array of bytes. * @param offset the source location in the data array. * @param length the number of bytes to use in the data array. * @see ZipExtraField#parseFromLocalFileData(byte[], int, int) */ public void parseFromLocalFileData(byte[] data, int offset, int length) { byte[] tmp = new byte[length]; System.arraycopy(data, offset, tmp, 0, length); setLocalFileDataData(tmp); }
/** * Get the central data. * @return the central data if present, else return the local file data */ public byte[] getCentralDirectoryData() { if (centralData != null) { return ZipUtil.copy(centralData); } return getLocalFileDataData(); }
/** * Get the central data length. * If there is no central data, get the local file data length. * @return the central data length */ public ZipShort getCentralDirectoryLength() { if (centralData != null) { return new ZipShort(centralData.length); } return getLocalFileDataLength(); }