org.apache.commons.compress.archivers.zip.ZipShort.equals()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(4.3k)|赞(0)|评价(0)|浏览(71)

本文整理了Java中org.apache.commons.compress.archivers.zip.ZipShort.equals()方法的一些代码示例,展示了ZipShort.equals()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipShort.equals()方法的具体详情如下:
包路径:org.apache.commons.compress.archivers.zip.ZipShort
类名称:ZipShort
方法名:equals

ZipShort.equals介绍

[英]Override to make two instances with same value equal.
[中]重写以使具有相同值的两个实例相等。

代码示例

代码示例来源:origin: org.apache.commons/commons-compress

/**
 * Looks up an extra field by its header id.
 *
 * @param type the header id
 * @return null if no such field exists.
 */
public ZipExtraField getExtraField(final ZipShort type) {
  if (extraFields != null) {
    for (final ZipExtraField extraField : extraFields) {
      if (type.equals(extraField.getHeaderId())) {
        return extraField;
      }
    }
  }
  return null;
}

代码示例来源:origin: org.apache.commons/commons-compress

/**
 * Remove an extra field.
 * @param type the type of extra field to remove
 */
public void removeExtraField(final ZipShort type) {
  if (extraFields == null) {
    throw new java.util.NoSuchElementException();
  }
  final List<ZipExtraField> newResult = new ArrayList<>();
  for (final 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();
}

代码示例来源: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

/**
 * Populate data from this array as if it was in local file data.
 *
 * @param data   an array of bytes
 * @param offset the start offset
 * @param length the number of bytes in the array from offset
 * @throws java.util.zip.ZipException on error
 */
@Override
public void parseFromLocalFileData(
    final byte[] data, int offset, final int length
) throws ZipException {
  final int len = offset + length;
  // skip reserved
  offset += 4;
  while (offset + 4 <= len) {
    final ZipShort tag = new ZipShort(data, offset);
    offset += 2;
    if (tag.equals(TIME_ATTR_TAG)) {
      readTimeAttr(data, offset, len - offset);
      break;
    }
    final ZipShort size = new ZipShort(data, offset);
    offset += 2 + size.getValue();
  }
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

/**
 * Looks up an extra field by its header id.
 *
 * @param type the header id
 * @return null if no such field exists.
 */
public ZipExtraField getExtraField(final ZipShort type) {
  if (extraFields != null) {
    for (final ZipExtraField extraField : extraFields) {
      if (type.equals(extraField.getHeaderId())) {
        return extraField;
      }
    }
  }
  return null;
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

/**
 * Remove an extra field.
 * @param type the type of extra field to remove
 */
public void removeExtraField(final ZipShort type) {
  if (extraFields == null) {
    throw new java.util.NoSuchElementException();
  }
  final List<ZipExtraField> newResult = new ArrayList<>();
  for (final 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();
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

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: com.impetus.fabric/fabric-jdbc-driver-shaded

/**
 * Populate data from this array as if it was in local file data.
 *
 * @param data   an array of bytes
 * @param offset the start offset
 * @param length the number of bytes in the array from offset
 * @throws java.util.zip.ZipException on error
 */
@Override
public void parseFromLocalFileData(
    final byte[] data, int offset, final int length
) throws ZipException {
  final int len = offset + length;
  // skip reserved
  offset += 4;
  while (offset + 4 <= len) {
    final ZipShort tag = new ZipShort(data, offset);
    offset += 2;
    if (tag.equals(TIME_ATTR_TAG)) {
      readTimeAttr(data, offset, len - offset);
      break;
    }
    final ZipShort size = new ZipShort(data, offset);
    offset += 2 + size.getValue();
  }
}

相关文章