KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > j2biz > pencil > test > scenario > impl > refCall > LocalClassTest


1 /*
2  * Copyright 2004 Andreas Siebert (j2biz community)
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7
8  * http://www.apache.org/licenses/LICENSE-2.0
9
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package com.j2biz.pencil.test.scenario.impl.refCall;
17
18
19 import com.j2biz.pencil.test.additional.DotCallTestObject;
20 import com.j2biz.pencil.test.additional.TestLog;
21
22 public class LocalClassTest {
23
24     public int publicField = new Integer JavaDoc(1).intValue();
25     protected int protectedField = new Integer JavaDoc(2).intValue();
26     private int privateField = new Integer JavaDoc(3).intValue();
27     
28     
29     public static class NestedClass {
30         public int publicField = new Integer JavaDoc(1).intValue();
31         protected int protectedField = new Integer JavaDoc(2).intValue();
32         private int privateField = new Integer JavaDoc(3).intValue();
33     }
34     
35     public static void main(String JavaDoc[] args) {
36         class RefData {
37             public int publicField = new Integer JavaDoc(1).intValue();
38             protected int protectedField = new Integer JavaDoc(2).intValue();
39             private int privateField = new Integer JavaDoc(3).intValue();
40             
41             public void testEnclosingClass() {
42                 LocalClassTest encClass = new LocalClassTest();
43                 TestLog.debug("refCall.LocalClassTest.refData.testEnclosingClass().public = " + encClass.publicField);
44                 TestLog.debug("refCall.LocalClassTest.refData.testEnclosingClass().protected = " + encClass.protectedField);
45                 TestLog.debug("refCall.LocalClassTest.refData.testEnclosingClass().private = " + encClass.privateField);
46             }
47         }
48         
49         RefData refData = new RefData();
50
51         TestLog.debug("refCall.LocalClassTest.main().public = " + refData.publicField);
52         TestLog.debug("refCall.LocalClassTest.main().protected = " + refData.protectedField);
53         TestLog.debug("refCall.LocalClassTest.main().private = " + refData.privateField);
54         
55         class LocalExtendsNestedClass extends NestedClass {
56
57         }
58         
59         LocalExtendsNestedClass localExtNested = new LocalExtendsNestedClass();
60         TestLog.debug("refCall.LocalClassTest.main().LocalExtendsNestedClass.public = " + localExtNested.publicField);
61         TestLog.debug("refCall.LocalClassTest.main().LocalExtendsNestedClass.protected = " + localExtNested.protectedField);
62         TestLog.debug("refCall.LocalClassTest.main().LocalExtendsNestedClass.private = ${localExtNested.privateField}");
63         
64
65         DotCallTestObject subClass = DotCallTestObject.createSublCass();
66         TestLog.debug("refCall.LocalClassTest.main().subClassIsHidden.public = " + subClass.field1);
67         TestLog.debug("refCall.LocalClassTest.main().subClassIsHidden.protected = ${subClass.field2}");
68         TestLog.debug("refCall.LocalClassTest.main().subClassIsHidden.private = ${subClass.field3}");
69     }
70     
71 }
72
Popular Tags