%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.jetspeed.rewriter.rules.impl.RuleImpl |
|
|
1 | /* |
|
2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
|
3 | * contributor license agreements. See the NOTICE file distributed with |
|
4 | * this work for additional information regarding copyright ownership. |
|
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
6 | * (the "License"); you may not use this file except in compliance with |
|
7 | * the License. You may obtain a copy of the License at |
|
8 | * |
|
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
10 | * |
|
11 | * Unless required by applicable law or agreed to in writing, software |
|
12 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
14 | * See the License for the specific language governing permissions and |
|
15 | * limitations under the License. |
|
16 | */ |
|
17 | package org.apache.jetspeed.rewriter.rules.impl; |
|
18 | ||
19 | import java.util.Iterator; |
|
20 | import java.util.List; |
|
21 | import java.util.ArrayList; |
|
22 | import java.util.StringTokenizer; |
|
23 | ||
24 | import org.apache.jetspeed.rewriter.rules.Rule; |
|
25 | ||
26 | /** |
|
27 | * Rule |
|
28 | * |
|
29 | * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a> |
|
30 | * @version $Id: RuleImpl.java 517121 2007-03-12 07:45:49Z ate $ |
|
31 | */ |
|
32 | 0 | public class RuleImpl extends IdentifiedImpl implements Rule |
33 | { |
|
34 | 0 | private boolean useBase = true; |
35 | 0 | private boolean popup = false; |
36 | 0 | private String suffix = null; |
37 | 0 | private String prefixes = null; |
38 | 0 | private List ignorePrefixes = null; |
39 | ||
40 | public String toString() |
|
41 | { |
|
42 | 0 | return id; |
43 | } |
|
44 | ||
45 | /* (non-Javadoc) |
|
46 | * @see org.apache.jetspeed.cps.rewriter.rules.Rule#getPopup() |
|
47 | */ |
|
48 | public boolean getPopup() |
|
49 | { |
|
50 | 0 | return popup; |
51 | } |
|
52 | ||
53 | /* (non-Javadoc) |
|
54 | * @see org.apache.jetspeed.cps.rewriter.rules.Rule#getSuffix() |
|
55 | */ |
|
56 | public String getSuffix() |
|
57 | { |
|
58 | 0 | return suffix; |
59 | } |
|
60 | ||
61 | /* (non-Javadoc) |
|
62 | * @see org.apache.jetspeed.cps.rewriter.rules.Rule#getUseBase() |
|
63 | */ |
|
64 | public boolean getUseBase() |
|
65 | { |
|
66 | 0 | return useBase; |
67 | } |
|
68 | ||
69 | /* (non-Javadoc) |
|
70 | * @see org.apache.jetspeed.cps.rewriter.rules.Rule#setPopup(boolean) |
|
71 | */ |
|
72 | public void setPopup(boolean b) |
|
73 | { |
|
74 | 0 | popup = b; |
75 | 0 | } |
76 | ||
77 | /* (non-Javadoc) |
|
78 | * @see org.apache.jetspeed.cps.rewriter.rules.Rule#setSuffix(java.lang.String) |
|
79 | */ |
|
80 | public void setSuffix(String string) |
|
81 | { |
|
82 | 0 | suffix = string; |
83 | 0 | } |
84 | ||
85 | /* (non-Javadoc) |
|
86 | * @see org.apache.jetspeed.cps.rewriter.rules.Rule#setUseBase(boolean) |
|
87 | */ |
|
88 | public void setUseBase(boolean b) |
|
89 | { |
|
90 | 0 | useBase = b; |
91 | 0 | } |
92 | ||
93 | public void setIgnorePrefixes(String prefixes) |
|
94 | { |
|
95 | 0 | this.prefixes = prefixes; |
96 | 0 | } |
97 | ||
98 | public String getIgnorePrefixes() |
|
99 | { |
|
100 | 0 | return this.prefixes; |
101 | } |
|
102 | ||
103 | public boolean shouldRewrite(String url) |
|
104 | { |
|
105 | 0 | if (prefixes == null) |
106 | { |
|
107 | 0 | return true; |
108 | } |
|
109 | 0 | if (ignorePrefixes == null) |
110 | { |
|
111 | 0 | ignorePrefixes = new ArrayList(); |
112 | 0 | StringTokenizer tokenizer = new StringTokenizer(prefixes, ","); |
113 | 0 | while (tokenizer.hasMoreTokens()) |
114 | { |
|
115 | 0 | String token = tokenizer.nextToken(); |
116 | 0 | ignorePrefixes.add(token); |
117 | 0 | } |
118 | ||
119 | } |
|
120 | ||
121 | 0 | Iterator list = ignorePrefixes.iterator(); |
122 | 0 | while (list.hasNext()) |
123 | { |
|
124 | 0 | String prefix = (String)list.next(); |
125 | 0 | if (url.startsWith(prefix)) |
126 | { |
|
127 | 0 | return false; |
128 | } |
|
129 | 0 | } |
130 | 0 | return true; |
131 | } |
|
132 | ||
133 | ||
134 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |