Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.puppycrawl.tools.checkstyle.checks.usage.transmogrify
Class Definition  view Definition download Definition.java

java.lang.Object
  extended bycom.puppycrawl.tools.checkstyle.checks.usage.transmogrify.Definition
All Implemented Interfaces:
java.lang.Comparable, IDefinition
Direct Known Subclasses:
LabelDef, Scope, VariableDef

public abstract class Definition
extends java.lang.Object
implements IDefinition, java.lang.Comparable

Definition contains basic information for everything that is defined in a java source file. A definition has a list of References, an Occurrence, a name, and a parent Scope.


Field Summary
private  java.lang.String _name
           
private  SymTabAST _node
           
private  Occurrence _occurrence
           
private  Scope _parentScope
           
private  java.util.SortedSet _references
           
 
Constructor Summary
Definition(java.lang.String name, Scope parentScope, SymTabAST node)
           
 
Method Summary
 void addReference(Reference reference)
          Adds a Reference to the collection of References
 int compareTo(java.lang.Object o)
          Compares this object with another, and returns a numerical result based on the comparison.
 ClassDef getEnclosingClass()
          Returns the ClassDef that this scope is contained in.
 IPackage getEnclosingPackage()
           
 java.lang.String getName()
          returns the name of the definition
 int getNumReferences()
          gets the number of references refer to by this definition
 Occurrence getOccurrence()
          Returns the Occurrence for the location of this definition
 Scope getParentScope()
          Returns the scope in which this definition is defined
 java.lang.String getQualifiedName()
          returns the fully qualifed name of this defintion.
 java.util.Iterator getReferences()
          Returns the References to this definition
 SymTabAST getTreeNode()
          returns the node in the AST that represents this definition
 boolean isSourced()
          verifies if this definition node is source/non-sourced(with no source-code)
 java.lang.String toString()
          returns a String representation of the definition.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_name

private java.lang.String _name

_parentScope

private Scope _parentScope

_node

private SymTabAST _node

_references

private java.util.SortedSet _references

_occurrence

private Occurrence _occurrence
Constructor Detail

Definition

public Definition(java.lang.String name,
                  Scope parentScope,
                  SymTabAST node)
Method Detail

isSourced

public boolean isSourced()
Description copied from interface: IDefinition
verifies if this definition node is source/non-sourced(with no source-code)

Specified by:
isSourced in interface IDefinition

getName

public java.lang.String getName()
returns the name of the definition

Specified by:
getName in interface IDefinition

getTreeNode

public SymTabAST getTreeNode()
returns the node in the AST that represents this definition


addReference

public void addReference(Reference reference)
Adds a Reference to the collection of References

Specified by:
addReference in interface IDefinition

getReferences

public java.util.Iterator getReferences()
Returns the References to this definition

Specified by:
getReferences in interface IDefinition

getNumReferences

public int getNumReferences()
Description copied from interface: IDefinition
gets the number of references refer to by this definition

Specified by:
getNumReferences in interface IDefinition

getParentScope

public Scope getParentScope()
Returns the scope in which this definition is defined


getQualifiedName

public java.lang.String getQualifiedName()
returns the fully qualifed name of this defintion. The name of the parentScope and all of its parents are considered when constructing this name.

Specified by:
getQualifiedName in interface IDefinition

getOccurrence

public Occurrence getOccurrence()
Returns the Occurrence for the location of this definition


getEnclosingClass

public ClassDef getEnclosingClass()
Returns the ClassDef that this scope is contained in.


getEnclosingPackage

public IPackage getEnclosingPackage()

toString

public java.lang.String toString()
returns a String representation of the definition. This string includes the class of the defintion and its qualified name


compareTo

public int compareTo(java.lang.Object o)
Description copied from interface: java.lang.Comparable
Compares this object with another, and returns a numerical result based on the comparison. If the result is negative, this object sorts less than the other; if 0, the two are equal, and if positive, this object sorts greater than the other. To translate this into boolean, simply perform o1.compareTo(o2) <op> 0, where op is one of <, <=, =, !=, >, or >=.

You must make sure that the comparison is mutual, ie. sgn(x.compareTo(y)) == -sgn(y.compareTo(x)) (where sgn() is defined as -1, 0, or 1 based on the sign). This includes throwing an exception in either direction if the two are not comparable; hence, compareTo(null) should always throw an Exception.

You should also ensure transitivity, in two forms: x.compareTo(y) > 0 && y.compareTo(z) > 0 implies x.compareTo(z) > 0; and x.compareTo(y) == 0 implies x.compareTo(z) == y.compareTo(z).

Specified by:
compareTo in interface java.lang.Comparable