クラス org.objectweb.cjdbc.common.util.ZipMe

すべてのメンバ一覧

説明

Zip utility class inspired by the java tutorials of sun.

作者:
Nicolas Modrzyk

ZipMe.java48 行で定義されています。

Public メソッド

 ZipMe ()
void create (String zipname, String rootdir) throws Exception
void create (String zipname, String rootdir, String putMeThere) throws Exception
void expand (String zipname, String targetdir, String getMeThere) throws Exception
long getZipSize ()
void expand (String zipname, String targetdir) throws Exception
boolean getUseCompression ()
void setUseCompression (boolean useCompression)

Static Public 変数

final String ZIP_EXT = ".cjdbc"

スタティック変数

final int BUFFER = 2048
final int STORE_FULL_PATH_IN_ZIP = 0
final int STORE_NAME_ONLY_IN_ZIP = 1
final int STORE_RELATIVE_PATH_IN_ZIP = 2
final int STORE_PATH_FROM_ZIP_ROOT = 3
final int STORE_POLICY = STORE_PATH_FROM_ZIP_ROOT
Trace logger

Private メソッド

void dirFunc (String dirName) throws IOException
void zipFunc (String filePath) throws IOException

Private 変数

FileOutputStream fos = null
ZipOutputStream zos = null
ZipInputStream zis = null
FileInputStream fis = null
BufferedOutputStream dest
String rootDir
String zipPath
boolean useCompression = true


コンストラクタとデストラクタ

org.objectweb.cjdbc.common.util.ZipMe.ZipMe  ) 
 

New ZipMe object ZipMe.java78 行で定義されています。

00079 { 00080 }


メソッド

void org.objectweb.cjdbc.common.util.ZipMe.create String  zipname,
String  rootdir,
String  putMeThere
throws Exception
 

Same as above but the place where to put the zip file is explicit

引数:
zipname of the file to create
rootdir of the directory to archive
putMeThere please
例外:
Exception if fails
ZipMe.java125 行で定義されています。

参照先 org.objectweb.cjdbc.common.util.ZipMe.create().

00127 { 00128 create(putMeThere + File.separator + zipname, rootdir); 00129 }

void org.objectweb.cjdbc.common.util.ZipMe.create String  zipname,
String  rootdir
throws Exception
 

Create a zip file from directory

引数:
zipname of the file to create
rootdir of the directory to archive
例外:
Exception if fails
ZipMe.java89 行で定義されています。

参照先 org.objectweb.cjdbc.common.util.ZipMe.dirFunc(), org.objectweb.cjdbc.common.util.ZipMe.fos, org.objectweb.cjdbc.common.util.ZipMe.logger, org.objectweb.cjdbc.common.util.ZipMe.useCompression, org.objectweb.cjdbc.common.util.ZipMe.ZIP_EXT, org.objectweb.cjdbc.common.util.ZipMe.zipPath, と org.objectweb.cjdbc.common.util.ZipMe.zos.

参照元 org.objectweb.cjdbc.common.util.ZipMe.create().

00090 { 00091 if (zipname == null || rootdir == null) 00092 throw new Exception("Invalid arguments to create zip file"); 00093 this.rootDir = rootdir; 00094 try 00095 { 00096 zipPath = zipname + ZIP_EXT; 00097 fos = new FileOutputStream(zipPath); 00098 if (useCompression) 00099 zos = new ZipOutputStream(new DeflaterOutputStream(fos, new Deflater( 00100 Deflater.BEST_COMPRESSION))); 00101 else 00102 zos = new ZipOutputStream(fos); 00103 00104 dirFunc(rootdir); 00105 00106 zos.flush(); 00107 zos.close(); 00108 fos.close(); 00109 } 00110 catch (IOException e) 00111 { 00112 logger.error(e.getMessage()); 00113 throw e; 00114 } 00115 }

void org.objectweb.cjdbc.common.util.ZipMe.dirFunc String  dirName  )  throws IOException [private]
 

ZipMe.java220 行で定義されています。

参照元 org.objectweb.cjdbc.common.util.ZipMe.create().

00221 { 00222 File dirObj = new File(dirName); 00223 if (dirObj.exists() == true) 00224 { 00225 if (dirObj.isDirectory() == true) 00226 { 00227 00228 File[] fileList = dirObj.listFiles(); 00229 00230 for (int i = 0; i < fileList.length; i++) 00231 { 00232 if (fileList[i].isDirectory()) 00233 { 00234 dirFunc(fileList[i].getPath()); 00235 } 00236 else if (fileList[i].isFile()) 00237 { 00238 00239 zipFunc(fileList[i].getPath()); 00240 } 00241 } 00242 } 00243 else 00244 { 00245 if (logger.isDebugEnabled()) 00246 logger.debug(Translate.get("zip.not.directory", dirName)); 00247 } 00248 } 00249 else 00250 { 00251 if (logger.isDebugEnabled()) 00252 logger.debug(Translate.get("zip.directory.not.found", dirName)); 00253 } 00254 }

void org.objectweb.cjdbc.common.util.ZipMe.expand String  zipname,
String  targetdir
throws Exception
 

Expand the content of the zip file

引数:
zipname of the file to expand
targetdir where to place unzipped files
例外:
Exception if fails
ZipMe.java166 行で定義されています。

参照先 org.objectweb.cjdbc.common.util.ZipMe.BUFFER, org.objectweb.cjdbc.common.util.ZipMe.dest, org.objectweb.cjdbc.common.util.ZipMe.fis, org.objectweb.cjdbc.common.util.ZipMe.fos, org.objectweb.cjdbc.common.util.ZipMe.logger, org.objectweb.cjdbc.common.util.ZipMe.useCompression, org.objectweb.cjdbc.common.util.ZipMe.ZIP_EXT, org.objectweb.cjdbc.common.util.ZipMe.zipPath, と org.objectweb.cjdbc.common.util.ZipMe.zis.

00167 { 00168 File ftargetDir = new File(targetdir); 00169 if (!ftargetDir.exists()) 00170 ftargetDir.mkdirs(); 00171 if (!ftargetDir.exists()) 00172 throw new Exception(Translate.get("zip.invalid.target.directory")); 00173 00174 zipPath = zipname + ZIP_EXT; 00175 File fzipname = new File(zipPath); 00176 if (!fzipname.exists()) 00177 throw new Exception(Translate.get("zip.invalid.source.file")); 00178 00179 try 00180 { 00181 fis = new FileInputStream(fzipname); 00182 if (useCompression) 00183 zis = new ZipInputStream(new InflaterInputStream(fis)); 00184 else 00185 zis = new ZipInputStream(new BufferedInputStream(fis)); 00186 00187 ZipEntry entry; 00188 00189 byte data[] = new byte[BUFFER]; 00190 while ((entry = zis.getNextEntry()) != null) 00191 { 00192 int count; 00193 String target = targetdir + File.separator + entry.getName(); 00194 File fget = new File(target); 00195 fget.mkdirs(); // create needed new directories 00196 fget.delete(); // delete directory but not parents 00197 if (logger.isDebugEnabled()) 00198 logger.debug(Translate.get("zip.extracting", new String[]{ 00199 String.valueOf(entry), fget.getAbsolutePath()})); 00200 fos = new FileOutputStream(target); 00201 00202 dest = new BufferedOutputStream(fos, BUFFER); 00203 while ((count = zis.read(data, 0, BUFFER)) != -1) 00204 { 00205 dest.write(data, 0, count); 00206 } 00207 dest.flush(); 00208 dest.close(); 00209 } 00210 zis.close(); 00211 } 00212 catch (Exception e) 00213 { 00214 e.printStackTrace(); 00215 logger.error(e.getMessage()); 00216 throw e; 00217 } 00218 }

void org.objectweb.cjdbc.common.util.ZipMe.expand String  zipname,
String  targetdir,
String  getMeThere
throws Exception
 

Same as below but the place where to get the zip file is explicit

引数:
zipname of the file to expand
targetdir where to place unzipped files
getMeThere please
例外:
Exception if fails
ZipMe.java139 行で定義されています。
00141 { 00142 expand(getMeThere + File.separator + zipname, targetdir); 00143 }

boolean org.objectweb.cjdbc.common.util.ZipMe.getUseCompression  ) 
 

戻り値:
Returns the useCompression.
ZipMe.java305 行で定義されています。
00306 { 00307 return useCompression; 00308 }

long org.objectweb.cjdbc.common.util.ZipMe.getZipSize  ) 
 

Get the size of the zip file

戻り値:
size in bytes
ZipMe.java150 行で定義されています。

参照先 org.objectweb.cjdbc.common.util.ZipMe.zipPath.

00151 { 00152 File f = new File(zipPath); 00153 if (f.exists()) 00154 return f.length(); 00155 else 00156 return -1; 00157 }

void org.objectweb.cjdbc.common.util.ZipMe.setUseCompression boolean  useCompression  ) 
 

引数:
useCompression The useCompression to set.
ZipMe.java313 行で定義されています。
00314 { 00315 this.useCompression = useCompression; 00316 }

void org.objectweb.cjdbc.common.util.ZipMe.zipFunc String  filePath  )  throws IOException [private]
 

ZipMe.java256 行で定義されています。

00257 { 00258 File ffilePath = new File(filePath); 00259 String path = ""; 00260 switch (STORE_POLICY) 00261 { 00262 case STORE_FULL_PATH_IN_ZIP : 00263 path = ffilePath.getAbsolutePath(); 00264 break; 00265 case STORE_NAME_ONLY_IN_ZIP : 00266 ffilePath.getName(); 00267 break; 00268 case STORE_RELATIVE_PATH_IN_ZIP : 00269 File f = new File(""); 00270 String pathToHere = f.getAbsolutePath(); 00271 path = ffilePath.getAbsolutePath(); 00272 path = path.substring(path.indexOf(pathToHere + File.separator) 00273 + pathToHere.length()); 00274 break; 00275 case STORE_PATH_FROM_ZIP_ROOT : 00276 path = ffilePath.getAbsolutePath(); 00277 String tmpDir = File.separator + rootDir + File.separator; 00278 path = rootDir + File.separator 00279 + path.substring(path.indexOf(tmpDir) + tmpDir.length()); 00280 logger.debug(path); 00281 break; 00282 default : 00283 break; 00284 } 00285 00286 FileInputStream fis = new FileInputStream(filePath); 00287 BufferedInputStream bis = new BufferedInputStream(fis); 00288 00289 ZipEntry fileEntry = new ZipEntry(path); 00290 zos.putNextEntry(fileEntry); 00291 00292 byte[] data = new byte[1024]; 00293 int byteCount; 00294 while ((byteCount = bis.read(data, 0, 1024)) > -1) 00295 { 00296 zos.write(data, 0, byteCount); 00297 } 00298 00299 logger.debug(filePath); 00300 }


変数

final int org.objectweb.cjdbc.common.util.ZipMe.BUFFER = 2048 [static, package]
 

ZipMe.java60 行で定義されています。

参照元 org.objectweb.cjdbc.common.util.ZipMe.expand().

BufferedOutputStream org.objectweb.cjdbc.common.util.ZipMe.dest [private]
 

ZipMe.java55 行で定義されています。

参照元 org.objectweb.cjdbc.common.util.ZipMe.expand().

FileInputStream org.objectweb.cjdbc.common.util.ZipMe.fis = null [private]
 

ZipMe.java54 行で定義されています。

参照元 org.objectweb.cjdbc.common.util.ZipMe.expand().

FileOutputStream org.objectweb.cjdbc.common.util.ZipMe.fos = null [private]
 

ZipMe.java51 行で定義されています。

参照元 org.objectweb.cjdbc.common.util.ZipMe.create(), と org.objectweb.cjdbc.common.util.ZipMe.expand().

Trace org.objectweb.cjdbc.common.util.ZipMe.logger [static, package]
 

初期値:

Trace .getLogger(ZipMe.class .getName())
ZipMe.java71 行で定義されています。

参照元 org.objectweb.cjdbc.common.util.ZipMe.create(), と org.objectweb.cjdbc.common.util.ZipMe.expand().

String org.objectweb.cjdbc.common.util.ZipMe.rootDir [private]
 

ZipMe.java56 行で定義されています。

final int org.objectweb.cjdbc.common.util.ZipMe.STORE_FULL_PATH_IN_ZIP = 0 [static, package]
 

ZipMe.java65 行で定義されています。

final int org.objectweb.cjdbc.common.util.ZipMe.STORE_NAME_ONLY_IN_ZIP = 1 [static, package]
 

ZipMe.java66 行で定義されています。

final int org.objectweb.cjdbc.common.util.ZipMe.STORE_PATH_FROM_ZIP_ROOT = 3 [static, package]
 

ZipMe.java68 行で定義されています。

final int org.objectweb.cjdbc.common.util.ZipMe.STORE_POLICY = STORE_PATH_FROM_ZIP_ROOT [static, package]
 

ZipMe.java69 行で定義されています。

final int org.objectweb.cjdbc.common.util.ZipMe.STORE_RELATIVE_PATH_IN_ZIP = 2 [static, package]
 

ZipMe.java67 行で定義されています。

boolean org.objectweb.cjdbc.common.util.ZipMe.useCompression = true [private]
 

ZipMe.java58 行で定義されています。

参照元 org.objectweb.cjdbc.common.util.ZipMe.create(), と org.objectweb.cjdbc.common.util.ZipMe.expand().

final String org.objectweb.cjdbc.common.util.ZipMe.ZIP_EXT = ".cjdbc" [static]
 

CJDBC extension for zipped file names ZipMe.java62 行で定義されています。

参照元 org.objectweb.cjdbc.common.util.ZipMe.create(), と org.objectweb.cjdbc.common.util.ZipMe.expand().

String org.objectweb.cjdbc.common.util.ZipMe.zipPath [private]
 

ZipMe.java57 行で定義されています。

参照元 org.objectweb.cjdbc.common.util.ZipMe.create(), org.objectweb.cjdbc.common.util.ZipMe.expand(), と org.objectweb.cjdbc.common.util.ZipMe.getZipSize().

ZipInputStream org.objectweb.cjdbc.common.util.ZipMe.zis = null [private]
 

ZipMe.java53 行で定義されています。

参照元 org.objectweb.cjdbc.common.util.ZipMe.expand().

ZipOutputStream org.objectweb.cjdbc.common.util.ZipMe.zos = null [private]
 

ZipMe.java52 行で定義されています。

参照元 org.objectweb.cjdbc.common.util.ZipMe.create().


このクラスの説明は次のファイルから生成されました:
CJDBCversion1.0.4に対してTue Oct 12 15:16:19 2004に生成されました。 doxygen 1.3.8