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