01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: * $Header:$
18: */
19: package org.apache.beehive.netui.compiler.typesystem.impl.declaration;
20:
21: import org.apache.beehive.netui.compiler.typesystem.declaration.Declaration;
22: import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationInstance;
23: import org.apache.beehive.netui.compiler.typesystem.declaration.Modifier;
24: import org.apache.beehive.netui.compiler.typesystem.util.SourcePosition;
25: import org.apache.beehive.netui.compiler.typesystem.impl.env.SourcePositionImpl;
26: import org.apache.beehive.netui.compiler.typesystem.impl.DelegatingImpl;
27: import org.apache.beehive.netui.compiler.typesystem.impl.WrapperFactory;
28:
29: import java.util.Collection;
30: import java.util.Set;
31: import java.util.HashSet;
32:
33: public class DeclarationImpl extends DelegatingImpl implements
34: Declaration {
35: private AnnotationInstance[] _annotations;
36: private Set _modifiers;
37:
38: public DeclarationImpl(
39: com.sun.mirror.declaration.Declaration delegate) {
40: super (delegate);
41: }
42:
43: public String getDocComment() {
44: return getDelegate().getDocComment();
45: }
46:
47: public AnnotationInstance[] getAnnotationInstances() {
48: if (_annotations == null) {
49: Collection<com.sun.mirror.declaration.AnnotationMirror> delegateCollection = getDelegate()
50: .getAnnotationMirrors();
51: AnnotationInstance[] array = new AnnotationInstance[delegateCollection
52: .size()];
53: int j = 0;
54: for (com.sun.mirror.declaration.AnnotationMirror i : delegateCollection) {
55: array[j++] = WrapperFactory.get()
56: .getAnnotationInstance(i, this );
57: }
58: _annotations = array;
59: }
60:
61: return _annotations;
62: }
63:
64: public Set getModifiers() {
65: if (_modifiers == null) {
66: Collection<com.sun.mirror.declaration.Modifier> delegateCollection = getDelegate()
67: .getModifiers();
68: Set modifiers = new HashSet();
69: for (com.sun.mirror.declaration.Modifier i : delegateCollection) {
70: modifiers.add(ModifierImpl.get(i));
71: }
72: _modifiers = modifiers;
73: }
74:
75: return _modifiers;
76: }
77:
78: public String getSimpleName() {
79: return getDelegate().getSimpleName();
80: }
81:
82: public SourcePosition getPosition() {
83: return SourcePositionImpl.get(getDelegate().getPosition());
84: }
85:
86: public boolean hasModifier(Modifier modifier) {
87: return getModifiers().contains(modifier);
88: }
89:
90: protected com.sun.mirror.declaration.Declaration getDelegate() {
91: return (com.sun.mirror.declaration.Declaration) super
92: .getDelegate();
93: }
94: }
|