gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-17 09:08:40 24 4
gpt4 key购买 nike

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

ZipArchiveEntry.getMethod介绍

[英]Returns the compression method of this entry, or -1 if the compression method has not been specified.
[中]返回此项的压缩方法,如果未指定压缩方法,则返回-1。

代码示例

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

private ZipArchiveEntryRequest(final ZipArchiveEntry zipArchiveEntry, final InputStreamSupplier payloadSupplier) {
  // this constructor has "safe" access to all member variables on zipArchiveEntry
  this.zipArchiveEntry = zipArchiveEntry;
  this.payloadSupplier = payloadSupplier;
  this.method = zipArchiveEntry.getMethod();
}

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

/**
 * Whether this library supports the compression method used by
 * the given entry.
 *
 * @return true if the compression method is supported
 */
private static boolean supportsMethodOf(final ZipArchiveEntry entry) {
  return entry.getMethod() == ZipEntry.STORED
    || entry.getMethod() == ZipMethod.UNSHRINKING.getCode()
    || entry.getMethod() == ZipMethod.IMPLODING.getCode()
    || entry.getMethod() == ZipEntry.DEFLATED
    || entry.getMethod() == ZipMethod.ENHANCED_DEFLATED.getCode()
    || entry.getMethod() == ZipMethod.BZIP2.getCode();
}

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

/**
 * Ensures all bytes sent to the deflater are written to the stream.
 */
private void flushDeflater() throws IOException {
  if (entry.entry.getMethod() == DEFLATED) {
    streamCompressor.flushDeflater();
  }
}

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

/**
 * Whether this entry requires a data descriptor this library can work with.
 *
 * @return true if allowStoredEntriesWithDataDescriptor is true,
 * the entry doesn't require any data descriptor or the method is
 * DEFLATED or ENHANCED_DEFLATED.
 */
private boolean supportsDataDescriptorFor(final ZipArchiveEntry entry) {
  return !entry.getGeneralPurposeBit().usesDataDescriptor()
      || (allowStoredEntriesWithDataDescriptor && entry.getMethod() == ZipEntry.STORED)
      || entry.getMethod() == ZipEntry.DEFLATED
      || entry.getMethod() == ZipMethod.ENHANCED_DEFLATED.getCode();
}

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

/**
 * If the mode is AsNeeded and the entry is a compressed entry of
 * unknown size that gets written to a non-seekable stream then
 * change the default to Never.
 *
 * @since 1.3
 */
private Zip64Mode getEffectiveZip64Mode(final ZipArchiveEntry ze) {
  if (zip64Mode != Zip64Mode.AsNeeded
    || channel != null
    || ze.getMethod() != DEFLATED
    || ze.getSize() != ArchiveEntry.SIZE_UNKNOWN) {
    return zip64Mode;
  }
  return Zip64Mode.Never;
}

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

/**
 * Whether the compressed size for the entry is either known or
 * not required by the compression method being used.
 */
private boolean supportsCompressedSizeFor(final ZipArchiveEntry entry) {
  return entry.getCompressedSize() != ArchiveEntry.SIZE_UNKNOWN
    || entry.getMethod() == ZipEntry.DEFLATED
    || entry.getMethod() == ZipMethod.ENHANCED_DEFLATED.getCode()
    || (entry.getGeneralPurposeBit().usesDataDescriptor()
      && allowStoredEntriesWithDataDescriptor
      && entry.getMethod() == ZipEntry.STORED);
}

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

final int method = zipArchiveEntry.getMethod();
if (method == ZipMethod.UNKNOWN_CODE) {
  throw new IllegalArgumentException("Method must be set on zipArchiveEntry: " + zipArchiveEntry);

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

/**
 * Whether this stream is able to write the given entry.
 *
 * <p>May return false if it is set up to use encryption or a
 * compression method that hasn't been implemented yet.</p>
 * @since 1.1
 */
@Override
public boolean canWriteEntryData(final ArchiveEntry ae) {
  if (ae instanceof ZipArchiveEntry) {
    final ZipArchiveEntry zae = (ZipArchiveEntry) ae;
    return zae.getMethod() != ZipMethod.IMPLODING.getCode()
      && zae.getMethod() != ZipMethod.UNSHRINKING.getCode()
      && ZipUtil.canHandleEntryData(zae);
  }
  return false;
}

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

/**
 * @since 1.17
 */
@Override
public long getCompressedCount() {
  if (current.entry.getMethod() == ZipArchiveOutputStream.STORED) {
    return current.bytesRead;
  } else if (current.entry.getMethod() == ZipArchiveOutputStream.DEFLATED) {
    return getBytesInflated();
  } else if (current.entry.getMethod() == ZipMethod.UNSHRINKING.getCode()) {
    return ((UnshrinkingInputStream) current.in).getCompressedCount();
  } else if (current.entry.getMethod() == ZipMethod.IMPLODING.getCode()) {
    return ((ExplodingInputStream) current.in).getCompressedCount();
  } else if (current.entry.getMethod() == ZipMethod.ENHANCED_DEFLATED.getCode()) {
    return ((Deflate64CompressorInputStream) current.in).getCompressedCount();
  } else if (current.entry.getMethod() == ZipMethod.BZIP2.getCode()) {
    return ((BZip2CompressorInputStream) current.in).getCompressedCount();
  } else {
    return -1;
  }
}

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

/**
 * Provides default values for compression method and last
 * modification time.
 */
private void setDefaults(final ZipArchiveEntry entry) {
  if (entry.getMethod() == -1) { // not specified
    entry.setMethod(method);
  }
  if (entry.getTime() == -1) { // not specified
    entry.setTime(System.currentTimeMillis());
  }
}

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

/**
 * Writes bytes to ZIP entry.
 * @param b the byte array to write
 * @param offset the start position to write from
 * @param length the number of bytes to write
 * @throws IOException on error
 */
@Override
public void write(final byte[] b, final int offset, final int length) throws IOException {
  if (entry == null) {
    throw new IllegalStateException("No current entry");
  }
  ZipUtil.checkRequestedFeatures(entry.entry);
  final long writtenThisTime = streamCompressor.write(b, offset, length, entry.entry.getMethod());
  count(writtenThisTime);
}

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

if (current.entry.getMethod() == ZipArchiveOutputStream.STORED) {
  read = readStored(buffer, offset, length);
} else if (current.entry.getMethod() == ZipArchiveOutputStream.DEFLATED) {
  read = readDeflated(buffer, offset, length);
} else if (current.entry.getMethod() == ZipMethod.UNSHRINKING.getCode()
    || current.entry.getMethod() == ZipMethod.IMPLODING.getCode()
    || current.entry.getMethod() == ZipMethod.ENHANCED_DEFLATED.getCode()
    || current.entry.getMethod() == ZipMethod.BZIP2.getCode()) {
  read = current.in.read(buffer, offset, length);
} else {
  throw new UnsupportedZipFeatureException(ZipMethod.getMethodByCode(current.entry.getMethod()),
      current.entry);

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

private void writeLocalFileHeader(final ZipArchiveEntry ze, final boolean phased) throws IOException {
  final boolean encodable = zipEncoding.canEncode(ze.getName());
  final ByteBuffer name = getName(ze);
  if (createUnicodeExtraFields != UnicodeExtraFieldPolicy.NEVER) {
    addUnicodeExtraFields(ze, encodable, name);
  }
  final long localHeaderStart = streamCompressor.getTotalBytesWritten();
  final byte[] localHeader = createLocalFileHeader(ze, name, encodable, phased, localHeaderStart);
  metaData.put(ze, new EntryMetaData(localHeaderStart, usesDataDescriptor(ze.getMethod(), phased)));
  entry.localDataStart = localHeaderStart + LFH_CRC_OFFSET; // At crc offset
  writeCounted(localHeader);
  entry.dataStart = streamCompressor.getTotalBytesWritten();
}

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

/**
   * Checks whether the entry requires features not (yet) supported
   * by the library and throws an exception if it does.
   */
  static void checkRequestedFeatures(final ZipArchiveEntry ze)
    throws UnsupportedZipFeatureException {
    if (!supportsEncryptionOf(ze)) {
      throw
        new UnsupportedZipFeatureException(UnsupportedZipFeatureException
                          .Feature.ENCRYPTION, ze);
    }
    if (!supportsMethodOf(ze)) {
      final ZipMethod m = ZipMethod.getMethodByCode(ze.getMethod());
      if (m == null) {
        throw
          new UnsupportedZipFeatureException(UnsupportedZipFeatureException
                            .Feature.METHOD, ze);
      }
      throw new UnsupportedZipFeatureException(m, ze);
    }
  }
}

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

&& getPlatform() == other.getPlatform()
&& getExternalAttributes() == other.getExternalAttributes()
&& getMethod() == other.getMethod()
&& getSize() == other.getSize()
&& getCrc() == other.getCrc()

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

} else if (entry.entry.getMethod() == STORED
      && entry.entry.getSize() != ArchiveEntry.SIZE_UNKNOWN) {
if (entry.entry.getMethod() == DEFLATED && hasCompressionLevelChanged) {
  def.setLevel(level);
  hasCompressionLevelChanged = false;

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

final Zip64Mode effectiveMode)
throws ZipException {
if (entry.entry.getMethod() == DEFLATED) {

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

/**
 * Throws an exception if the size is unknown for a stored entry
 * that is written to a non-seekable output or the entry is too
 * big to be written without Zip64 extra but the mode has been set
 * to Never.
 */
private void validateSizeInformation(final Zip64Mode effectiveMode)
  throws ZipException {
  // Size/CRC not required if SeekableByteChannel is used
  if (entry.entry.getMethod() == STORED && channel == null) {
    if (entry.entry.getSize() == ArchiveEntry.SIZE_UNKNOWN) {
      throw new ZipException("uncompressed size is required for"
                  + " STORED method when not writing to a"
                  + " file");
    }
    if (entry.entry.getCrc() == ZipArchiveEntry.CRC_UNKNOWN) {
      throw new ZipException("crc checksum is required for STORED"
                  + " method when not writing to a file");
    }
    entry.entry.setCompressedSize(entry.entry.getSize());
  }
  if ((entry.entry.getSize() >= ZIP64_MAGIC
     || entry.entry.getCompressedSize() >= ZIP64_MAGIC)
    && effectiveMode == Zip64Mode.Never) {
    throw new Zip64RequiredException(Zip64RequiredException
                     .getEntryTooBigMessage(entry.entry));
  }
}

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

/**
 * Writes the data descriptor entry.
 * @param ze the entry to write
 * @throws IOException on error
 */
protected void writeDataDescriptor(final ZipArchiveEntry ze) throws IOException {
  if (!usesDataDescriptor(ze.getMethod(), false)) {
    return;
  }
  writeCounted(DD_SIG);
  writeCounted(ZipLong.getBytes(ze.getCrc()));
  if (!hasZip64Extra(ze)) {
    writeCounted(ZipLong.getBytes(ze.getCompressedSize()));
    writeCounted(ZipLong.getBytes(ze.getSize()));
  } else {
    writeCounted(ZipEightByteInteger.getBytes(ze.getCompressedSize()));
    writeCounted(ZipEightByteInteger.getBytes(ze.getSize()));
  }
}

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

writeOut(ZipShort.getBytes(versionNeededToExtract(entry.entry.getMethod(), false, false)));

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com