Clover Coverage Report
Coverage timestamp: Sun Mar 23 2008 08:24:39 GMT
9   108   3   2.25
2   21   0.67   4
4     1.5  
1    
 
 
  OperatorNode       Line # 53 9 3 20% 0.2
 
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 Operator 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 no or any number of Terms of any type, and
40    * returns a
41    * value of type determined by the matching Interpreter.
42    * There must be an interpreter for
43    * the required set of Terms, and it implements the semantics of the evaluation.
44    *
45    * <p>It is possible to register the interpreters for specific
46    * combinations of Terms. Use registerOperatorInterpreter method to do that.
47    * There is no default Interpreter.
48    *
49    * @see #registerOperatorInterpreter
50    *
51    * @author A.Otenko
52    */
 
53    public class OperatorNode extends OperationNode {
54    public final static String OPERATOR_NODE = "Operator";
55   
56    /**
57    * This method should be called to register the node with the XML Parser
58    */
 
59  21 toggle public static void register(){
60  21 try{
61  21 issrg.pba.rbac.xmlpolicy.XMLPolicyParser.registerXMLNode(OPERATOR_NODE, OperatorNode.class);
62    }catch (NoSuchMethodException nsme){
63  0 nsme.printStackTrace();
64    }
65    }
66   
67    /**
68    * This method maintains a register of interpreters for specific combinations
69    * of Terms for the specified operator. If no special interpreters are
70    * registered, the evaluation error
71    * occurs. The semantics of the interpreters ensure the semantics of
72    * evaluation of the operator.
73    *
74    * @param name - the operator name
75    * @param i - the Interpreter instance that can evaluate the expression
76    * for some combination of Terms
77    *
78    * @see Interpreter#evaluate
79    */
 
80  0 toggle public static void registerOperatorInterpreter(String name, Interpreter i){
81  0 OperationNode.registerInterpreterForNode(OPERATOR_NODE+" "+name, i);
82    }
83   
 
84  0 toggle protected OperatorNode(){};
85   
86    /**
87    * This constructor builds a OperatorNode given the XMLPolicyParser and the
88    * set of
89    * attributes of this XML element. It expects that there are no or many
90    * child nodes. It expects there is a
91    * issrg.pba.rbac.xmlpolicy.XMLTags.NAME_ATTRIBUTE ("Name") attribute in this
92    * XML element.
93    *
94    * @param p - the XMLPolicyParser that builds this LtNode
95    * @param attrs - the attributes of this XML element
96    *
97    * @throws issrg.pba.rbac.PolicyParsingException if there is no
98    * issrg.pba.rbac.xmlpolicy.XMLTags.NAME_ATTRIBUTE in this XML element
99    */
 
100  0 toggle public OperatorNode(issrg.pba.rbac.xmlpolicy.XMLPolicyParser p, org.xml.sax.Attributes attrs) throws issrg.pba.rbac.PolicyParsingException {
101  0 super(OPERATOR_NODE, attrs, -1, -1);
102   
103  0 String opname=(String)getAttributes().get(issrg.pba.rbac.xmlpolicy.XMLTags.NAME_ATTRIBUTE);
104  0 if (opname==null) throw new issrg.pba.rbac.PolicyParsingException(issrg.pba.rbac.xmlpolicy.XMLTags.NAME_ATTRIBUTE+" attribute was expected for "+OPERATOR_NODE);
105  0 name = OPERATOR_NODE+" "+opname;
106    }
107   
108    }