View Javadoc

1   package zeus.concepts;
2   
3   public class Restriction {
4   
5     private String taskName;
6     private String factName;
7     private String attributeName;
8     private String restriction;
9   
10    public Restriction(String task, String fact,
11  		     String attribute, String value) {
12  
13      setTaskName(task);
14      setFactName(fact);
15      setAttributeName(attribute);
16      setRestriction(value);
17    }
18  
19    public void setTaskName(String task) {
20      this.taskName = task;
21    }
22  
23    public String getTaskName() {
24      return taskName;
25    }
26  
27    public void setFactName(String fact) {
28      this.factName = fact;
29    }
30  
31    public String getFactName() {
32      return factName;
33    }
34  
35    public void setAttributeName(String attribute) {
36      this.attributeName = attribute;
37    }
38  
39    public String getAttributeName() {
40      return attributeName;
41    }
42  
43    public void setRestriction(String value) {
44      if(value.trim().startsWith("\"") &&
45         value.trim().endsWith("\"")) {
46  
47        value = value.trim();
48        value = value.substring(1, value.length() - 1);
49      }
50      this.restriction = value;
51    }
52  
53    public String getRestriction() {
54      return restriction;
55    }
56  
57    public boolean sameTarget(Restriction item) {
58      if(item.getTaskName().equals(taskName) &&
59         item.getFactName().equals(factName) &&
60         item.getAttributeName().equals(attributeName)) {
61        return true;
62      }
63      else {
64        return false;
65      }
66    }
67  
68    public String toString() {
69      return pprint();
70    }
71  
72    public String pprint() {
73      return pprint(0);
74    }
75  
76    public String pprint(int spaces) {
77  
78      String tabs = zeus.util.Misc.spaces(spaces);
79      String eol  = "\n" + tabs + " ";
80      
81      String s = new String("(");
82      s += ":task " + taskName + eol;
83      s += ":fact " + factName + eol;
84      s += ":attribute " + attributeName + eol;
85      s += ":value \"" + restriction + "\"" + eol;
86      return s.trim() + "\n" + tabs + ")";
87  
88    }
89  }