View Javadoc

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.profiler.rules.impl;
18  
19  import org.apache.jetspeed.profiler.rules.RuleCriterion;
20  
21  /***
22   * RuleCriterionImpl
23   *
24   * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
25   * @version $Id: RuleCriterionImpl.java 516448 2007-03-09 16:25:47Z ate $
26   */
27  public class RuleCriterionImpl implements RuleCriterion
28  {
29      private String id;
30      private String ruleId;
31      private String type;
32      private String name = null;
33      private String value;
34      private int fallbackType = RuleCriterion.FALLBACK_CONTINUE;
35      private int fallbackOrder;
36      
37      public RuleCriterionImpl()
38      {
39      }
40  
41      public RuleCriterionImpl(RuleCriterion master)
42      {
43          this.name = master.getName();
44          this.ruleId = master.getRuleId();
45          this.type = master.getType();
46          this.value = master.getValue();
47          this.fallbackOrder = master.getFallbackOrder();
48          this.fallbackType = master.getFallbackType();
49      }
50      /***
51       * two objects of type RuleCriterion should be considered equal if their name and type  are the same
52       * 
53       */
54       public boolean equals(Object o)
55      {
56      	if (this == o) return true;
57      	if ((o == null) || (!(o instanceof RuleCriterion)))
58      		return false;
59      	RuleCriterion r = (RuleCriterion)o;
60      	if (this.name != null)
61      	{
62      		if (!(this.name.equals(r.getName())))
63      				return false;
64      	}
65      	else
66      		if (r.getName() != null)
67      			return false;
68      	if (this.type != null)
69      	{
70      		if (!(this.type.equals(r.getName())))
71      				return false;
72      	}
73      	else
74      		if (r.getType() != null)
75      			return false;
76      	return true;    	
77      	
78      }
79      /* (non-Javadoc)
80       * @see org.apache.jetspeed.profiler.rules.RuleCriterion#getType()
81       */
82      public String getType()
83      {
84          return this.type;
85      }
86      
87      /* (non-Javadoc)
88       * @see org.apache.jetspeed.profiler.rules.RuleCriterion#setType(java.lang.String)
89       */
90      public void setType(String type)
91      {
92          this.type = type;
93      }
94      
95      /* (non-Javadoc)
96       * @see org.apache.jetspeed.profiler.rules.RuleCriterion#getName()
97       */
98      public String getName()
99      {
100         return this.name;
101     }
102     
103     /* (non-Javadoc)
104      * @see org.apache.jetspeed.profiler.rules.RuleCriterion#setName(java.lang.String)
105      */
106     public void setName(String name)
107     {
108         this.name = name;
109     }
110 
111     /* (non-Javadoc)
112      * @see org.apache.jetspeed.profiler.rules.RuleCriterion#getRuleId()
113      */
114     public String getRuleId()
115     {
116         return ruleId;
117     }
118 
119     /* (non-Javadoc)
120      * @see org.apache.jetspeed.profiler.rules.RuleCriterion#setRuleId(java.lang.String)
121      */
122     public void setRuleId(String ruleId)
123     {
124         this.ruleId = ruleId;
125     }
126 
127     /* (non-Javadoc)
128      * @see org.apache.jetspeed.profiler.rules.RuleCriterion#getFallbackOrder()
129      */
130     public int getFallbackOrder()
131     {
132         return fallbackOrder;
133     }
134 
135     /* (non-Javadoc)
136      * @see org.apache.jetspeed.profiler.rules.RuleCriterion#getValue()
137      */
138     public String getValue()
139     {
140         return value;
141     }
142 
143     /* (non-Javadoc)
144      * @see org.apache.jetspeed.profiler.rules.RuleCriterion#setFallbackOrder(int)
145      */
146     public void setFallbackOrder(int i)
147     {
148         fallbackOrder = i;
149     }
150 
151     /* (non-Javadoc)
152      * @see org.apache.jetspeed.profiler.rules.RuleCriterion#setValue(java.lang.String)
153      */
154     public void setValue(String value)
155     {
156         this.value = value;
157     }
158 
159     /* (non-Javadoc)
160      * @see org.apache.jetspeed.profiler.rules.RuleCriterion#getFallbackType()
161      */
162     public int getFallbackType()
163     {
164         return fallbackType;
165     }
166 
167     /* (non-Javadoc)
168      * @see org.apache.jetspeed.profiler.rules.RuleCriterion#setFallbackType(int)
169      */
170     public void setFallbackType(int i)
171     {
172         fallbackType = i;
173     }
174 
175     
176 }