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


001:        /*
002:         * Created on Jan 17, 2005 
003:         *
004:         * $Id: AbstractSunSecureRule.java 5018 2007-01-31 01:37:56Z xlv $
005:         */
006:        package net.sourceforge.pmd.rules.sunsecure;
007:
008:        import net.sourceforge.pmd.AbstractRule;
009:        import net.sourceforge.pmd.ast.ASTFieldDeclaration;
010:        import net.sourceforge.pmd.ast.ASTLocalVariableDeclaration;
011:        import net.sourceforge.pmd.ast.ASTName;
012:        import net.sourceforge.pmd.ast.ASTPrimarySuffix;
013:        import net.sourceforge.pmd.ast.ASTReturnStatement;
014:        import net.sourceforge.pmd.ast.ASTTypeDeclaration;
015:        import net.sourceforge.pmd.ast.ASTVariableDeclaratorId;
016:        import net.sourceforge.pmd.ast.SimpleNode;
017:
018:        import java.util.List;
019:
020:        /**
021:         * Utility methods for the package
022:         *
023:         * @author mgriffa
024:         */
025:        public abstract class AbstractSunSecureRule extends AbstractRule {
026:
027:            /**
028:             * Tells if the type declaration has a field with varName.
029:             *
030:             * @param varName         the name of the field to search
031:             * @param typeDeclaration the type declaration
032:             * @return <code>true</code> if there is a field in the type declaration named varName, <code>false</code> in other case
033:             */
034:            protected final boolean isField(String varName,
035:                    ASTTypeDeclaration typeDeclaration) {
036:                final List<ASTFieldDeclaration> fds = typeDeclaration
037:                        .findChildrenOfType(ASTFieldDeclaration.class);
038:                if (fds != null) {
039:                    for (ASTFieldDeclaration fd : fds) {
040:                        final ASTVariableDeclaratorId vid = fd
041:                                .getFirstChildOfType(ASTVariableDeclaratorId.class);
042:                        if (vid != null && vid.hasImageEqualTo(varName)) {
043:                            return true;
044:                        }
045:                    }
046:                }
047:                return false;
048:            }
049:
050:            /**
051:             * Gets the name of the variable returned.
052:             * Some examples: <br>
053:             * for this.foo returns foo <br>
054:             * for foo returns foo <br>
055:             * for foo.bar returns foo.bar
056:             *
057:             * @param ret a return statement to evaluate
058:             * @return the name of the variable associated or <code>null</code> if it cannot be detected
059:             */
060:            protected final String getReturnedVariableName(
061:                    ASTReturnStatement ret) {
062:                final ASTName n = ret.getFirstChildOfType(ASTName.class);
063:                if (n != null)
064:                    return n.getImage();
065:                final ASTPrimarySuffix ps = ret
066:                        .getFirstChildOfType(ASTPrimarySuffix.class);
067:                if (ps != null)
068:                    return ps.getImage();
069:                return null;
070:            }
071:
072:            /**
073:             * TODO modify usages to use symbol table
074:             * Tells if the variable name is a local variable declared in the method.
075:             *
076:             * @param vn   the variable name
077:             * @param node the ASTMethodDeclaration where the local variable name will be searched
078:             * @return <code>true</code> if the method declaration contains any local variable named vn and <code>false</code> in other case
079:             */
080:            protected boolean isLocalVariable(String vn, SimpleNode node) {
081:                final List<ASTLocalVariableDeclaration> lvars = node
082:                        .findChildrenOfType(ASTLocalVariableDeclaration.class);
083:                if (lvars != null) {
084:                    for (ASTLocalVariableDeclaration lvd : lvars) {
085:                        final ASTVariableDeclaratorId vid = lvd
086:                                .getFirstChildOfType(ASTVariableDeclaratorId.class);
087:                        if (vid != null && vid.hasImageEqualTo(vn)) {
088:                            return true;
089:                        }
090:                    }
091:                }
092:                return false;
093:            }
094:
095:            /**
096:             * Gets the image of the first ASTName node found by {@link SimpleNode#getFirstChildOfType(Class)}
097:             *
098:             * @param n the node to search
099:             * @return the image of the first ASTName or <code>null</code>
100:             */
101:            protected String getFirstNameImage(SimpleNode n) {
102:                ASTName name = n.getFirstChildOfType(ASTName.class);
103:                if (name != null)
104:                    return name.getImage();
105:                return null;
106:            }
107:
108:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.