@Test public void testCanDecode() { CompressionTransformFactory factory = new CompressionTransformFactory(); checkDecode(factory, "COMP", "LZMA/9", true); checkDecode(factory, "COMP", "Deflate/5", true); checkDecode(factory, "COMP", "Deflate", true); checkDecode(factory, "COMP", "", false); checkDecode(factory, "COMP", null, false); checkDecode(factory, "COMP", "BZip2/2", false); checkDecode(factory, "COMP", "GZ/9", false); checkDecode(factory, "ENC", "Deflate", false); checkDecode(factory, "SomethingCrazy", "", false); checkDecode(factory, "", "", false); checkDecode(factory, null, null, false); }
public boolean canDecode(String transformClass, String config, Map<String,String> metadata) { if(config == null) { logger.warn("Configuration string null"); return false; } String[] configParams = config.split("/"); if(configParams.length < 1) { logger.warn("Could not decode config string {}", config); return false; } try { CompressionMode.valueOf(configParams[0]); } catch(IllegalArgumentException e) { logger.warn("Invalid compression mode {}", configParams[0]); return false; } return getTransformClass().equals(transformClass); }
CompressionTransformFactory extends
        TransformFactory<CompressionOutputTransform, CompressionInputTransform> { public boolean canDecode(String transformClass, String config, Map<String,String> metadata) { if(config == null) { logger.warn("Configuration string null"); return false; } String[] configParams = config.split("/"); if(configParams.length < 1) { logger.warn("Could not decode config string {}", config); return false; } try { CompressionMode.valueOf(configParams[0]); } catch(IllegalArgumentException e) { logger.warn("Invalid compression mode {}", configParams[0]); return false; } return getTransformClass().equals(transformClass); } }
CompressionTransformFactory extends
        TransformFactory<CompressionOutputTransform, CompressionInputTransform> { public boolean canDecode(String transformClass, String config, Map<String,String> metadata) { if(config == null) { logger.warn("Configuration string null"); return false; } String[] configParams = config.split("/"); if(configParams.length < 1) { logger.warn("Could not decode config string {}", config); return false; } try { CompressionMode.valueOf(configParams[0]); } catch(IllegalArgumentException e) { logger.warn("Invalid compression mode {}", configParams[0]); return false; } return getTransformClass().equals(transformClass); } CompressionTransformFactory(); }
CompressionTransformFactory extends
        TransformFactory<CompressionOutputTransform, CompressionInputTransform> { public boolean canDecode(String transformClass, String config, Map<String,String> metadata) { if(config == null) { logger.warn("Configuration string null"); return false; } String[] configParams = config.split("/"); if(configParams.length < 1) { logger.warn("Could not decode config string {}", config); return false; } try { CompressionMode.valueOf(configParams[0]); } catch(IllegalArgumentException e) { logger.warn("Invalid compression mode {}", configParams[0]); return false; } return getTransformClass().equals(transformClass); } 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> { public boolean canDecode(String transformClass, String config, Map<String,String> metadata) { if(config == null) { logger.warn("Configuration string null"); return false; } String[] configParams = config.split("/"); if(configParams.length < 1) { logger.warn("Could not decode config string {}", config); return false; } try { CompressionMode.valueOf(configParams[0]); } catch(IllegalArgumentException e) { logger.warn("Invalid compression mode {}", configParams[0]); return false; } return getTransformClass().equals(transformClass); } 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; }