001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.jetspeed.components;
018:
019: /**
020: * @author <a href="mailto:sweaver@einnovation.com">Scott T. Weaver</a>
021: *
022: */
023: public class BaseMockComponent implements MockComponent {
024: private int fieldValue1;
025: private String fieldValue2;
026:
027: private int id;
028: private String threadName;
029: protected static int instanceCount;
030:
031: public BaseMockComponent(int inValue1, String inValue2) {
032: id = instanceCount;
033: instanceCount++;
034: fieldValue1 = inValue1;
035: fieldValue2 = inValue2;
036: this .threadName = Thread.currentThread().getName();
037:
038: }
039:
040: /**
041: * @return Returns the value1.
042: */
043: public int getValue1() {
044: return fieldValue1;
045: }
046:
047: /**
048: * @param value1 The value1 to set.
049: */
050: public void setValue1(int value1) {
051: fieldValue1 = value1;
052: }
053:
054: /**
055: * @return Returns the value2.
056: */
057: public String getValue2() {
058: return fieldValue2;
059: }
060:
061: /**
062: * @param value2 The value2 to set.
063: */
064: public void setValue2(String value2) {
065: fieldValue2 = value2;
066: }
067:
068: /* (non-Javadoc)
069: * @see org.apache.jetspeed.components.MockComponent#componentCount()
070: */
071: public int componentId() {
072: return id;
073: }
074:
075: /* (non-Javadoc)
076: * @see org.apache.jetspeed.components.MockComponent#getThreadName()
077: */
078: public String getThreadName() {
079: return threadName;
080: }
081:
082: public Object getValue(String key) {
083: if (key.equals("1")) {
084: return new Integer(getValue1());
085: } else if (key.equals("2")) {
086: return getValue2();
087: } else {
088: return null;
089: }
090: }
091:
092: public void setValue(String key, Object value) {
093: if (key.equals("1")) {
094: setValue1(Integer.parseInt(value.toString()));
095: } else if (key.equals("2")) {
096: setValue2(value.toString());
097: }
098:
099: }
100: }
|