Source Code Cross Referenced for RuleSetList.java in  » UML » jrefactory » org » acm » seguin » 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 » UML » jrefactory » org.acm.seguin.pmd 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.acm.seguin.pmd;
002:
003:        import org.acm.seguin.pmd.swingui.Resources;
004:
005:        import java.io.BufferedReader;
006:        import java.io.File;
007:        import java.io.FileNotFoundException;
008:        import java.io.FileReader;
009:        import java.io.FileWriter;
010:        import java.io.IOException;
011:        import java.io.PrintWriter;
012:        import java.util.StringTokenizer;
013:
014:        /**
015:         * Reads and writes a list of included rule sets.  Used by the PMD Viewer to select the
016:         * rule sets to be used during analysis.  The PMD Viewer provides the editing capability
017:         * to include or exclude rule sets.
018:         *
019:         * @author Donald A. Leckie
020:         * @since September 11, 2002
021:         * @version $Revision: 1.1 $, $Date: 2003/07/29 20:51:58 $
022:         */
023:        public class RuleSetList {
024:
025:            private static final String RULE_SET_LIST_FILE_NAME = "Included_Rule_Set_Names.txt";
026:
027:            /**
028:             ********************************************************************************
029:             *
030:             * @param directoryPath
031:             *
032:             * @return
033:             */
034:            public static final String[] getIncludedRuleSetNames(
035:                    String directoryPath) throws PMDException {
036:                String[] ruleSetNames = new String[0];
037:
038:                if (directoryPath != null) {
039:                    File file;
040:
041:                    directoryPath = directoryPath.trim();
042:                    file = new File(directoryPath + File.separator
043:                            + RULE_SET_LIST_FILE_NAME);
044:
045:                    if (file.exists()) {
046:                        BufferedReader inputStream = null;
047:
048:                        try {
049:                            String ruleSetNameList;
050:                            StringTokenizer parser;
051:                            int index;
052:
053:                            inputStream = new BufferedReader(new FileReader(
054:                                    file));
055:                            ruleSetNameList = inputStream.readLine();
056:                            parser = new StringTokenizer(ruleSetNameList, ",");
057:                            ruleSetNames = new String[parser.countTokens()];
058:                            index = 0;
059:
060:                            while (parser.hasMoreTokens()) {
061:                                ruleSetNames[index] = parser.nextToken().trim();
062:                                index++;
063:                            }
064:
065:                        } catch (FileNotFoundException exception) {
066:                            // Should not reach here because the file was already tested for existence.
067:                            String message;
068:                            PMDException pmdException;
069:
070:                            message = Resources
071:                                    .getString("RESOURCE_RuleSetListFileNotFound");
072:                            pmdException = new PMDException(message, exception);
073:                            pmdException.fillInStackTrace();
074:                            throw pmdException;
075:                        } catch (IOException exception) {
076:                            String message;
077:                            PMDException pmdException;
078:
079:                            message = Resources
080:                                    .getString("RESOURCE_RuleSetListFileIOError");
081:                            pmdException = new PMDException(message, exception);
082:                            pmdException.fillInStackTrace();
083:                            throw pmdException;
084:                        } finally {
085:                            if (inputStream != null) {
086:                                try {
087:                                    inputStream.close();
088:                                } catch (IOException exception) {
089:                                    // Ignore because the file is closed anyway.
090:                                    inputStream = null;
091:                                }
092:                            }
093:                        }
094:                    }
095:                }
096:
097:                return ruleSetNames;
098:            }
099:
100:            /**
101:             ********************************************************************************
102:             *
103:             * @param directoryPath
104:             *
105:             * @return
106:             */
107:            public static final void saveIncludedRuleSetNames(
108:                    String directoryPath, String[] ruleSetNames)
109:                    throws PMDException {
110:                if ((directoryPath != null) && (ruleSetNames != null)) {
111:                    File file;
112:
113:                    directoryPath = directoryPath.trim();
114:                    file = new File(directoryPath + File.separator
115:                            + RULE_SET_LIST_FILE_NAME);
116:
117:                    if (file.exists()) {
118:                        file.delete();
119:                    } else {
120:                        File directory = new File(directoryPath);
121:
122:                        directory.mkdirs();
123:                    }
124:
125:                    PrintWriter outputStream = null;
126:
127:                    try {
128:                        StringBuffer buffer;
129:
130:                        outputStream = new PrintWriter(new FileWriter(file));
131:                        buffer = new StringBuffer(100);
132:
133:                        for (int n = 0; n < ruleSetNames.length; n++) {
134:                            buffer.append(ruleSetNames[n]);
135:                            buffer.append(',');
136:                        }
137:
138:                        if (buffer.length() > 0) {
139:                            buffer.setLength(buffer.length() - 1);
140:                        }
141:
142:                        outputStream.println(buffer.toString());
143:                    } catch (FileNotFoundException exception) {
144:                        String message = Resources
145:                                .getString("RESOURCE_RuleSetListFileNotFound");
146:                        PMDException pmdException = new PMDException(message,
147:                                exception);
148:                        pmdException.fillInStackTrace();
149:                        throw pmdException;
150:                    } catch (IOException exception) {
151:                        String message;
152:                        PMDException pmdException;
153:
154:                        message = Resources
155:                                .getString("RESOURCE_RuleSetListFileIOError");
156:                        pmdException = new PMDException(message, exception);
157:                        pmdException.fillInStackTrace();
158:                        throw pmdException;
159:                    } finally {
160:                        if (outputStream != null) {
161:                            outputStream.close();
162:                        }
163:                    }
164:                }
165:            }
166:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.