1 | package edu.stanford.rt.datatype; |
---|
2 | |
---|
3 | /** |
---|
4 | * @author Ninghui Li, Sandra Qiu <br> |
---|
5 | * |
---|
6 | A TreeValueSet object contains a TreeValue and can be |
---|
7 | used to express the concept such as including all the |
---|
8 | sub-directories of the current directory by specifying |
---|
9 | whether the current value is included, the children of |
---|
10 | the current value or the descendant of the current value |
---|
11 | are included. |
---|
12 | */ |
---|
13 | public class TreeValueSet extends ValueSet |
---|
14 | { |
---|
15 | /** tree value */ |
---|
16 | private TreeValue value; |
---|
17 | |
---|
18 | /** is current tree value included?*/ |
---|
19 | private boolean currentIncluded; |
---|
20 | /** is the children included?*/ |
---|
21 | private boolean childrenIncluded; |
---|
22 | /** is the descendant incuded? If it is true, then childrenIncluded is also true.*/ |
---|
23 | private boolean descendantIncluded; |
---|
24 | |
---|
25 | /** |
---|
26 | * Constructor of TreeValueSet |
---|
27 | */ |
---|
28 | public TreeValueSet( |
---|
29 | TreeType type, |
---|
30 | TreeValue value, |
---|
31 | boolean currentIncluded, |
---|
32 | boolean childrenIncluded, |
---|
33 | boolean descendantIncluded) |
---|
34 | { |
---|
35 | super(type); |
---|
36 | |
---|
37 | this.value = value; |
---|
38 | this.currentIncluded = currentIncluded; |
---|
39 | this.childrenIncluded = childrenIncluded; |
---|
40 | if (descendantIncluded && !childrenIncluded) |
---|
41 | throw new IllegalArgumentException("descendantIncluded implicits childrenIncluded."); |
---|
42 | this.descendantIncluded = descendantIncluded; |
---|
43 | } |
---|
44 | |
---|
45 | /* (non-Javadoc) |
---|
46 | * @see edu.stanford.rt.datatype.ValueSet#toString(String) |
---|
47 | */ |
---|
48 | public String toString(String indent) |
---|
49 | { |
---|
50 | String thisIndent = indent + " "; |
---|
51 | |
---|
52 | StringBuffer sb = new StringBuffer(); |
---|
53 | sb.append(thisIndent).append("TreeValueSet: \n"); |
---|
54 | sb.append(thisIndent + " ").append( |
---|
55 | getType().toString()).append( |
---|
56 | "\n"); |
---|
57 | sb.append(thisIndent + " ").append(value.toString()).append( |
---|
58 | "\n"); |
---|
59 | sb |
---|
60 | .append(thisIndent) |
---|
61 | .append("currentIncluded=") |
---|
62 | .append(currentIncluded) |
---|
63 | .append(" ") |
---|
64 | .append("childrenIncluded=") |
---|
65 | .append(childrenIncluded) |
---|
66 | .append(" ") |
---|
67 | .append("descendantIncluded=") |
---|
68 | .append(descendantIncluded) |
---|
69 | .append("\n"); |
---|
70 | |
---|
71 | return sb.toString(); |
---|
72 | } |
---|
73 | |
---|
74 | } |
---|