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

Quick Search    Search Deep

com.puppycrawl.tools.checkstyle.api
Class Scope  view Scope download Scope.java

java.lang.Object
  extended bycom.puppycrawl.tools.checkstyle.api.Scope
All Implemented Interfaces:
java.lang.Comparable, java.io.Serializable

public final class Scope
extends java.lang.Object
implements java.lang.Comparable, java.io.Serializable

Represents a Java visibility scope.


Field Summary
static Scope ANONINNER
          anon inner scope.
private  int mCode
          the SCOPECODE_XYZ value of this scope.
private  java.lang.String mName
          the name of this scope.
private static java.util.Map NAME_TO_SCOPE
          map from scope names to the respective Scope
static Scope NOTHING
          nothing scope.
static Scope PACKAGE
          package scope.
static Scope PRIVATE
          private scope.
static Scope PROTECTED
          protected scope.
static Scope PUBLIC
          public scope.
private static int SCOPECODE_ANONINNER
          poor man's enum for anonymous inner class scope
private static int SCOPECODE_NOTHING
          poor man's enum for nothing scope
private static int SCOPECODE_PACKAGE
          poor man's enum for package scope
private static int SCOPECODE_PRIVATE
          poor man's enum for private scope
private static int SCOPECODE_PROTECTED
          poor man's enum for protected scope
private static int SCOPECODE_PUBLIC
          poor man's enum for public scope
private static java.lang.String SCOPENAME_ANONINNER
          anon inner scopename
private static java.lang.String SCOPENAME_NOTHING
          none scopename
private static java.lang.String SCOPENAME_PACKAGE
          package scopename
private static java.lang.String SCOPENAME_PRIVATE
          private scopename
private static java.lang.String SCOPENAME_PROTECTED
          protected scopename
private static java.lang.String SCOPENAME_PUBLIC
          public scopename
 
Constructor Summary
private Scope(int aCode, java.lang.String aName)
          Creates a new Scope instance.
 
Method Summary
 int compareTo(java.lang.Object aObject)
          Compares this object with another, and returns a numerical result based on the comparison.
static Scope getInstance(java.lang.String aScopeName)
          Scope factory method.
 java.lang.String getName()
           
 boolean isIn(Scope aScope)
          Checks if this scope is a subscope of another scope.
private  java.lang.Object readResolve()
          Ensures that we don't get multiple instances of one Scope during deserialization.
 java.lang.String toString()
          Convert this Object to a human-readable String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SCOPECODE_NOTHING

private static final int SCOPECODE_NOTHING
poor man's enum for nothing scope

See Also:
Constant Field Values

SCOPECODE_PUBLIC

private static final int SCOPECODE_PUBLIC
poor man's enum for public scope

See Also:
Constant Field Values

SCOPECODE_PROTECTED

private static final int SCOPECODE_PROTECTED
poor man's enum for protected scope

See Also:
Constant Field Values

SCOPECODE_PACKAGE

private static final int SCOPECODE_PACKAGE
poor man's enum for package scope

See Also:
Constant Field Values

SCOPECODE_PRIVATE

private static final int SCOPECODE_PRIVATE
poor man's enum for private scope

See Also:
Constant Field Values

SCOPECODE_ANONINNER

private static final int SCOPECODE_ANONINNER
poor man's enum for anonymous inner class scope

See Also:
Constant Field Values

SCOPENAME_NOTHING

private static final java.lang.String SCOPENAME_NOTHING
none scopename

See Also:
Constant Field Values

SCOPENAME_PUBLIC

private static final java.lang.String SCOPENAME_PUBLIC
public scopename

See Also:
Constant Field Values

SCOPENAME_PROTECTED

private static final java.lang.String SCOPENAME_PROTECTED
protected scopename

See Also:
Constant Field Values

SCOPENAME_PACKAGE

private static final java.lang.String SCOPENAME_PACKAGE
package scopename

See Also:
Constant Field Values

SCOPENAME_PRIVATE

private static final java.lang.String SCOPENAME_PRIVATE
private scopename

See Also:
Constant Field Values

SCOPENAME_ANONINNER

private static final java.lang.String SCOPENAME_ANONINNER
anon inner scopename

See Also:
Constant Field Values

NOTHING

public static final Scope NOTHING
nothing scope.


PUBLIC

public static final Scope PUBLIC
public scope.


PROTECTED

public static final Scope PROTECTED
protected scope.


PACKAGE

public static final Scope PACKAGE
package scope.


PRIVATE

public static final Scope PRIVATE
private scope.


ANONINNER

public static final Scope ANONINNER
anon inner scope.


NAME_TO_SCOPE

private static final java.util.Map NAME_TO_SCOPE
map from scope names to the respective Scope


mCode

private final int mCode
the SCOPECODE_XYZ value of this scope.


mName

private final java.lang.String mName
the name of this scope.

Constructor Detail

Scope

private Scope(int aCode,
              java.lang.String aName)
Creates a new Scope instance.

Method Detail

toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).


getName

public java.lang.String getName()

compareTo

public int compareTo(java.lang.Object aObject)
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

isIn

public boolean isIn(Scope aScope)
Checks if this scope is a subscope of another scope. Example: PUBLIC is a subscope of PRIVATE.


getInstance

public static Scope getInstance(java.lang.String aScopeName)
Scope factory method.


readResolve

private java.lang.Object readResolve()
Ensures that we don't get multiple instances of one Scope during deserialization. See Section 3.6 of the Java Object Serialization Specification for details.