1 2 package net.firstpartners.nounit.reader.bytecode; 3 4 27 28 import java.util.HashMap ; 29 import java.util.Iterator ; 30 31 import net.firstpartners.nounit.reader.ISnippetFactory; 32 import net.firstpartners.nounit.snippet.Snippets; 33 import net.firstpartners.nounit.utility.NoUnitException; 34 import net.firstpartners.nounit.utility.TextUtil; 35 36 37 38 41 abstract public class AbstractByteCodeSnippetFactory implements ISnippetFactory{ 42 43 44 48 abstract public Snippets getSnippets() 49 throws NoUnitException; 50 51 56 protected HashMap cleanValues(HashMap dirtyValues){ 57 58 String tmpKey; 60 String tmpValue; 61 Iterator keys = dirtyValues.keySet().iterator(); 62 HashMap cleanValues = new HashMap (); 63 64 while (keys.hasNext()) { 65 66 tmpKey=(String )keys.next(); 68 tmpValue=(String )dirtyValues.get(tmpKey); 69 70 tmpValue = cleanValues(tmpValue); 72 73 cleanValues.put(tmpKey,tmpValue); 75 } 76 77 return cleanValues; 78 79 } 80 81 86 public String cleanValues(String valueToClean){ 87 88 if (valueToClean==null) return""; 90 91 92 valueToClean=TextUtil.removeAll(valueToClean,"."); 94 95 valueToClean=TextUtil.replaceAll(valueToClean,"/","."); 97 98 valueToClean=TextUtil.removeAll(valueToClean,"("); 100 101 valueToClean=TextUtil.removeAll(valueToClean,")"); 103 104 if (valueToClean.startsWith("L")) { 106 107 valueToClean=valueToClean.substring(1,valueToClean.length()); 108 109 } 110 111 if (valueToClean.startsWith(".")) { 113 114 valueToClean=valueToClean.substring(1,valueToClean.length()); 115 116 } 117 118 return valueToClean; 119 } 120 121 126 protected String tidyNames(String inString) { 127 128 129 String returnString = TextUtil.removeAll(inString," "); 130 returnString=TextUtil.removeAll(inString,"<"); 131 returnString=TextUtil.removeAll(inString,">"); 132 133 if (returnString.startsWith(" ")) { 135 136 returnString=returnString.substring(1,returnString.length()); 137 138 } 139 140 if (returnString.startsWith(".")) { 142 143 returnString=returnString.substring(1,returnString.length()); 144 145 } 146 147 if (returnString.startsWith("<")) { 149 150 returnString=returnString.substring(1,returnString.length()); 151 152 } 153 154 returnString = TextUtil.replaceAll(returnString,"/","."); 156 157 158 return returnString; 159 160 } 161 } 162 | Popular Tags |