source: fedd/abac-src/rtml/src/edu/stanford/rt/datatype/IntervalValueSet.java @ 8780cbec

axis_examplecompt_changesinfo-opsversion-1.30version-2.00version-3.01version-3.02
Last change on this file since 8780cbec was 8780cbec, checked in by Jay Jacobs <Jay.Jacobs@…>, 15 years ago

ABAC sources from Cobham

  • Property mode set to 100644
File size: 2.4 KB
Line 
1package edu.stanford.rt.datatype;
2
3/**
4 * @author Ninghui Li, Sandra Qiu<br>
5 *
6 * Implementation of <code>Inteval</code> element.
7 *
8 * An IntervalValueSet represents an Interval value.  It has a min value and
9 * a max value.  When min is null, it means that the lower side is
10 * unbounded.  When max is null, the upper side is unbounded.  When min
11 * is not null, includeMin can be true.  Similarly, when max is not null,
12 * includeMax can be true.
13 */
14public class IntervalValueSet extends ValueSet
15{
16        private DataValue min;
17        private DataValue max;
18        private boolean includeMin;
19        private boolean includeMax;
20
21    /**
22     * Constructor of IntervalValueSet.
23     */
24        public IntervalValueSet(
25                OrderedType type,
26                DataValue min,
27                DataValue max)
28        {
29        super(type);
30
31        if(! (type instanceof OrderedType))
32            throw new IllegalArgumentException("Wrong data type");           
33                if (min != null && !type.isValidValue(min))
34                        throw new IllegalArgumentException("Illegal min value");
35                if (max != null && !type.isValidValue(max))
36                        throw new IllegalArgumentException("Illegal max value");
37
38                this.min = min;
39                this.max = max;
40                if (this.min != null)
41                        this.includeMin = true;
42                if (this.max != null)
43                        this.includeMax = true;
44        }
45
46        /**
47         * Method getMin.
48         * @return DataValue
49         */
50        public DataValue getMin()
51        {
52                return min;
53        }
54
55        /**
56         * Method getMax.
57         * @return DataValue
58         */
59        public DataValue getMax()
60        {
61                return max;
62        }
63
64        /**
65         * Method isMinIncluded.
66         * @return boolean
67         */
68        public boolean isMinIncluded()
69        {
70                return includeMin;
71        }
72
73        /**
74         * Method isMaxIncluded.
75         * @return boolean
76         */
77        public boolean isMaxIncluded()
78        {
79                return includeMax;
80        }
81
82        /* (non-Javadoc)
83         * @see edu.stanford.rt.datatype.ValueSet#toString(String)
84         */
85        public String toString(String indent)
86        {
87                String thisIndent = indent + "  ";
88                StringBuffer sb = new StringBuffer();
89                sb.append(thisIndent).append("IntervalValueSet: \n");
90                sb.append(thisIndent + "  ").append(
91                        getType().toString()).append(
92                        "\n");
93                sb.append(thisIndent + "  ");
94                if (includeMin)
95                        sb.append(" [");
96                else
97                        sb.append(" (");
98                sb.append(min.toString());
99                sb.append(", ");
100                sb.append(max.toString());
101
102                if (includeMax)
103                        sb.append("]");
104                else
105                        sb.append(") ");
106                sb.append("\n");
107
108                return sb.toString();
109        }
110
111}
Note: See TracBrowser for help on using the repository browser.