1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| package com.opensymphony.oscache.plugins.diskpersistence; |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
| |
19 |
| public class DiskPersistenceListener extends AbstractDiskPersistenceListener { |
20 |
| private static final String CHARS_TO_CONVERT = "./\\ :;\"\'_?"; |
21 |
| |
22 |
| |
23 |
| |
24 |
| |
25 |
| |
26 |
| |
27 |
| |
28 |
1005
| protected char[] getCacheFileName(String key) {
|
29 |
1005
| if ((key == null) || (key.length() == 0)) {
|
30 |
0
| throw new IllegalArgumentException("Invalid key '" + key + "' specified to getCacheFile.");
|
31 |
| } |
32 |
| |
33 |
1005
| char[] chars = key.toCharArray();
|
34 |
| |
35 |
1005
| StringBuffer sb = new StringBuffer(chars.length + 8);
|
36 |
| |
37 |
1005
| for (int i = 0; i < chars.length; i++) {
|
38 |
14349
| char c = chars[i];
|
39 |
14349
| int pos = CHARS_TO_CONVERT.indexOf(c);
|
40 |
| |
41 |
14349
| if (pos >= 0) {
|
42 |
1606
| sb.append('_');
|
43 |
1606
| sb.append(i);
|
44 |
| } else { |
45 |
12743
| sb.append(c);
|
46 |
| } |
47 |
| } |
48 |
| |
49 |
1005
| char[] fileChars = new char[sb.length()];
|
50 |
1005
| sb.getChars(0, fileChars.length, fileChars, 0);
|
51 |
1005
| return fileChars;
|
52 |
| } |
53 |
| } |