net.sourceforge.plantuml.code.CompressionZopfliZlib Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of plantuml-mit Show documentation
Show all versions of plantuml-mit Show documentation
PlantUML is a component that allows to quickly write diagrams from text.
// THIS FILE HAS BEEN GENERATED BY A PREPROCESSOR.
package net.sourceforge.plantuml.code;
import net.sourceforge.plantuml.zopfli.Options;
import net.sourceforge.plantuml.zopfli.Options.BlockSplitting;
import net.sourceforge.plantuml.zopfli.Options.OutputFormat;
import net.sourceforge.plantuml.zopfli.Zopfli;
public class CompressionZopfliZlib implements Compression {
// ::remove file when __CORE__
public byte[] compress(byte[] in) {
if (in.length == 0)
return null;
int len = in.length * 2;
if (len < 100)
len = 100;
final Zopfli compressor = new Zopfli(len);
final Options options = new Options(OutputFormat.DEFLATE, BlockSplitting.FIRST, 30);
return compressor.compress(options, in).getResult();
}
public ByteArray decompress(byte[] in) throws NoPlantumlCompressionException {
return new CompressionZlib().decompress(in);
}
}