|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This report was generated with an evaluation server license. Purchase Clover or configure your license. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
RefererFilter | Line # 41 | 16 | 0% | 12 | 1 | 96,7% |
0.96666664
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
(16) | |||
Result | |||
0.6
|
net.sourceforge.pebble.domain.RefererFilterManagerTest.testAddDuplicateFilter
![]() |
1 PASS | |
0.6
|
net.sourceforge.pebble.domain.RefererFilterManagerTest.testAddDuplicateFilter
![]() |
1 PASS | |
0.53333336
|
net.sourceforge.pebble.domain.RefererFilterTest.testEquals
![]() |
1 PASS | |
0.53333336
|
net.sourceforge.pebble.domain.RefererFilterTest.testEquals
![]() |
1 PASS | |
0.4
|
net.sourceforge.pebble.domain.RefererFilterTest.testComparisonOfFilters
![]() |
1 PASS | |
0.4
|
net.sourceforge.pebble.domain.RefererFilterTest.testComparisonOfFilters
![]() |
1 PASS | |
0.36666667
|
net.sourceforge.pebble.domain.RefererFilterTest.testId
![]() |
1 PASS | |
0.36666667
|
net.sourceforge.pebble.domain.RefererFilterTest.testId
![]() |
1 PASS | |
0.36666667
|
net.sourceforge.pebble.domain.RefererFilterManagerTest.testAddFilter
![]() |
1 PASS | |
0.36666667
|
net.sourceforge.pebble.domain.RefererFilterManagerTest.testAddFilter
![]() |
1 PASS | |
0.3
|
net.sourceforge.pebble.domain.RefererFilterTest.testCreatingFilterWithNullExpression
![]() |
1 PASS | |
0.3
|
net.sourceforge.pebble.domain.RefererFilterTest.testCreatingFilterWithNullExpression
![]() |
1 PASS | |
0.13333334
|
net.sourceforge.pebble.domain.RefererFilterTest.testConstruction
![]() |
1 PASS | |
0.13333334
|
net.sourceforge.pebble.domain.RefererFilterTest.testConstruction
![]() |
1 PASS | |
0.06666667
|
net.sourceforge.pebble.domain.RefererFilterTest.testHashCode
![]() |
1 PASS | |
0.06666667
|
net.sourceforge.pebble.domain.RefererFilterTest.testHashCode
![]() |
1 PASS | |
1 | /* | |
2 | * Copyright (c) 2003-2006, Simon Brown | |
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 | |
9 | * notice, this list of conditions and the following disclaimer. | |
10 | * | |
11 | * - Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in | |
13 | * the documentation and/or other materials provided with the | |
14 | * distribution. | |
15 | * | |
16 | * - Neither the name of Pebble nor the names of its contributors may | |
17 | * be used to endorse or promote products derived from this software | |
18 | * without specific prior written permission. | |
19 | * | |
20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | |
24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
30 | * POSSIBILITY OF SUCH DAMAGE. | |
31 | */ | |
32 | package net.sourceforge.pebble.domain; | |
33 | ||
34 | import java.util.regex.Pattern; | |
35 | ||
36 | /** | |
37 | * Represents a blog category. | |
38 | * | |
39 | * @author Simon Brown | |
40 | */ | |
41 | public class RefererFilter implements Comparable { | |
42 | ||
43 | // the internal ID for this filter | |
44 | private long id; | |
45 | ||
46 | /** the underlying filter expression */ | |
47 | private String expression; | |
48 | ||
49 | /** the compiled version of the expression */ | |
50 | private Pattern compiledExpression; | |
51 | ||
52 | 0 |
![]() |
53 | } | |
54 | ||
55 | /** | |
56 | * Creates a new category with the specified properties. | |
57 | * | |
58 | * @param expression the filter expression | |
59 | */ | |
60 | 30 |
![]() |
61 | 30 | setExpression(expression); |
62 | } | |
63 | ||
64 | 6 |
![]() |
65 | 6 | this.id = id; |
66 | } | |
67 | ||
68 | 2 |
![]() |
69 | 2 | return this.id; |
70 | } | |
71 | ||
72 | /** | |
73 | * Gets the expression. | |
74 | * | |
75 | * @return the expression as a String | |
76 | */ | |
77 | 20 |
![]() |
78 | 20 | return this.expression; |
79 | } | |
80 | ||
81 | /** | |
82 | * Sets the expression. | |
83 | * | |
84 | * @param expression the expression as a String | |
85 | */ | |
86 | 30 |
![]() |
87 | 30 | if (expression == null) { |
88 | 2 | this.expression = ""; |
89 | } else { | |
90 | 28 | this.expression = expression; |
91 | } | |
92 | 30 | this.compiledExpression = Pattern.compile(this.expression); |
93 | } | |
94 | ||
95 | /** | |
96 | * Gets the compiled version of the expression. | |
97 | * | |
98 | * @return the compiled expression as a Pattern | |
99 | */ | |
100 | 2 |
![]() |
101 | 2 | return this.compiledExpression; |
102 | } | |
103 | ||
104 | /** | |
105 | * Gets the hashcode of this object. | |
106 | * | |
107 | * @return the hashcode as an int | |
108 | */ | |
109 | 18 |
![]() |
110 | 18 | return expression.hashCode(); |
111 | } | |
112 | ||
113 | /** | |
114 | * Determines whether the specified object is equal to this one. | |
115 | * | |
116 | * @param o the object to compare against | |
117 | * @return true if Object o represents the same category, false otherwise | |
118 | */ | |
119 | 8 |
![]() |
120 | 8 | if (!(o instanceof RefererFilter)) { |
121 | 4 | return false; |
122 | } | |
123 | ||
124 | 4 | RefererFilter filter = (RefererFilter)o; |
125 | 4 | return (filter.getExpression().equals(expression)); |
126 | } | |
127 | ||
128 | /** | |
129 | * Compares this object with the specified object for order. Returns a | |
130 | * negative integer, zero, or a positive integer if this object is less | |
131 | * than, equal to, or greater than the specified object. | |
132 | * | |
133 | * @param o the Object to be compared. | |
134 | * @return a negative integer, zero, or a positive integer if this object | |
135 | * is less than, equal to, or greater than the specified object. | |
136 | * | |
137 | * @throws ClassCastException if the specified object's type prevents it | |
138 | * from being compared to this Object. | |
139 | */ | |
140 | 6 |
![]() |
141 | 6 | RefererFilter category = (RefererFilter)o; |
142 | 6 | return getExpression().compareTo(category.getExpression()); |
143 | } | |
144 | ||
145 | } |
|