Clover Coverage Report
Coverage timestamp: Sun Mar 23 2008 08:24:39 GMT
14   101   5   3.5
8   32   0.57   4
4     2  
1    
 
 
  AdjustedPeriodCollection       Line # 46 14 5 61.5% 0.61538464
 
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;
33   
34    /**
35    * This is a collection of periods that are applied together. This is an
36    * advanced implementation of intersection. Normally the
37    * IntersectionValidityPeriod produces the validity period that is just a set of
38    * the latest notBefore and the earliest notAfter, which is good for
39    * constraining. However, Age and Min cannot be implemented this way, because
40    * if the ValidityPeriod exceeds one of the margins, it is fully invalid, and
41    * not just constrained.
42    *
43    * @author A.Otenko
44    */
45   
 
46    public class AdjustedPeriodCollection extends AdjustedValidityPeriod {
47   
48    private ValidityPeriod vp1;
49    private ValidityPeriod vp2;
50   
 
51  0 toggle protected AdjustedPeriodCollection(){
52  0 super();
53    }
54   
55    /**
56    * This constructor builds a AdjustedPeriodCollection of two ValidityPeriods.
57    * More ValidityPeriods can be added to the collection by chaining multiple
58    * AdjustedPeriodCollection as a binary tree. Both ValidityPeriods are treated
59    * equally.
60    *
61    * @param vp1 - one ValidityPeriod
62    * @param vp2 - another ValidityPeriod
63    */
 
64  5 toggle public AdjustedPeriodCollection(ValidityPeriod vp1, ValidityPeriod vp2) {
65  5 super();
66   
67  5 this.vp1=vp1;
68  5 this.vp2=vp2;
69    }
70   
71    /**
72    * This method returns an adjusted ValidityPeriod, where the collection of
73    * ValidityPeriods provided at construction time is adjusted against the
74    * given ValidityPeriod.
75    *
76    * @param vp - the ValidityPeriod to adjust against
77    */
 
78  244 toggle public ValidityPeriod adjust(ValidityPeriod vp){
79  244 if (vp1!=null){
80  244 if (vp1 instanceof AdjustedValidityPeriod){
81  0 vp = ((AdjustedValidityPeriod)vp1).adjust(vp);
82    }else{
83  244 vp = new IntersectionValidityPeriod(vp1, vp);
84    }
85    }
86   
87  244 if (vp2!=null){
88  244 if (vp2 instanceof AdjustedValidityPeriod){
89  244 vp = ((AdjustedValidityPeriod)vp2).adjust(vp);
90    }else{
91  0 vp = new IntersectionValidityPeriod(vp2, vp);
92    }
93    }
94   
95  244 return vp;
96    }
97   
 
98  0 toggle public String toString(){
99  0 return "{rule "+vp1+" && "+vp2+"}";
100    }
101    }