1 package jester; 2 3 import java.util.ArrayList ; 4 import java.util.List ; 5 6 public class IgnoreList { 7 private static final String specialEndOfLineMarker = "\\n"; 8 private String contents; 9 10 public IgnoreList(String ignoreFileContents) { 11 contents = ignoreFileContents; 12 } 13 14 public List ignorePairs() throws ConfigurationException { 15 List result = new ArrayList (); 16 String [] lines = contents.split("\n"); 17 for (int i = 0; i < lines.length; i++) { 18 String line = lines[i]; 19 if (line.length()==0){ 20 continue; 21 } 22 char delimiter = line.charAt(0); 23 String [] parts = line.split(""+delimiter); 24 if (parts.length != 3){ 25 throw new ConfigurationException("could not parse ignore list line "+line); 26 } 27 String start = parts[1]; 28 String end = parts[2]; 29 if(end.equals(specialEndOfLineMarker)){ 30 end = "\n"; 31 } 32 result.add(new IgnorePair(start, end)); 33 } 34 return result; 35 } 36 37 public String toString() { 38 try{ 39 return "IgnoreList ["+ignorePairs()+"]"; 40 }catch(ConfigurationException ex){ 41 return "Malformed IgnoreList"; 42 } 43 } 44 } 45 | Popular Tags |