1 19 20 package org.netbeans.modules.java; 21 22 import java.util.*; 23 24 import org.openide.util.MapFormat; 25 26 47 48 public class JMapFormat extends MapFormat { 49 50 private String cdel = ","; 52 static final long serialVersionUID =5503640004816201285L; 53 public JMapFormat(Map map) { 54 super(map); 55 } 56 57 protected Object processKey(String key) { 58 StringTokenizer st = new StringTokenizer(key, cdel, true); 60 String data[] = new String [4]; 61 String temp; 62 63 for(int i = 0; (i < 4) && st.hasMoreTokens(); ) { 64 temp = st.nextToken(); 65 if (temp.equals("$")) i++; else data[i] = temp; 67 } 68 69 Object obj = super.processKey(data[0]); 70 if (obj instanceof String ) { 71 if (data[1] != null) { 72 String name = (String )obj; 73 if (name.endsWith(data[1])) { 74 if (data[2] == null) data[2] = ""; return name.substring(0, name.length() - data[1].length()) + data[2]; 76 } else { 77 if (data[3] != null) return data[3]; 78 else return obj; 79 } 80 } 81 } 82 return obj; 83 } 84 85 public String getCondDelimiter() { 86 return cdel; 87 } 88 89 public void setCondDelimiter(String cdel) { 90 this.cdel = cdel; 91 } 92 93 } 94 | Popular Tags |