/** * Are the classes required to support LZMA compression available? * @return true if the classes required to support LZMA * compression are available */ public static boolean isLZMACompressionAvailable() { final CachedAvailability cachedResult = cachedLZMAAvailability; if (cachedResult != CachedAvailability.DONT_CACHE) { return cachedResult == CachedAvailability.CACHED_AVAILABLE; } return internalIsLZMACompressionAvailable(); }
private static boolean internalIsLZMACompressionAvailable() { try { LZMACompressorInputStream.matches(null, 0); return true; } catch (final NoClassDefFoundError error) { return false; } }
/** {@inheritDoc} */ @Override public int read() throws IOException { final int ret = in.read(); count(ret == -1 ? 0 : 1); return ret; }
/** * @param stream the stream to read from, should be buffered */ @Override public CompressorInputStream getCompressorStream(InputStream stream) throws IOException { return new LZMACompressorInputStream(stream); }
if (!LZMAUtils.isLZMACompressionAvailable()) { throw new CompressorException("LZMA compression is not available" + YOU_NEED_XZ_JAVA); return new LZMACompressorInputStream(in, memoryLimitInKb);
if (LZMAUtils.matches(signature, signatureLength)) { return LZMA;
@Override protected InputStream open(InputStream containerInputStream) throws IOException { return new LZMACompressorInputStream(containerInputStream); } }
@Override public void save(Factory f, OutputStream out) throws IOException { if (f.getEnvironment().getCompressionType() == CompressionType.GZIP) { out = new GZIPOutputStream(out); } else if (f.getEnvironment().getCompressionType() == CompressionType.LZMA) { out = new LZMACompressorOutputStream(out); } else if (f.getEnvironment().getCompressionType() == CompressionType.BZIP2) { out = new BZip2CompressorOutputStream(out); } try (ObjectOutputStream oos = new ObjectOutputStream(new BufferedOutputStream(out))) { oos.writeObject(f); oos.flush(); } }
/** * Whether to cache the result of the LZMA check. * * <p>This defaults to {@code false} in an OSGi environment and {@code true} otherwise.</p> * @param doCache whether to cache the result */ public static void setCacheLZMAAvailablity(final boolean doCache) { if (!doCache) { cachedLZMAAvailability = CachedAvailability.DONT_CACHE; } else if (cachedLZMAAvailability == CachedAvailability.DONT_CACHE) { final boolean hasLzma = internalIsLZMACompressionAvailable(); cachedLZMAAvailability = hasLzma ? CachedAvailability.CACHED_AVAILABLE // NOSONAR : CachedAvailability.CACHED_UNAVAILABLE; } }
/** {@inheritDoc} */ @Override public int read(final byte[] buf, final int off, final int len) throws IOException { final int ret = in.read(buf, off, len); count(ret); return ret; }
private static boolean internalIsLZMACompressionAvailable() { try { LZMACompressorInputStream.matches(null, 0); return true; } catch (final NoClassDefFoundError error) { return false; } }
@Override protected InputStream open(InputStream containerInputStream) throws IOException { return new LZMACompressorInputStream(containerInputStream); } }
/** * @param stream the stream to write to, should be buffered */ @Override public CompressorOutputStream getCompressorStream(OutputStream stream) throws IOException { return new LZMACompressorOutputStream(stream); } }
/** * Are the classes required to support LZMA compression available? * @return true if the classes required to support LZMA * compression are available */ public static boolean isLZMACompressionAvailable() { final CachedAvailability cachedResult = cachedLZMAAvailability; if (cachedResult != CachedAvailability.DONT_CACHE) { return cachedResult == CachedAvailability.CACHED_AVAILABLE; } return internalIsLZMACompressionAvailable(); }
/** {@inheritDoc} */ @Override public int read() throws IOException { final int ret = in.read(); count(ret == -1 ? 0 : 1); return ret; }
@Override public CompressorInputStream compressorInputStream(InputStream is) throws IOException { return new LZMACompressorInputStream(is); }
/** * Whether to cache the result of the LZMA check. * * <p>This defaults to {@code false} in an OSGi environment and {@code true} otherwise.</p> * @param doCache whether to cache the result */ public static void setCacheLZMAAvailablity(final boolean doCache) { if (!doCache) { cachedLZMAAvailability = CachedAvailability.DONT_CACHE; } else if (cachedLZMAAvailability == CachedAvailability.DONT_CACHE) { final boolean hasLzma = internalIsLZMACompressionAvailable(); cachedLZMAAvailability = hasLzma ? CachedAvailability.CACHED_AVAILABLE // NOSONAR : CachedAvailability.CACHED_UNAVAILABLE; } }
@Override public CompressorInputStream compressorInputStream(InputStream is) throws IOException { return new LZMACompressorInputStream(is); }
in = new GZIPInputStream(buffered); } else if (s.equals(CompressorStreamFactory.LZMA)) { in = new LZMACompressorInputStream(buffered); } else if (s.equals(CompressorStreamFactory.BZIP2)) { in = new BZip2CompressorInputStream(buffered);