1 22 package org.aspectj.tools.ajdoc; 23 24 import org.aspectj.compiler.base.ast.Dec; 25 import org.aspectj.compiler.base.ast.Modifiers; 26 import org.aspectj.compiler.base.ast.NameType; 27 import org.aspectj.compiler.base.ast.TypeDec; 28 import org.aspectj.compiler.crosscuts.AspectJCompiler; 29 30 import com.sun.javadoc.ClassDoc; 31 import com.sun.javadoc.PackageDoc; 32 33 import java.lang.reflect.Modifier ; 34 35 public abstract class ProgramElementDocImpl 36 extends DocImpl 37 implements org.aspectj.ajdoc.ProgramElementDoc { 38 39 40 private final ClassDoc containingClass; 41 42 47 public ProgramElementDocImpl(ClassDoc containingClass) { 48 this.containingClass = containingClass; 49 } 50 51 56 protected abstract Dec dec(); 57 58 64 protected final AspectJCompiler ajc() { 65 return (AspectJCompiler)dec().getCompiler(); 66 } 67 68 73 public Comment getComment() { 74 if (super.getComment() == null) { 75 setComment(new Comment(this, dec().getFormalComment(), err())); 76 } 77 return super.getComment(); 78 } 79 80 88 public ClassDoc containingClass() { 89 return containingClass; 90 } 91 92 98 public PackageDoc containingPackage() { 99 return PackageDocImpl.getPackageDoc(nonNullTypeDec()); 100 } 101 102 104 public TypeDec nonNullTypeDec() { 105 if (dec().getDeclaringType() == null) return null; 106 return ((NameType)dec().getDeclaringType()).getTypeDec(); 107 } 108 109 115 public int modifierSpecifier() { 116 return dec().getModifiers().getValue(); 117 } 118 119 124 public String modifiers() { 125 return Modifier.toString(modifierSpecifier()); 126 } 127 128 133 public boolean isPublic() { 134 return dec().isPublic(); 135 } 136 137 142 public boolean isProtected() { 143 return dec().isProtected(); 144 } 145 146 151 public boolean isPackagePrivate() { 152 Modifiers mods = dec().getModifiers(); 153 return ((null != mods) && mods.isPackagePrivate()); 156 } 157 158 163 public boolean isPrivate() { 164 return dec().isPrivate(); 165 } 166 167 172 public boolean isStatic() { 173 return dec().isStatic(); 174 } 175 176 181 public boolean isFinal() { 182 return dec().isFinal(); 183 } 184 185 190 public String qualifiedName() { 191 return name(); 192 } 193 194 199 public String name() { 200 return dec().getId(); 201 } 202 203 } 204 | Popular Tags |