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: * $Header:$
018: */
019: package org.apache.beehive.netui.compiler.typesystem.impl.declaration;
020:
021: import org.apache.beehive.netui.compiler.typesystem.declaration.FieldDeclaration;
022: import org.apache.beehive.netui.compiler.typesystem.declaration.MethodDeclaration;
023: import org.apache.beehive.netui.compiler.typesystem.declaration.PackageDeclaration;
024: import org.apache.beehive.netui.compiler.typesystem.declaration.TypeDeclaration;
025: import org.apache.beehive.netui.compiler.typesystem.impl.WrapperFactory;
026: import org.apache.beehive.netui.compiler.typesystem.type.InterfaceType;
027:
028: import java.util.Collection;
029:
030: public class TypeDeclarationImpl extends MemberDeclarationImpl
031: implements TypeDeclaration {
032: private InterfaceType[] _super Interfaces;
033: private MethodDeclaration[] _methods;
034: private TypeDeclaration[] _nestedTypes;
035: private FieldDeclaration[] _fields;
036:
037: public TypeDeclarationImpl(
038: com.sun.mirror.declaration.TypeDeclaration delegate) {
039: super (delegate);
040: }
041:
042: public PackageDeclaration getPackage() {
043: return WrapperFactory.get().getPackageDeclaration(
044: getDelegate().getPackage());
045: }
046:
047: public String getQualifiedName() {
048: return getDelegate().getQualifiedName();
049: }
050:
051: /*
052: public TypeParameterDeclaration[] getFormalTypeParameters()
053: {
054: }
055: */
056:
057: public InterfaceType[] getSuperinterfaces() {
058: if (_super Interfaces == null) {
059: Collection<com.sun.mirror.type.InterfaceType> delegateCollection = getDelegate()
060: .getSuperinterfaces();
061: InterfaceType[] array = new InterfaceType[delegateCollection
062: .size()];
063: int j = 0;
064: for (com.sun.mirror.type.InterfaceType i : delegateCollection) {
065: array[j++] = WrapperFactory.get().getInterfaceType(i);
066: }
067: _super Interfaces = array;
068: }
069:
070: return _super Interfaces;
071: }
072:
073: public FieldDeclaration[] getFields() {
074: if (_fields == null) {
075: Collection<com.sun.mirror.declaration.FieldDeclaration> delegateCollection = getDelegate()
076: .getFields();
077: FieldDeclaration[] array = new FieldDeclaration[delegateCollection
078: .size()];
079: int j = 0;
080: for (com.sun.mirror.declaration.FieldDeclaration i : delegateCollection) {
081: array[j++] = WrapperFactory.get()
082: .getFieldDeclaration(i);
083: }
084: _fields = array;
085: }
086:
087: return _fields;
088: }
089:
090: public MethodDeclaration[] getMethods() {
091: if (_methods == null) {
092: Collection<? extends com.sun.mirror.declaration.MethodDeclaration> delegateCollection = getDelegate()
093: .getMethods();
094: MethodDeclaration[] array = new MethodDeclaration[delegateCollection
095: .size()];
096: int j = 0;
097: for (com.sun.mirror.declaration.MethodDeclaration i : delegateCollection) {
098: array[j++] = WrapperFactory.get().getMethodDeclaration(
099: i);
100: }
101: _methods = array;
102: }
103:
104: return _methods;
105: }
106:
107: public TypeDeclaration[] getNestedTypes() {
108: if (_nestedTypes == null) {
109: Collection<com.sun.mirror.declaration.TypeDeclaration> delegateCollection = getDelegate()
110: .getNestedTypes();
111: TypeDeclaration[] array = new TypeDeclaration[delegateCollection
112: .size()];
113: int j = 0;
114: for (com.sun.mirror.declaration.TypeDeclaration i : delegateCollection) {
115: array[j++] = WrapperFactory.get().getTypeDeclaration(i);
116: }
117: _nestedTypes = array;
118: }
119:
120: return _nestedTypes;
121: }
122:
123: protected com.sun.mirror.declaration.TypeDeclaration getDelegate() {
124: return (com.sun.mirror.declaration.TypeDeclaration) super
125: .getDelegate();
126: }
127: }
|