Source Code Cross Referenced for Scope.java in  » Code-Analyzer » checkstyle » com » puppycrawl » tools » checkstyle » api » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Code Analyzer » checkstyle » com.puppycrawl.tools.checkstyle.api 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        ////////////////////////////////////////////////////////////////////////////////
002:        // checkstyle: Checks Java source code for adherence to a set of rules.
003:        // Copyright (C) 2001-2007  Oliver Burn
004:        //
005:        // This library is free software; you can redistribute it and/or
006:        // modify it under the terms of the GNU Lesser General Public
007:        // License as published by the Free Software Foundation; either
008:        // version 2.1 of the License, or (at your option) any later version.
009:        //
010:        // This library is distributed in the hope that it will be useful,
011:        // but WITHOUT ANY WARRANTY; without even the implied warranty of
012:        // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013:        // Lesser General Public License for more details.
014:        //
015:        // You should have received a copy of the GNU Lesser General Public
016:        // License along with this library; if not, write to the Free Software
017:        // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
018:        ////////////////////////////////////////////////////////////////////////////////
019:        package com.puppycrawl.tools.checkstyle.api;
020:
021:        import java.io.Serializable;
022:        import java.util.HashMap;
023:        import java.util.Map;
024:
025:        /**
026:         * Represents a Java visibility scope.
027:         *
028:         * @author <a href="mailto:lkuehne@users.sourceforge.net">Lars Kühne</a>
029:         */
030:        public final class Scope implements  Comparable, Serializable {
031:            // Note that although this class might seem to be an
032:            // implementation detail, this class has to be public because it
033:            // is used as a parameter in GlobalProperties.setJavadocScope()
034:
035:            /** poor man's enum for nothing scope */
036:            private static final int SCOPECODE_NOTHING = 0;
037:            /** poor man's enum for public scope */
038:            private static final int SCOPECODE_PUBLIC = 1;
039:            /** poor man's enum for protected scope */
040:            private static final int SCOPECODE_PROTECTED = 2;
041:            /** poor man's enum for package scope */
042:            private static final int SCOPECODE_PACKAGE = 3;
043:            /** poor man's enum for private scope */
044:            private static final int SCOPECODE_PRIVATE = 4;
045:            /** poor man's enum for anonymous inner class scope */
046:            private static final int SCOPECODE_ANONINNER = 5;
047:
048:            /** none scopename */
049:            private static final String SCOPENAME_NOTHING = "nothing";
050:            /** public scopename */
051:            private static final String SCOPENAME_PUBLIC = "public";
052:            /** protected scopename */
053:            private static final String SCOPENAME_PROTECTED = "protected";
054:            /** package scopename */
055:            private static final String SCOPENAME_PACKAGE = "package";
056:            /** private scopename */
057:            private static final String SCOPENAME_PRIVATE = "private";
058:            /** anon inner scopename */
059:            private static final String SCOPENAME_ANONINNER = "anoninner";
060:
061:            /** nothing scope. */
062:            public static final Scope NOTHING = new Scope(SCOPECODE_NOTHING,
063:                    SCOPENAME_NOTHING);
064:
065:            /** public scope. */
066:            public static final Scope PUBLIC = new Scope(SCOPECODE_PUBLIC,
067:                    SCOPENAME_PUBLIC);
068:
069:            /** protected scope. */
070:            public static final Scope PROTECTED = new Scope(
071:                    SCOPECODE_PROTECTED, SCOPENAME_PROTECTED);
072:
073:            /** package scope. */
074:            public static final Scope PACKAGE = new Scope(SCOPECODE_PACKAGE,
075:                    SCOPENAME_PACKAGE);
076:
077:            /** private scope. */
078:            public static final Scope PRIVATE = new Scope(SCOPECODE_PRIVATE,
079:                    SCOPENAME_PRIVATE);
080:
081:            /** anon inner scope. */
082:            public static final Scope ANONINNER = new Scope(
083:                    SCOPECODE_ANONINNER, SCOPENAME_ANONINNER);
084:
085:            /** map from scope names to the respective Scope */
086:            private static final Map NAME_TO_SCOPE = new HashMap();
087:            static {
088:                NAME_TO_SCOPE.put(SCOPENAME_NOTHING, NOTHING);
089:                NAME_TO_SCOPE.put(SCOPENAME_PUBLIC, PUBLIC);
090:                NAME_TO_SCOPE.put(SCOPENAME_PROTECTED, PROTECTED);
091:                NAME_TO_SCOPE.put(SCOPENAME_PACKAGE, PACKAGE);
092:                NAME_TO_SCOPE.put(SCOPENAME_PRIVATE, PRIVATE);
093:                NAME_TO_SCOPE.put(SCOPENAME_ANONINNER, ANONINNER);
094:            }
095:
096:            /** the SCOPECODE_XYZ value of this scope. */
097:            private final int mCode;
098:
099:            /** the name of this scope. */
100:            private final String mName;
101:
102:            /**
103:             * {@inheritDoc}
104:             */
105:            public String toString() {
106:                return "Scope[" + mCode + " (" + mName + ")]";
107:            }
108:
109:            /**
110:             * @return the name of this scope.
111:             */
112:            public String getName() {
113:                return mName;
114:            }
115:
116:            /**
117:             * {@inheritDoc}
118:             */
119:            public int compareTo(Object aObject) {
120:                final Scope s = (Scope) aObject;
121:                return this .mCode - s.mCode;
122:            }
123:
124:            /**
125:             * Checks if this scope is a subscope of another scope.
126:             * Example: PUBLIC is a subscope of PRIVATE.
127:             *
128:             * @param aScope a <code>Scope</code> value
129:             * @return if <code>this</code> is a subscope of <code>aScope</code>.
130:             */
131:            public boolean isIn(Scope aScope) {
132:                return (compareTo(aScope) <= 0);
133:            }
134:
135:            /**
136:             * Creates a new <code>Scope</code> instance.
137:             *
138:             * @param aCode one of the SCOPECODE_XYZ values.
139:             * @param aName one of the SCOPENAME_XYZ values.
140:             */
141:            private Scope(int aCode, String aName) {
142:                mCode = aCode;
143:                mName = aName;
144:            }
145:
146:            /**
147:             * Scope factory method.
148:             *
149:             * @param aScopeName scope name, such as "nothing", "public", etc.
150:             * @return the <code>Scope</code> associated with <code>aScopeName</code>
151:             */
152:            public static Scope getInstance(String aScopeName) {
153:                // TODO: change scope....
154:                // canonicalize argument
155:                final String scopeName = aScopeName.trim().toLowerCase();
156:
157:                final Scope retVal = (Scope) NAME_TO_SCOPE.get(scopeName);
158:                if (retVal == null) {
159:                    throw new IllegalArgumentException(scopeName);
160:                }
161:                return retVal;
162:            }
163:
164:            /**
165:             * Ensures that we don't get multiple instances of one Scope
166:             * during deserialization. See Section 3.6 of the Java Object
167:             * Serialization Specification for details.
168:             *
169:             * @return the serialization replacement object
170:             */
171:            private Object readResolve() {
172:                return getInstance(mName);
173:            }
174:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.