01 
02 /*
03  *  JavaDoq 1.0 - DOCUment JAVA In Source
04  *  Copyright (C) 2008-2011  J.J.Liu<jianjunliu@126.com> <http://www.javadoq.com>
05  *  
06  *  This program is free software: you can redistribute it and/or modify
07  *  it under the terms of the GNU Affero General Public License as published by
08  *  the Free Software Foundation, either version 3 of the License, or
09  *  (at your option) any later version.
10  *  
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU Affero General Public License for more details.
15  *  
16  *  You should have received a copy of the GNU Affero General Public License
17  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 package com.javadoq;
21 
22 /**
23  * <p>Represents an enclosed Java type, either a class, an interface or enum.</p>
24  * 
25  * @author <a href="mailto:jianjunliu@126.com">J.J.Liu (Jianjun Liu)</a> at <a href="http://www.javadoq.com" target="_blank">http://www.javadoq.com</a>
26  */
27 public class JavaNestedType extends JavaType
28 {
29     /**
30      * <p>The enclosing type.</p>
31      * @since 1.0
32      */
33     public final JavaType outer;
34 
35     /**
36      * <p>Constructs a {@link JavaNestedType}.</p>
37      * @param outer The enclosing type.
38      * @param name The simple name for the type.
39      * @since 1.0
40      */
41     public JavaNestedType(JavaType outer, String name) {
42         super(outer.file, name, outer.qname.addLast(name));
43         this.outer = outer;
44     }
45 
46     /**
47      * <p>Finds a Java type locally defined within this type or its super types.</p>
48      * @param name The simple name for the type being found.
49      * @return The matched Java type or <tt>null</tt> if it is not found.
50      * @since 1.0
51      */
52     @Override
53     protected JavaType findLocalType(JavaName name) {
54         JavaType t = super.findLocalType(name);
55         if (t == null) {
56             t = outer.findLocalType(name);
57         }
58         return t;
59     }
60 }