@Test public void testGetInputTransform() throws IOException { CompressionTransformFactory factory = new CompressionTransformFactory(); byte[] lzmaConfig = new byte[] { 0, 0, 0, 0, 0 }; CompressionInputTransform t = factory.getInputTransform("COMP:LZMA/9", new ByteArrayInputStream(lzmaConfig), new HashMap<String, String>()); assertNotNull("input transform null", t); }
@Override public CompressionInputTransform getInputTransform(String transformConfig, InputStream streamToDecode, Map<String, String> metadata) throws IOException { String[] transformTuple = splitTransformConfig(transformConfig); if(!TransformConstants.COMPRESSION_CLASS.equals(transformTuple[0])) { throw new IllegalArgumentException("Unsupported transform class: " + transformTuple[0]); } String[] configParams = transformTuple[1].split("/"); if(configParams.length < 1) { throw new IllegalArgumentException("Could not decode configuration: " + configParams); } CompressionMode mode = CompressionMode.valueOf(configParams[0]); switch(mode) { case Deflate: return new DeflateInputTransform(streamToDecode, metadata); case LZMA: return new LZMAInputTransform(streamToDecode, metadata); default: throw new IllegalArgumentException("Unknown compression method " + mode); } }
CompressionTransformFactory extends
        TransformFactory<CompressionOutputTransform, CompressionInputTransform> { @Override public CompressionInputTransform getInputTransform(String transformConfig, InputStream streamToDecode, Map<String, String> metadata) throws IOException { String[] transformTuple = splitTransformConfig(transformConfig); if(!TransformConstants.COMPRESSION_CLASS.equals(transformTuple[0])) { throw new IllegalArgumentException("Unsupported transform class: " + transformTuple[0]); } String[] configParams = transformTuple[1].split("/"); if(configParams.length < 1) { throw new IllegalArgumentException("Could not decode configuration: " + configParams); } CompressionMode mode = CompressionMode.valueOf(configParams[0]); switch(mode) { case Deflate: return new DeflateInputTransform(streamToDecode, metadata); case LZMA: return new LZMAInputTransform(streamToDecode, metadata); default: throw new IllegalArgumentException("Unknown compression method " + mode); } } }
CompressionTransformFactory extends
        TransformFactory<CompressionOutputTransform, CompressionInputTransform> { @Override public CompressionInputTransform getInputTransform(String transformConfig, InputStream streamToDecode, Map<String, String> metadata) throws IOException { String[] transformTuple = splitTransformConfig(transformConfig); if(!TransformConstants.COMPRESSION_CLASS.equals(transformTuple[0])) { throw new IllegalArgumentException("Unsupported transform class: " + transformTuple[0]); } String[] configParams = transformTuple[1].split("/"); if(configParams.length < 1) { throw new IllegalArgumentException("Could not decode configuration: " + configParams); } CompressionMode mode = CompressionMode.valueOf(configParams[0]); switch(mode) { case Deflate: return new DeflateInputTransform(streamToDecode, metadata); case LZMA: return new LZMAInputTransform(streamToDecode, metadata); default: throw new IllegalArgumentException("Unknown compression method " + mode); } } CompressionTransformFactory(); }
CompressionTransformFactory extends
        TransformFactory<CompressionOutputTransform, CompressionInputTransform> { @Override public CompressionInputTransform getInputTransform(String transformConfig, InputStream streamToDecode, Map<String, String> metadata) throws IOException { String[] transformTuple = splitTransformConfig(transformConfig); if(!TransformConstants.COMPRESSION_CLASS.equals(transformTuple[0])) { throw new IllegalArgumentException("Unsupported transform class: " + transformTuple[0]); } String[] configParams = transformTuple[1].split("/"); if(configParams.length < 1) { throw new IllegalArgumentException("Could not decode configuration: " + configParams); } CompressionMode mode = CompressionMode.valueOf(configParams[0]); switch(mode) { case Deflate: return new DeflateInputTransform(streamToDecode, metadata); case LZMA: return new LZMAInputTransform(streamToDecode, metadata); default: throw new IllegalArgumentException("Unknown compression method " + mode); } } CompressionTransformFactory(); CompressionMode getCompressMode(); void setCompressMode(CompressionMode compressMode); int getCompressionLevel(); void setCompressionLevel(int compressionLevel); @Override CompressionOutputTransform getOutputTransform(
            OutputStream streamToEncodeTo, Map<String, String> metadataToEncode); @Override CompressionOutputTransform getOutputTransform(
            InputStream streamToEncode, Map<String, String> metadataToEncode); @Override CompressionInputTransform getInputTransform(String transformConfig, InputStream streamToDecode, Map<String, String> metadata); @Override String getTransformClass(); boolean canDecode(String transformClass, String config, Map<String,String> metadata); static long memoryRequiredForLzma(int compressionLevel); static long memoryRequiredForLzma(LzmaProfile profile); }
CompressionTransformFactory extends
        TransformFactory<CompressionOutputTransform, CompressionInputTransform> { @Override public CompressionInputTransform getInputTransform(String transformConfig, InputStream streamToDecode, Map<String, String> metadata) throws IOException { String[] transformTuple = splitTransformConfig(transformConfig); if(!TransformConstants.COMPRESSION_CLASS.equals(transformTuple[0])) { throw new IllegalArgumentException("Unsupported transform class: " + transformTuple[0]); } String[] configParams = transformTuple[1].split("/"); if(configParams.length < 1) { throw new IllegalArgumentException("Could not decode configuration: " + configParams); } CompressionMode mode = CompressionMode.valueOf(configParams[0]); switch(mode) { case Deflate: return new DeflateInputTransform(streamToDecode, metadata); case LZMA: return new LZMAInputTransform(streamToDecode, metadata); default: throw new IllegalArgumentException("Unknown compression method " + mode); } } CompressionTransformFactory(); CompressionMode getCompressMode(); void setCompressMode(CompressionMode compressMode); int getCompressionLevel(); void setCompressionLevel(int compressionLevel); @Override CompressionOutputTransform getOutputTransform(
            OutputStream streamToEncodeTo, Map<String, String> metadataToEncode); @Override CompressionOutputTransform getOutputTransform(
            InputStream streamToEncode, Map<String, String> metadataToEncode); @Override CompressionInputTransform getInputTransform(String transformConfig, InputStream streamToDecode, Map<String, String> metadata); @Override String getTransformClass(); boolean canDecode(String transformClass, String config, Map<String,String> metadata); static long memoryRequiredForLzma(int compressionLevel); static long memoryRequiredForLzma(LzmaProfile profile); public CompressionMode compressMode; public int compressionLevel; static LzmaProfile LZMA_COMPRESSION_PROFILE; }