Source Code Cross Referenced for RuleContext.java in  » Code-Analyzer » pmd-4.2rc1 » net » sourceforge » pmd » 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 » pmd 4.2rc1 » net.sourceforge.pmd 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
003:         */package net.sourceforge.pmd;
004:
005:        import java.io.File;
006:        import java.util.Collections;
007:        import java.util.HashMap;
008:        import java.util.Map;
009:
010:        public class RuleContext {
011:
012:            private Report report = new Report();
013:            private File sourceCodeFile;
014:            private String sourceCodeFilename;
015:            private SourceType sourceType;
016:            private final Map<String, Object> attributes;
017:
018:            /**
019:             * Default constructor.
020:             */
021:            public RuleContext() {
022:                attributes = Collections
023:                        .synchronizedMap(new HashMap<String, Object>());
024:            }
025:
026:            /**
027:             * Constructor which shares attributes with the given RuleContext.
028:             */
029:            public RuleContext(RuleContext ruleContext) {
030:                this .attributes = ruleContext.attributes;
031:            }
032:
033:            public Report getReport() {
034:                return report;
035:            }
036:
037:            public void setReport(Report report) {
038:                this .report = report;
039:            }
040:
041:            public File getSourceCodeFile() {
042:                return sourceCodeFile;
043:            }
044:
045:            public void setSourceCodeFile(File sourceCodeFile) {
046:                this .sourceCodeFile = sourceCodeFile;
047:            }
048:
049:            public String getSourceCodeFilename() {
050:                return sourceCodeFilename;
051:            }
052:
053:            public void setSourceCodeFilename(String filename) {
054:                this .sourceCodeFilename = filename;
055:            }
056:
057:            public void excludeLines(Map<Integer, String> lines) {
058:                report.exclude(lines);
059:            }
060:
061:            public SourceType getSourceType() {
062:                return this .sourceType;
063:            }
064:
065:            public void setSourceType(SourceType t) {
066:                this .sourceType = t;
067:            }
068:
069:            /**
070:             * Set an attribute value on the RuleContext, if it does not already exist.
071:             * <p>
072:             * Attributes can be shared between RuleContext instances.  This operation
073:             * is thread-safe.
074:             * <p>
075:             * Attribute values should be modified directly via the reference provided.
076:             * It is not necessary to call <code>setAttribute(String, Object)</code> to
077:             * update an attribute value.  Modifications made to the attribute value
078:             * will automatically be seen by other threads.  Because of this, you must
079:             * ensure the attribute values are themselves thread safe.
080:             * 
081:             * @param name The attribute name.
082:             * @param value The attribute value.
083:             * @exception IllegalArgumentException if <code>name</code> or <code> value</code> are <code>null</code>
084:             * @return <code>true</code> if the attribute was set, <code>false</code> otherwise.
085:             */
086:            public boolean setAttribute(String name, Object value) {
087:                if (name == null) {
088:                    throw new IllegalArgumentException(
089:                            "Parameter 'name' cannot be null.");
090:                }
091:                if (value == null) {
092:                    throw new IllegalArgumentException(
093:                            "Parameter 'value' cannot be null.");
094:                }
095:                synchronized (this .attributes) {
096:                    if (!this .attributes.containsKey(name)) {
097:                        this .attributes.put(name, value);
098:                        return true;
099:                    } else {
100:                        return false;
101:                    }
102:                }
103:            }
104:
105:            /**
106:             * Get an attribute value on the RuleContext.
107:             * <p>
108:             * Attributes can be shared between RuleContext instances.  This operation
109:             * is thread-safe.
110:             * <p>
111:             * Attribute values should be modified directly via the reference provided.
112:             * It is not necessary to call <code>setAttribute(String, Object)</code> to
113:             * update an attribute value.  Modifications made to the attribute value
114:             * will automatically be seen by other threads.  Because of this, you must
115:             * ensure the attribute values are themselves thread safe.
116:             * 
117:             * @param name The attribute name.
118:             * @return The current attribute value, or <code>null</code> if the attribute does not exist.
119:             */
120:            public Object getAttribute(String name) {
121:                return this .attributes.get(name);
122:            }
123:
124:            /**
125:             * Remove an attribute value on the RuleContext.
126:             * <p>
127:             * Attributes can be shared between RuleContext instances.  This operation
128:             * is thread-safe.
129:             * <p>
130:             * Attribute values should be modified directly via the reference provided.
131:             * It is not necessary to call <code>setAttribute(String, Object)</code> to
132:             * update an attribute value.  Modifications made to the attribute value
133:             * will automatically be seen by other threads.  Because of this, you must
134:             * ensure the attribute values are themselves thread safe.
135:             * 
136:             * @param name The attribute name.
137:             * @return The current attribute value, or <code>null</code> if the attribute does not exist.
138:             */
139:            public Object removeAttribute(String name) {
140:                return this.attributes.remove(name);
141:            }
142:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.