KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > replacementproxy > ContentStash


1 /*
2  * SSL-Explorer
3  *
4  * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */

19             
20 package com.sslexplorer.replacementproxy;
21
22 import java.io.File JavaDoc;
23 import java.util.Iterator JavaDoc;
24 import java.util.Map JavaDoc;
25
26 import org.apache.commons.cache.CachedObjectInfo;
27 import org.apache.commons.cache.FileStash;
28
29 /**
30  * Extension to {@link org.apache.commons.cache.FileStash}that does some extra
31  * stuff in the {@link #clear()}method.
32  *
33  * @author Brett Smith
34  */

35
36 public class ContentStash extends FileStash {
37
38     public ContentStash() {
39         super();
40     }
41
42     public ContentStash(long arg0) {
43         super(arg0);
44     }
45
46     public ContentStash(long arg0, long arg1) {
47         super(arg0, arg1);
48     }
49
50     public ContentStash(long arg0, long arg1, File JavaDoc arg2, int arg3) {
51         super(arg0, arg1, arg2, arg3);
52     }
53
54     public ContentStash(long arg0, long arg1, File JavaDoc arg2, int arg3, boolean arg4) {
55         super(arg0, arg1, arg2, arg3, arg4);
56     }
57
58     public ContentStash(long arg0, long arg1, File JavaDoc[] arg2, boolean arg3) {
59         super(arg0, arg1, arg2, arg3);
60     }
61
62     public ContentStash(long arg0, long arg1, String JavaDoc arg2, int arg3) {
63         super(arg0, arg1, arg2, arg3);
64     }
65
66     public ContentStash(long arg0, long arg1, String JavaDoc arg2, int arg3, boolean arg4) {
67         super(arg0, arg1, arg2, arg3, arg4);
68     }
69
70     /*
71      * (non-Javadoc)
72      *
73      * @see org.apache.commons.cache.Stash#clear()
74      */

75     public synchronized void clear() {
76         Iterator JavaDoc it = _hash.entrySet().iterator();
77         while (it.hasNext()) {
78             try {
79                 Map.Entry JavaDoc en = (Map.Entry JavaDoc) it.next();
80                 CachedObjectInfo obj = (CachedObjectInfo) en.getValue();
81                 ((File JavaDoc) (obj.getKey())).delete();
82             } catch (Exception JavaDoc e) {
83                 // ignored
84
}
85         }
86         _hash.clear();
87         _curBytes = 0;
88     }
89
90 }
91
Popular Tags