📄 zipstreamfactory.java
字号:
// You can redistribute this software and/or modify it under the terms of// the Ozone Core License version 1 published by ozone-db.org.//// Copyright (C) 2003-@year@, Leo Mekenkamp. All rights reserved.//// $Id: ZipStreamFactory.java,v 1.1 2004/01/02 09:24:38 leomekenkamp Exp $package org.ozoneDB.core.storage.gammaStore;import java.io.IOException;import java.io.InputStream;import java.io.OutputStream;import java.util.Collection;import java.util.LinkedList;import java.util.List;import java.util.Properties;import java.util.zip.GZIPInputStream;import java.util.zip.GZIPOutputStream;import java.util.zip.ZipEntry;import java.util.zip.ZipInputStream;import java.util.zip.ZipOutputStream;import org.ozoneDB.core.storage.PropertyConfigurable;import org.ozoneDB.core.storage.PropertyInfo;/** * Factory that creates streams that read/write to other streams via a Zip * stream. * * @author <a href="mailto:leoATmekenkampD0Tcom">Leo Mekenkamp (mind the anti sp@m)</a> * @version $Id: ZipStreamFactory.java,v 1.1 2004/01/02 09:24:38 leomekenkamp Exp $ */public class ZipStreamFactory implements StreamFactory, PropertyConfigurable { public static final PropertyInfo LEVEL = new PropertyInfo( ".level", "[0-9]", "1", "compression level, see java.util.zip.ZipOutputStream.setLevel(int)", new String[] {"1", "4"} ); public static final PropertyInfo METHOD = new PropertyInfo( ".method", "int", "8", "method used for compression, see java.util.zip.ZipOutputStream.setMethod(int)", new String[] {"8 (DEFLATED)"} ); public static final PropertyInfo ENTRYNAME = new PropertyInfo( ".entryName", "String", "O", "name for the ZipEntry in the zip file", new String[] {"entry", "FooBar", "R_Daneel_Olivaw"} ); private String prefix; private int method; private int level; private String entryName; /** * As prescribed by the <code>PropertyConfigurable</code> interface. */ public ZipStreamFactory(Properties properties, String prefix) { System.out.println(properties + " " + prefix); this.prefix = prefix; method = Integer.parseInt(properties.getProperty(prefix + METHOD.getKey(), METHOD.getDefaultValue())); level = Integer.parseInt(properties.getProperty(prefix + LEVEL, LEVEL.getDefaultValue())); entryName = properties.getProperty(prefix + ENTRYNAME, ENTRYNAME.getDefaultValue()); } public InputStream createInputStream(InputStream in) throws IOException { ZipInputStream result = new ZipInputStream(in); result.getNextEntry(); return result; } public OutputStream createOutputStream(OutputStream out) throws IOException { ZipOutputStream result = new ZipOutputStream(out); result.putNextEntry(new ZipEntry(entryName)); return result; } public Collection getPropertyInfos() { Collection result = new LinkedList(); result.add(LEVEL); result.add(METHOD); return result; } public String getPrefix() { return prefix; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -