LtNode | Line # 56 | 5 | 2 | 77.8% |
0.7777778
|
No Tests | |||
1 | /* | |
2 | * Copyright (c) 2000-2005, University of Salford | |
3 | * All rights reserved. | |
4 | * | |
5 | * Redistribution and use in source and binary forms, with or without | |
6 | * modification, are permitted provided that the following conditions are met: | |
7 | * | |
8 | * Redistributions of source code must retain the above copyright notice, this | |
9 | * list of conditions and the following disclaimer. | |
10 | * | |
11 | * Redistributions in binary form must reproduce the above copyright notice, | |
12 | * this list of conditions and the following disclaimer in the documentation | |
13 | * and/or other materials provided with the distribution. | |
14 | * | |
15 | * Neither the name of the University of Salford nor the names of its | |
16 | * contributors may be used to endorse or promote products derived from this | |
17 | * software without specific prior written permission. | |
18 | * | |
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
20 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | |
23 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | |
31 | ||
32 | package issrg.pba.rbac.xmlpolicy.ifstatement; | |
33 | ||
34 | /** | |
35 | * This is the class for LT node of the IF-statement. Its functionality is | |
36 | * very much determined by OperationNode, which is | |
37 | * configured to deliver the following semantics: | |
38 | * | |
39 | * <p>This operation expects two and only two Terms of any type, and | |
40 | * returns a | |
41 | * value of type Types.BOOLEAN_TYPE. | |
42 | * The evaluation result is "true", if and only if there is an interpreter for | |
43 | * the required set of Terms, and it evaluates that the first Term is strictly | |
44 | * less than the second Term. | |
45 | * | |
46 | * <p>It is possible to register the interpreters for specific | |
47 | * combinations of Terms. Use registerInterpreter method to do that. There is no | |
48 | * default | |
49 | * Interpreter. | |
50 | * | |
51 | * @see #registerInterpreter | |
52 | * | |
53 | * @author A.Otenko | |
54 | */ | |
55 | ||
56 | public class LtNode extends OperationNode { | |
57 | public static final String LT_NODE = "LT"; | |
58 | ||
59 | /** | |
60 | * Call this method to register the node with the XMLPolicyParser. | |
61 | */ | |
62 | 21 | public static void register(){ |
63 | 21 | try{ |
64 | 21 | issrg.pba.rbac.xmlpolicy.XMLPolicyParser.registerXMLNode(LT_NODE, LtNode.class); |
65 | }catch (NoSuchMethodException nsme){ | |
66 | 0 | nsme.printStackTrace(); |
67 | } | |
68 | } | |
69 | ||
70 | /** | |
71 | * This method maintains a register of interpreters for specific combinations | |
72 | * of Terms. If no special interpreters are registered, the evaluation error | |
73 | * occurs. The semantics of the interpreters should make sure that the first | |
74 | * Term is strictly less than the second Term in the array passed to the | |
75 | * evaluate method of that Interpreter. | |
76 | * | |
77 | * @param i - the Interpreter instance that can evaluate inequality expression | |
78 | * for some combination of Terms | |
79 | * | |
80 | * @see Interpreter#evaluate | |
81 | */ | |
82 | 63 | public static void registerInterpreter(Interpreter i){ |
83 | 63 | OperationNode.registerInterpreterForNode(LT_NODE, i); |
84 | } | |
85 | ||
86 | 0 | protected LtNode() { |
87 | } | |
88 | ||
89 | /** | |
90 | * This constructor builds a LtNode given the XMLPolicyParser and the set of | |
91 | * attributes of this XML element. It expects that there are two and only two | |
92 | * child nodes. | |
93 | * | |
94 | * @param p - the XMLPolicyParser that builds this LtNode | |
95 | * @param attr - the attributes of this XML element | |
96 | */ | |
97 | 8 | public LtNode(issrg.pba.rbac.xmlpolicy.XMLPolicyParser p, org.xml.sax.Attributes attrs){ |
98 | 8 | super(LT_NODE, attrs, 2, 2); |
99 | } | |
100 | } |
|