1 package org.rpi.plugin.lcddisplay;
2
3 import java.util.ArrayList;
4 import java.util.regex.Matcher;
5 import java.util.regex.Pattern;
6
7 import org.apache.log4j.Logger;
8
9 public class RowDefinition {
10
11 private static Logger log = Logger.getLogger(RowDefinition.class);
12
13 private String text = "";
14 private boolean first_time = true;
15 private ArrayList<KeyDefinition> keys = new ArrayList<KeyDefinition>();
16 private ArrayList<KeyDefinition> system_keys = new ArrayList<KeyDefinition>();
17
18 public String getText() {
19 return text;
20 }
21
22 public void setText(String text) {
23 this.text = text;
24 if (first_time) {
25 grabKeys();
26 first_time = false;
27 }
28 }
29
30 private void grabKeys() {
31 log.debug("GrabKeys: " + text);
32
33 String p = "\\[([^]]+)\\]";
34 Pattern pattern = Pattern.compile(p);
35 Matcher matcher = pattern.matcher(text);
36 while (matcher.find()) {
37 String value = matcher.group();
38 KeyDefinition kd = new KeyDefinition();
39 kd.setName(value);
40
41 if (value.startsWith("[SYS")) {
42 log.debug("Adding System Key: " + value);
43 getSystemKeys().add(kd);
44 } else {
45 log.debug("Adding Key: " + value);
46 keys.add(kd);
47 }
48 }
49 }
50
51 public ArrayList<KeyDefinition> getKeys() {
52 return keys;
53 }
54
55 public ArrayList<KeyDefinition> getSystemKeys() {
56 return system_keys;
57 }
58 }