equal
deleted
inserted
replaced
34 |
34 |
35 |
35 |
36 /** Recoder tables **/ |
36 /** Recoder tables **/ |
37 |
37 |
38 class Recoder(list: List[(String, String)]) { |
38 class Recoder(list: List[(String, String)]) { |
39 var pattern: Pattern = null |
39 private var pattern: Pattern = null |
40 var table = new HashMap[String, String] |
40 private var table = new HashMap[String, String] |
41 |
41 |
42 def recode(text: String) = { |
42 def recode(text: String) = { |
43 val output = new StringBuffer(text.length) |
43 val output = new StringBuffer(text.length) |
44 val matcher = pattern.matcher(text) |
44 val matcher = pattern.matcher(text) |
45 while(matcher.find) matcher.appendReplacement(output, table(matcher.group)) |
45 while(matcher.find) matcher.appendReplacement(output, table(matcher.group)) |
67 class Interpretation { |
67 class Interpretation { |
68 |
68 |
69 class BadSymbol(val msg: String) extends Exception |
69 class BadSymbol(val msg: String) extends Exception |
70 |
70 |
71 private var symbols = new HashMap[String, HashMap[String, String]] |
71 private var symbols = new HashMap[String, HashMap[String, String]] |
72 var decoder: Recoder = null |
72 private var decoder: Recoder = null |
73 var encoder: Recoder = null |
73 private var encoder: Recoder = null |
74 |
74 |
75 def decode(text: String) = decoder.recode(text) |
75 def decode(text: String) = decoder.recode(text) |
76 def encode(text: String) = encoder.recode(text) |
76 def encode(text: String) = encoder.recode(text) |
77 |
77 |
78 |
78 |