001: /*
002: * Copyright 2007 Google Inc.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005: * use this file except in compliance with the License. You may obtain a copy of
006: * the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
012: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013: * License for the specific language governing permissions and limitations under
014: * the License.
015: */
016: package com.google.gwt.user.client.rpc;
017:
018: import java.io.Serializable;
019:
020: /**
021: * Test data factory used by the
022: * {@link com.google.gwt.user.client.rpc.InheritanceTest InheritanceTest} unit
023: * test.
024: */
025: public class InheritanceTestSetFactory {
026:
027: /**
028: * Used to test <a
029: * href="http://code.google.com/p/google-web-toolkit/issues/detail?id=1163">Issue
030: * 1163</a>.
031: */
032: public static class AbstractClass implements IsSerializable {
033: }
034:
035: /**
036: * TODO: document me.
037: */
038: public static interface AnonymousClassInterface extends
039: IsSerializable {
040: void foo();
041: }
042:
043: /**
044: * This class is here to make the code generator think that there is at least
045: * one serializable subclass of the AnonymousClassInterface.
046: */
047: public static class AnonymousClassInterfaceImplementor implements
048: AnonymousClassInterface {
049: public void foo() {
050: }
051: }
052:
053: /**
054: * TODO: document me.
055: */
056: public static class Circle extends Shape {
057: private String name;
058:
059: public native void doStuff() /*-{
060: alert("foo");
061: }-*/;
062: }
063:
064: /**
065: * TODO: document me.
066: */
067: public static class JavaSerializableBaseClass implements
068: Serializable {
069: private int field1 = -1;
070:
071: public JavaSerializableBaseClass() {
072: }
073:
074: public JavaSerializableBaseClass(int field1) {
075: this .field1 = field1;
076: }
077: }
078:
079: /**
080: * TODO: document me.
081: */
082: public static class JavaSerializableClass extends
083: JavaSerializableBaseClass {
084: private int field2 = -2;
085:
086: public JavaSerializableClass() {
087: }
088:
089: public JavaSerializableClass(int field2) {
090: this .field2 = field2;
091: }
092: }
093:
094: /**
095: * Used to test <a
096: * href="http://code.google.com/p/google-web-toolkit/issues/detail?id=1163">Issue
097: * 1163</a>.
098: */
099: public static interface MySerializableInterface extends
100: IsSerializable {
101: }
102:
103: /**
104: * Used to test <a
105: * href="http://code.google.com/p/google-web-toolkit/issues/detail?id=1163">Issue
106: * 1163</a>.
107: */
108: public static interface MySerializableInterfaceSubtype extends
109: MySerializableInterface {
110: }
111:
112: /**
113: * This class is here to make the code generator think that there is at least
114: * one serializable subclass of the MySerializableInterfaceSubtype.
115: */
116: public static class MySerializableInterfaceSubtypeImplementor
117: implements MySerializableInterfaceSubtype {
118: }
119:
120: /**
121: * TODO: document me.
122: */
123: public static class SerializableClass implements IsSerializable {
124: protected int d = 4;
125:
126: int e = 5;
127:
128: private int a = 1;
129:
130: private int b = 2;
131:
132: private int c = 3;
133:
134: public int getA() {
135: return a;
136: }
137:
138: public int getB() {
139: return b;
140: }
141:
142: public int getC() {
143: return c;
144: }
145:
146: public void setA(int a) {
147: this .a = a;
148: }
149:
150: public void setB(int b) {
151: this .b = b;
152: }
153:
154: public void setC(int c) {
155: this .c = c;
156: }
157: }
158:
159: /**
160: * TODO: document me.
161: */
162: public static class SerializableClassWithTransientField extends
163: SerializableClass {
164: private transient Object obj;
165:
166: public Object getObj() {
167: return obj;
168: }
169:
170: public void setObj(Object obj) {
171: this .obj = obj;
172: }
173: }
174:
175: /**
176: * TODO: document me.
177: */
178: public static class SerializableSubclass extends SerializableClass {
179: private int d = 4;
180:
181: public int getD() {
182: return d;
183: }
184:
185: public void setD(int d) {
186: this .d = d;
187: }
188: }
189:
190: /**
191: * TODO: document me.
192: */
193: public static class Shape implements IsSerializable {
194: private String name;
195:
196: public String getName() {
197: return name;
198: }
199:
200: public void setName(String name) {
201: this .name = name;
202: }
203: }
204:
205: public static Circle createCircle() {
206: Circle circle = new Circle();
207: circle.setName("Circle");
208: return circle;
209: }
210:
211: public static SerializableClass createNonStaticInnerClass() {
212: return new SerializableClass() {
213: public String toString() {
214: return "foo";
215: }
216: };
217: }
218:
219: public static SerializableClass createSerializableClass() {
220: return new SerializableClass();
221: }
222:
223: public static SerializableClassWithTransientField createSerializableClassWithTransientField() {
224: SerializableClassWithTransientField cls = new SerializableClassWithTransientField();
225: cls.setObj("hello");
226: return cls;
227: }
228:
229: public static SerializableClass createSerializableSubclass() {
230: return new SerializableSubclass();
231: }
232: }
|