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.components;
18  
19  /***
20   * @author <a href="mailto:sweaver@einnovation.com">Scott T. Weaver</a>
21   *
22   */
23  public class BaseMockComponent implements MockComponent
24  {
25      private int fieldValue1;
26      private String fieldValue2;
27    
28      private int id;
29      private String threadName;
30      protected static int instanceCount;
31  
32      public BaseMockComponent(int inValue1, String inValue2)
33      {
34          id = instanceCount;
35          instanceCount++;
36          fieldValue1 = inValue1;
37          fieldValue2 = inValue2;
38          this.threadName = Thread.currentThread().getName();
39          
40      }
41  
42      /***
43       * @return Returns the value1.
44       */
45      public int getValue1()
46      {
47          return fieldValue1;
48      }
49      /***
50       * @param value1 The value1 to set.
51       */
52      public void setValue1( int value1 )
53      {
54          fieldValue1 = value1;
55      }
56      /***
57       * @return Returns the value2.
58       */
59      public String getValue2()
60      {
61          return fieldValue2;
62      }
63      /***
64       * @param value2 The value2 to set.
65       */
66      public void setValue2( String value2 )
67      {
68          fieldValue2 = value2;
69      }
70      /* (non-Javadoc)
71       * @see org.apache.jetspeed.components.MockComponent#componentCount()
72       */
73      public int componentId()
74      {        
75          return id;
76      }
77      /* (non-Javadoc)
78       * @see org.apache.jetspeed.components.MockComponent#getThreadName()
79       */
80      public String getThreadName()
81      {        
82          return threadName;
83      }
84      
85      public Object getValue( String key )
86      {
87          if(key.equals("1"))
88          {
89              return new Integer(getValue1());
90          }
91          else if(key.equals("2"))
92          {
93              return getValue2();
94          }
95          else
96          {
97              return null;
98          }
99      }
100     public void setValue( String key, Object value )
101     {
102         if(key.equals("1"))
103         {
104             setValue1(Integer.parseInt(value.toString()));
105         }
106         else if(key.equals("2"))
107         {
108             setValue2(value.toString());
109         }
110         
111 
112     }
113 }