本文整理了Java中org.apache.commons.compress.archivers.zip.ZipEightByteInteger
类的一些代码示例,展示了ZipEightByteInteger
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipEightByteInteger
类的具体详情如下:
包路径:org.apache.commons.compress.archivers.zip.ZipEightByteInteger
类名称:ZipEightByteInteger
[英]Utility class that represents an eight byte integer with conversion rules for the little endian byte order of ZIP files.
[中]一个实用类,它表示一个八字节的整数,并带有ZIP文件小端字节顺序的转换规则。
代码示例来源:origin: org.apache.commons/commons-compress
private static ZipEightByteInteger dateToZip(final Date d) {
if (d == null) { return null; }
return new ZipEightByteInteger((d.getTime() * 10000L) - EPOCH_OFFSET);
}
代码示例来源:origin: org.apache.commons/commons-compress
private static Date zipToDate(final ZipEightByteInteger z) {
if (z == null || ZipEightByteInteger.ZERO.equals(z)) { return null; }
final long l = (z.getLongValue() + EPOCH_OFFSET) / 10000L;
return new Date(l);
}
代码示例来源:origin: org.apache.commons/commons-compress
/**
* Get value as eight bytes in big endian byte order.
* @return value as eight bytes in big endian order
*/
public byte[] getBytes() {
return ZipEightByteInteger.getBytes(value);
}
代码示例来源:origin: org.apache.commons/commons-compress
/**
* Helper method to get the value as a Java long from an eight-byte array
* @param bytes the array of bytes
* @return the corresponding Java BigInteger value
*/
public static BigInteger getValue(final byte[] bytes) {
return getValue(bytes, 0);
}
代码示例来源:origin: org.apache.commons/commons-compress
/**
* Helper method to get the value as a Java long from an eight-byte array
* @param bytes the array of bytes
* @return the corresponding Java long value
*/
public static long getLongValue(final byte[] bytes) {
return getLongValue(bytes, 0);
}
代码示例来源:origin: org.apache.commons/commons-compress
ze.setSize(z64.getSize().getLongValue());
} else if (hasCompressedSize) {
z64.setSize(new ZipEightByteInteger(ze.getSize()));
ze.setCompressedSize(z64.getCompressedSize().getLongValue());
} else if (hasUncompressedSize) {
z64.setCompressedSize(new ZipEightByteInteger(ze.getCompressedSize()));
ze.setLocalHeaderOffset(z64.getRelativeHeaderOffset().getLongValue());
代码示例来源:origin: org.apache.commons/commons-compress
@Override
public boolean equals(final Object o) {
if (o instanceof X000A_NTFS) {
final X000A_NTFS xf = (X000A_NTFS) o;
return (modifyTime == xf.modifyTime || (modifyTime != null && modifyTime.equals(xf.modifyTime))) &&
(accessTime == xf.accessTime || (accessTime != null && accessTime.equals(xf.accessTime))) &&
(createTime == xf.createTime || (createTime != null && createTime.equals(xf.createTime)));
}
return false;
}
代码示例来源:origin: org.apache.commons/commons-compress
@Override
public int hashCode() {
int hc = -123;
if (modifyTime != null) {
hc ^= modifyTime.hashCode();
}
if (accessTime != null) {
// Since accessTime is often same as modifyTime,
// this prevents them from XOR negating each other.
hc ^= Integer.rotateLeft(accessTime.hashCode(), 11);
}
if (createTime != null) {
hc ^= Integer.rotateLeft(createTime.hashCode(), 22);
}
return hc;
}
代码示例来源:origin: org.apache.commons/commons-compress
/**
* Create instance from the eight bytes starting at offset.
* @param bytes the bytes to store as a ZipEightByteInteger
* @param offset the offset to start
*/
public ZipEightByteInteger (final byte[] bytes, final int offset) {
value = ZipEightByteInteger.getValue(bytes, offset);
}
代码示例来源:origin: org.apache.commons/commons-compress
/**
* Parses the "Zip64 end of central directory locator",
* finds the "Zip64 end of central directory record" using the
* parsed information, parses that and positions the stream at the
* first central directory record.
*
* Expects stream to be positioned right behind the "Zip64
* end of central directory locator"'s signature.
*/
private void positionAtCentralDirectory64()
throws IOException {
skipBytes(ZIP64_EOCDL_LOCATOR_OFFSET
- WORD /* signature has already been read */);
dwordBbuf.rewind();
IOUtils.readFully(archive, dwordBbuf);
archive.position(ZipEightByteInteger.getLongValue(dwordBuf));
wordBbuf.rewind();
IOUtils.readFully(archive, wordBbuf);
if (!Arrays.equals(wordBuf, ZipArchiveOutputStream.ZIP64_EOCD_SIG)) {
throw new ZipException("archive's ZIP64 end of central "
+ "directory locator is corrupt.");
}
skipBytes(ZIP64_EOCD_CFD_LOCATOR_OFFSET
- WORD /* signature has already been read */);
dwordBbuf.rewind();
IOUtils.readFully(archive, dwordBbuf);
archive.position(ZipEightByteInteger.getLongValue(dwordBuf));
}
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
ze.setSize(z64.getSize().getLongValue());
} else if (hasCompressedSize) {
z64.setSize(new ZipEightByteInteger(ze.getSize()));
ze.setCompressedSize(z64.getCompressedSize().getLongValue());
} else if (hasUncompressedSize) {
z64.setCompressedSize(new ZipEightByteInteger(ze.getCompressedSize()));
ze.setLocalHeaderOffset(z64.getRelativeHeaderOffset().getLongValue());
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
@Override
public boolean equals(final Object o) {
if (o instanceof X000A_NTFS) {
final X000A_NTFS xf = (X000A_NTFS) o;
return (modifyTime == xf.modifyTime || (modifyTime != null && modifyTime.equals(xf.modifyTime))) &&
(accessTime == xf.accessTime || (accessTime != null && accessTime.equals(xf.accessTime))) &&
(createTime == xf.createTime || (createTime != null && createTime.equals(xf.createTime)));
}
return false;
}
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
@Override
public int hashCode() {
int hc = -123;
if (modifyTime != null) {
hc ^= modifyTime.hashCode();
}
if (accessTime != null) {
// Since accessTime is often same as modifyTime,
// this prevents them from XOR negating each other.
hc ^= Integer.rotateLeft(accessTime.hashCode(), 11);
}
if (createTime != null) {
hc ^= Integer.rotateLeft(createTime.hashCode(), 22);
}
return hc;
}
代码示例来源:origin: org.apache.commons/commons-compress
/**
* Get value as eight bytes in big endian byte order.
* @param value the value to convert
* @return value as eight bytes in big endian byte order
*/
public static byte[] getBytes(final long value) {
return getBytes(BigInteger.valueOf(value));
}
代码示例来源:origin: org.apache.commons/commons-compress
private void readTimeAttr(final byte[] data, int offset, final int length) {
if (length >= 2 + 3 * 8) {
final ZipShort tagValueLength = new ZipShort(data, offset);
if (TIME_ATTR_SIZE.equals(tagValueLength)) {
offset += 2;
modifyTime = new ZipEightByteInteger(data, offset);
offset += 8;
accessTime = new ZipEightByteInteger(data, offset);
offset += 8;
createTime = new ZipEightByteInteger(data, offset);
}
}
}
代码示例来源:origin: org.apache.commons/commons-compress
/**
* Override to make two instances with same value equal.
* @param o an object to compare
* @return true if the objects are equal
*/
@Override
public boolean equals(final Object o) {
if (o == null || !(o instanceof ZipEightByteInteger)) {
return false;
}
return value.equals(((ZipEightByteInteger) o).getValue());
}
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
private static Date zipToDate(final ZipEightByteInteger z) {
if (z == null || ZipEightByteInteger.ZERO.equals(z)) { return null; }
final long l = (z.getLongValue() + EPOCH_OFFSET) / 10000L;
return new Date(l);
}
代码示例来源:origin: org.apache.commons/commons-compress
/**
* Records whether a Zip64 extra is present and sets the size
* information from it if sizes are 0xFFFFFFFF and the entry
* doesn't use a data descriptor.
*/
private void processZip64Extra(final ZipLong size, final ZipLong cSize) {
final Zip64ExtendedInformationExtraField z64 =
(Zip64ExtendedInformationExtraField)
current.entry.getExtraField(Zip64ExtendedInformationExtraField.HEADER_ID);
current.usesZip64 = z64 != null;
if (!current.hasDataDescriptor) {
if (z64 != null // same as current.usesZip64 but avoids NPE warning
&& (cSize.equals(ZipLong.ZIP64_MAGIC) || size.equals(ZipLong.ZIP64_MAGIC)) ) {
current.entry.setCompressedSize(z64.getCompressedSize().getLongValue());
current.entry.setSize(z64.getSize().getLongValue());
} else {
current.entry.setCompressedSize(cSize.getValue());
current.entry.setSize(size.getValue());
}
}
}
代码示例来源:origin: org.apache.commons/commons-compress
private int addSizes(final byte[] data) {
int off = 0;
if (size != null) {
System.arraycopy(size.getBytes(), 0, data, 0, DWORD);
off += DWORD;
}
if (compressedSize != null) {
System.arraycopy(compressedSize.getBytes(), 0, data, off, DWORD);
off += DWORD;
}
return off;
}
}
代码示例来源:origin: org.apache.commons/commons-compress
@Override
public void parseFromCentralDirectoryData(final byte[] buffer, int offset,
final int length)
throws ZipException {
// store for processing in reparseCentralDirectoryData
rawCentralDirectoryData = new byte[length];
System.arraycopy(buffer, offset, rawCentralDirectoryData, 0, length);
// if there is no size information in here, we are screwed and
// can only hope things will get resolved by LFH data later
// But there are some cases that can be detected
// * all data is there
// * length == 24 -> both sizes and offset
// * length % 8 == 4 -> at least we can identify the diskStart field
if (length >= 3 * DWORD + WORD) {
parseFromLocalFileData(buffer, offset, length);
} else if (length == 3 * DWORD) {
size = new ZipEightByteInteger(buffer, offset);
offset += DWORD;
compressedSize = new ZipEightByteInteger(buffer, offset);
offset += DWORD;
relativeHeaderOffset = new ZipEightByteInteger(buffer, offset);
} else if (length % DWORD == WORD) {
diskStart = new ZipLong(buffer, offset + length - WORD);
}
}
内容来源于网络,如有侵权,请联系作者删除!