Package org.fife.rsta.ac.java.rjc.ast
Class AbstractTypeDeclarationNode
- java.lang.Object
-
- org.fife.rsta.ac.java.rjc.ast.AbstractASTNode
-
- org.fife.rsta.ac.java.rjc.ast.AbstractTypeDeclarationNode
-
- All Implemented Interfaces:
ASTNode,TypeDeclaration,TypeDeclarationContainer
- Direct Known Subclasses:
EnumDeclaration,NormalClassDeclaration,NormalInterfaceDeclaration
public abstract class AbstractTypeDeclarationNode extends AbstractASTNode implements TypeDeclaration
A base class for type declaration nodes.- Version:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description private OffsetbodyEndOffsprivate OffsetbodyStartOffsprivate java.util.List<TypeDeclaration>childTypesprivate booleandeprecatedprivate java.lang.StringdocCommentprivate java.util.List<Member>memberListprivate Modifiersmodifiersprivate TypeDeclarationparentTypeprivate Packagepkg
-
Constructor Summary
Constructors Constructor Description AbstractTypeDeclarationNode(java.lang.String name, Offset start)AbstractTypeDeclarationNode(java.lang.String name, Offset start, Offset end)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMember(Member member)Adds a member to this type declaration.voidaddTypeDeclaration(TypeDeclaration type)Adds a type declaration to this container.booleangetBodyContainsOffset(int offs)Returns whether this type declaration contains the specified offset.intgetBodyEndOffset()Returns the end-offset of the type declaration's body.intgetBodyStartOffset()Returns the start-offset of the type declaration's body.TypeDeclarationgetChildType(int index)Returns a child type by index.TypeDeclarationgetChildTypeAtOffset(int offs)Returns the child type declaration of this one that contains the specified offset, if any.intgetChildTypeCount()Returns the number of child types.java.lang.StringgetDocComment()Returns the doc comment for this type declaration.java.util.Iterator<Field>getFieldIterator()Returns an iterator over all fields defined in this type.MembergetMember(int index)Returns a member by index.intgetMemberCount()Returns the number of members in this type declaration.java.util.Iterator<Member>getMemberIterator()Returns an iterator over all members of this type.java.util.Iterator<Method>getMethodIterator()Returns an iterator over all methods defined in this type.java.util.List<Method>getMethodsByName(java.lang.String name)Returns all methods declared in this type with the given name.ModifiersgetModifiers()Returns the modifiers of this type declaration.java.lang.StringgetName(boolean fullyQualified)Returns the name of this type.PackagegetPackage()Returns the package this type is in.TypeDeclarationgetParentType()Returns the parent type declaration.private voidinit()booleanisDeprecated()Returns whether this type declaration is deprecated.booleanisStatic()Shortcut forgetModifiers().isStatic(); useful sincegetModifiers()may returnnull.voidsetBodyEndOffset(Offset end)voidsetBodyStartOffset(Offset start)voidsetDeprecated(boolean deprecated)voidsetDocComment(java.lang.String comment)Sets the doc comment for this type declaration.voidsetModifiers(Modifiers modifiers)voidsetPackage(Package pkg)Sets the package this type is in.voidsetParentType(TypeDeclaration parentType)Sets the parent type declaration for this type declaration.java.lang.StringtoString()Returns the name of this node (e.g.-
Methods inherited from class org.fife.rsta.ac.java.rjc.ast.AbstractASTNode
getName, getNameEndOffset, getNameStartOffset, setDeclarationEndOffset, setDeclarationOffsets
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.fife.rsta.ac.java.rjc.ast.ASTNode
getNameEndOffset, getNameStartOffset
-
Methods inherited from interface org.fife.rsta.ac.java.rjc.ast.TypeDeclaration
getName, getTypeString
-
-
-
-
Field Detail
-
pkg
private Package pkg
-
modifiers
private Modifiers modifiers
-
parentType
private TypeDeclaration parentType
-
childTypes
private java.util.List<TypeDeclaration> childTypes
-
bodyStartOffs
private Offset bodyStartOffs
-
bodyEndOffs
private Offset bodyEndOffs
-
deprecated
private boolean deprecated
-
docComment
private java.lang.String docComment
-
memberList
private java.util.List<Member> memberList
-
-
Method Detail
-
addMember
public void addMember(Member member)
Adds a member to this type declaration.- Parameters:
member- The member to add.
-
addTypeDeclaration
public void addTypeDeclaration(TypeDeclaration type)
Description copied from interface:TypeDeclarationContainerAdds a type declaration to this container.- Specified by:
addTypeDeclarationin interfaceTypeDeclarationContainer- Parameters:
type- The new type declaration.
-
getBodyContainsOffset
public boolean getBodyContainsOffset(int offs)
Description copied from interface:TypeDeclarationReturns whether this type declaration contains the specified offset.- Specified by:
getBodyContainsOffsetin interfaceTypeDeclaration- Parameters:
offs- The offset to check.- Returns:
- Whether the offset is contained.
-
getBodyEndOffset
public int getBodyEndOffset()
Description copied from interface:TypeDeclarationReturns the end-offset of the type declaration's body.- Specified by:
getBodyEndOffsetin interfaceTypeDeclaration- Returns:
- The end offset.
- See Also:
TypeDeclaration.getBodyStartOffset()
-
getBodyStartOffset
public int getBodyStartOffset()
Description copied from interface:TypeDeclarationReturns the start-offset of the type declaration's body.- Specified by:
getBodyStartOffsetin interfaceTypeDeclaration- Returns:
- The start offset.
- See Also:
TypeDeclaration.getBodyEndOffset()
-
getChildType
public TypeDeclaration getChildType(int index)
Description copied from interface:TypeDeclarationReturns a child type by index.- Specified by:
getChildTypein interfaceTypeDeclaration- Parameters:
index- The index.- Returns:
- The child type.
- See Also:
TypeDeclaration.getChildTypeCount()
-
getChildTypeAtOffset
public TypeDeclaration getChildTypeAtOffset(int offs)
Description copied from interface:TypeDeclarationReturns the child type declaration of this one that contains the specified offset, if any.- Specified by:
getChildTypeAtOffsetin interfaceTypeDeclaration- Parameters:
offs- The offset.- Returns:
- The type declaration, or
nullif the offset is outside any child type declaration.
-
getChildTypeCount
public int getChildTypeCount()
Description copied from interface:TypeDeclarationReturns the number of child types.- Specified by:
getChildTypeCountin interfaceTypeDeclaration- Returns:
- The number of child types.
- See Also:
TypeDeclaration.getChildType(int)
-
getDocComment
public java.lang.String getDocComment()
Description copied from interface:TypeDeclarationReturns the doc comment for this type declaration.- Specified by:
getDocCommentin interfaceTypeDeclaration- Returns:
- The doc comment.
- See Also:
TypeDeclaration.setDocComment(String)
-
getFieldIterator
public java.util.Iterator<Field> getFieldIterator()
Description copied from interface:TypeDeclarationReturns an iterator over all fields defined in this type.- Specified by:
getFieldIteratorin interfaceTypeDeclaration- Returns:
- The iterator.
- See Also:
TypeDeclaration.getMethodIterator(),TypeDeclaration.getMemberIterator()
-
getMember
public Member getMember(int index)
Description copied from interface:TypeDeclarationReturns a member by index.- Specified by:
getMemberin interfaceTypeDeclaration- Parameters:
index- The index.- Returns:
- The member.
- See Also:
TypeDeclaration.getMemberCount(),TypeDeclaration.getMemberIterator()
-
getMemberCount
public int getMemberCount()
Description copied from interface:TypeDeclarationReturns the number of members in this type declaration.- Specified by:
getMemberCountin interfaceTypeDeclaration- Returns:
- The number of members.
- See Also:
TypeDeclaration.getMember(int),TypeDeclaration.getMemberIterator()
-
getMemberIterator
public java.util.Iterator<Member> getMemberIterator()
Description copied from interface:TypeDeclarationReturns an iterator over all members of this type. Note that an exception may be thrown if a method is added to this type while this iterator is being used.- Specified by:
getMemberIteratorin interfaceTypeDeclaration- Returns:
- The iterator.
- See Also:
TypeDeclaration.getMethodIterator(),TypeDeclaration.getMember(int),TypeDeclaration.getMemberCount()
-
getMethodIterator
public java.util.Iterator<Method> getMethodIterator()
Description copied from interface:TypeDeclarationReturns an iterator over all methods defined in this type.- Specified by:
getMethodIteratorin interfaceTypeDeclaration- Returns:
- The iterator.
- See Also:
TypeDeclaration.getFieldIterator(),TypeDeclaration.getMemberIterator()
-
getMethodsByName
public java.util.List<Method> getMethodsByName(java.lang.String name)
Description copied from interface:TypeDeclarationReturns all methods declared in this type with the given name. Does not check for methods with this name in subclasses.- Specified by:
getMethodsByNamein interfaceTypeDeclaration- Parameters:
name- The name to check for.- Returns:
- Any method overloads with that name, or an empty list if none.
-
getModifiers
public Modifiers getModifiers()
Description copied from interface:TypeDeclarationReturns the modifiers of this type declaration.- Specified by:
getModifiersin interfaceTypeDeclaration- Returns:
- The modifier list. This may be
nullif no modifiers were specified.
-
getName
public java.lang.String getName(boolean fullyQualified)
Description copied from interface:TypeDeclarationReturns the name of this type.- Specified by:
getNamein interfaceTypeDeclaration- Parameters:
fullyQualified- Whether the name returned should be fully qualified.- Returns:
- The type's name.
- See Also:
TypeDeclaration.getName()
-
getPackage
public Package getPackage()
Returns the package this type is in.- Specified by:
getPackagein interfaceTypeDeclaration- Returns:
- The package, or
nullif it's in the default package.
-
getParentType
public TypeDeclaration getParentType()
Returns the parent type declaration.- Specified by:
getParentTypein interfaceTypeDeclaration- Returns:
- The parent type declaration, or
nullif there isn't one. - See Also:
TypeDeclaration.setParentType(TypeDeclaration)
-
init
private void init()
-
isDeprecated
public boolean isDeprecated()
Description copied from interface:TypeDeclarationReturns whether this type declaration is deprecated.- Specified by:
isDeprecatedin interfaceTypeDeclaration- Returns:
- Whether this type declaration is deprecated.
-
isStatic
public boolean isStatic()
Shortcut forgetModifiers().isStatic(); useful sincegetModifiers()may returnnull.- Specified by:
isStaticin interfaceTypeDeclaration- Returns:
- Whether this type declaration is static.
- See Also:
TypeDeclaration.getModifiers()
-
setBodyEndOffset
public void setBodyEndOffset(Offset end)
-
setBodyStartOffset
public void setBodyStartOffset(Offset start)
-
setDeprecated
public void setDeprecated(boolean deprecated)
-
setDocComment
public void setDocComment(java.lang.String comment)
Description copied from interface:TypeDeclarationSets the doc comment for this type declaration.- Specified by:
setDocCommentin interfaceTypeDeclaration- Parameters:
comment- The new doc comment.- See Also:
TypeDeclaration.getDocComment()
-
setModifiers
public void setModifiers(Modifiers modifiers)
-
setPackage
public void setPackage(Package pkg)
Sets the package this type is in.- Parameters:
pkg- The package, ornullif this is in the default package.- See Also:
getPackage()
-
setParentType
public void setParentType(TypeDeclaration parentType)
Sets the parent type declaration for this type declaration.- Specified by:
setParentTypein interfaceTypeDeclaration- Parameters:
parentType- The parent type declaration.- See Also:
TypeDeclaration.getParentType()
-
toString
public java.lang.String toString()
Description copied from class:AbstractASTNodeReturns the name of this node (e.g. the value ofAbstractASTNode.getName()). Subclasses can override this method if appropriate.- Overrides:
toStringin classAbstractASTNode- Returns:
- A string representation of this node.
-
-