01: /*
02: * JFolder, Copyright 2001-2006 Gary Steinmetz
03: *
04: * Distributable under LGPL license.
05: * See terms of license at gnu.org.
06: */
07:
08: package org.jfolder.common.files.memory;
09:
10: //base classes
11: import java.io.IOException;
12: import java.util.ArrayList;
13: import java.util.Collections;
14: import java.util.HashMap;
15: import java.util.HashSet;
16: import java.util.Iterator;
17: import java.util.zip.ZipEntry;
18: import java.util.zip.ZipInputStream;
19: import java.util.zip.ZipOutputStream;
20:
21: //project specific classes
22: import org.jfolder.common.UnexpectedSystemException;
23: import org.jfolder.common.files.BaseVirtualFileSystemHolder;
24: import org.jfolder.common.files.VirtualFileSystemDirectory;
25: import org.jfolder.common.files.VirtualFileSystemFile;
26: import org.jfolder.common.files.VirtualFileSystemHolder;
27: import org.jfolder.common.utils.misc.MiscHelper;
28:
29: //other classes
30:
31: class MemoryFileSystemHolder extends BaseVirtualFileSystemHolder
32: implements VirtualFileSystemHolder {
33:
34: private HashMap localDirectories = null;
35: private HashMap localFiles = null;
36:
37: protected MemoryFileSystemHolder() {
38: this .localDirectories = new HashMap();
39: this .localFiles = new HashMap();
40: }
41:
42: //
43: protected HashMap getLocalFilesAsHashMap() {
44: return (HashMap) this .localFiles.clone();
45: }
46:
47: protected HashMap getLocalDirectoriesAsHashMap() {
48: return (HashMap) this .localDirectories.clone();
49: }
50:
51: //
52: protected VirtualFileSystemFile createLocalFile(String inName,
53: byte inContent[]) {
54:
55: //
56: VirtualFileSystemFile outValue = new MemoryFileSystemFile(
57: inName, inContent);
58:
59: this .localFiles.put(inName.toUpperCase(), outValue);
60:
61: return outValue;
62: }
63:
64: protected VirtualFileSystemFile updateLocalFile(String inName,
65: byte inContent[]) {
66:
67: //
68: return createLocalFile(inName, inContent);
69: }
70:
71: protected void deleteLocalFile(String inName) {
72: this .localFiles.remove(inName.toUpperCase());
73: }
74:
75: //
76: protected VirtualFileSystemDirectory createLocalDirectory(
77: String inName) {
78:
79: VirtualFileSystemDirectory outValue = new MemoryFileSystemDirectory(
80: inName);
81:
82: this .localDirectories.put(inName.toUpperCase(), outValue);
83:
84: return outValue;
85: }
86:
87: protected void deleteLocalDirectory(String inName) {
88: this .localDirectories.remove(inName.toUpperCase());
89: }
90:
91: //
92: protected boolean isRemovePropogateActive() {
93: return false;
94: }
95: }
|