001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * If you wish your version of this file to be governed by only the CDDL
025: * or only the GPL Version 2, indicate your decision by adding
026: * "[Contributor] elects to include this software in this distribution
027: * under the [CDDL or GPL Version 2] license." If you do not indicate a
028: * single choice of license, a recipient has the option to distribute
029: * your version of this file under either the CDDL, the GPL Version 2 or
030: * to extend the choice of license to its licensees as provided above.
031: * However, if you add GPL Version 2 code and therefore, elected the GPL
032: * Version 2 license, then the option applies only if the new code is
033: * made subject to such option by the copyright holder.
034: *
035: * Contributor(s):
036: *
037: * Portions Copyrighted 2007 Sun Microsystems, Inc.
038: */
039:
040: package org.netbeans.modules.visualweb.dataprovider;
041:
042: import java.io.Serializable;
043: import java.util.ArrayList;
044: import java.util.HashMap;
045: import java.util.List;
046: import java.util.Map;
047:
048: /**
049: * <p>JavaBean for data provider unit tests.</p>
050: */
051: public class TestBean implements Serializable {
052:
053: public TestBean() {
054: }
055:
056: public TestBean(String id) {
057: this .id = id;
058: }
059:
060: // Public id (set in constructor) for easy identification
061: private String id = null;
062:
063: public String getId() {
064: return this .id;
065: }
066:
067: public void setId(String id) {
068: this .id = id;
069: }
070:
071: // Read-only property for testing
072: private String readOnly = "readOnly Property";
073:
074: public String getReadOnly() {
075: return this .readOnly;
076: }
077:
078: // Public fieldKeys with no getter/setter for tests related to accessing fieldKeys
079: public String public1 = "This is public1";
080: public int public2 = 8888;
081:
082: private boolean booleanProperty = true;
083:
084: public boolean getBooleanProperty() {
085: return this .booleanProperty;
086: }
087:
088: public void setBooleanProperty(boolean booleanProperty) {
089: this .booleanProperty = booleanProperty;
090: }
091:
092: private byte byteProperty = 123;
093:
094: public byte getByteProperty() {
095: return this .byteProperty;
096: }
097:
098: public void setByteProperty(byte byteProperty) {
099: this .byteProperty = byteProperty;
100: }
101:
102: private double doubleProperty = 654.321;
103:
104: public double getDoubleProperty() {
105: return this .doubleProperty;
106: }
107:
108: public void setDoubleProperty(double doubleProperty) {
109: this .doubleProperty = doubleProperty;
110: }
111:
112: private float floatProperty = (float) 123.45;
113:
114: public float getFloatProperty() {
115: return this .floatProperty;
116: }
117:
118: public void setFloatProperty(float floatProperty) {
119: this .floatProperty = floatProperty;
120: }
121:
122: private int intArray[] = { 1, 2, 3 };
123:
124: public int[] getIntArray() {
125: return this .intArray;
126: }
127:
128: public void setIntArray(int intArray[]) {
129: this .intArray = intArray;
130: }
131:
132: private List intList = null;
133:
134: public List getIntList() {
135: if (intList == null) {
136: intList = new ArrayList();
137: intList.add(new Integer(10));
138: intList.add(new Integer(20));
139: intList.add(new Integer(30));
140: intList.add(new Integer(40));
141: intList.add(new Integer(50));
142: }
143: return intList;
144: }
145:
146: public void setIntList(List intList) {
147: this .intList = intList;
148: }
149:
150: private int intProperty = 1234;
151:
152: public int getIntProperty() {
153: return this .intProperty;
154: }
155:
156: public void setIntProperty(int intProperty) {
157: this .intProperty = intProperty;
158: }
159:
160: private long longProperty = 54321;
161:
162: public long getLongProperty() {
163: return this .longProperty;
164: }
165:
166: public void setLongProperty(long longProperty) {
167: this .longProperty = longProperty;
168: }
169:
170: private TestBean nestedArray[] = null;
171:
172: public TestBean[] getNestedArray() {
173: if (nestedArray == null) {
174: nestedArray = new TestBean[2];
175: nestedArray[0] = new TestBean("array0");
176: nestedArray[1] = new TestBean("array1");
177: }
178: return this .nestedArray;
179: }
180:
181: public void setNestedArray(TestBean nestedArray[]) {
182: this .nestedArray = nestedArray;
183: }
184:
185: private List nestedList = null;
186:
187: public List getNestedList() {
188: if (nestedList == null) {
189: nestedList = new ArrayList();
190: nestedList.add(new TestBean("list0"));
191: nestedList.add(new TestBean("list1"));
192: nestedList.add(new TestBean("list2"));
193: nestedList.add(new TestBean("list3"));
194: }
195: return this .nestedList;
196: }
197:
198: public void setNestedList(List nestedList) {
199: this .nestedList = nestedList;
200: }
201:
202: private Map nestedMap = null;
203:
204: public Map getNestedMap() {
205: if (nestedMap == null) {
206: nestedMap = new HashMap();
207: nestedMap.put("map0", new TestBean("map0"));
208: nestedMap.put("map1", new TestBean("map1"));
209: nestedMap.put("map2", new TestBean("map2"));
210: }
211: return (this .nestedMap);
212: }
213:
214: public void setNestedMap(Map nestedMap) {
215: this .nestedMap = nestedMap;
216: }
217:
218: private TestBean nestedProperty = null;
219:
220: public TestBean getNestedProperty() {
221: if (nestedProperty == null) {
222: nestedProperty = new TestBean();
223: }
224: return this .nestedProperty;
225: }
226:
227: public void setNestedProperty(TestBean nestedProperty) {
228: this .nestedProperty = nestedProperty;
229: }
230:
231: private short shortProperty = 321;
232:
233: public short getShortProperty() {
234: return this .shortProperty;
235: }
236:
237: public void setShortProperty(short shortProperty) {
238: this .shortProperty = shortProperty;
239: }
240:
241: private String stringProperty = "This is a String";
242:
243: public String getStringProperty() {
244: return this .stringProperty;
245: }
246:
247: public void setStringProperty(String stringProperty) {
248: this .stringProperty = stringProperty;
249: }
250:
251: // This property is also read-only
252: private String nullString = null;
253:
254: public String getNullString() {
255: return this.nullString;
256: }
257:
258: }
|