Source Code Cross Referenced for Deprecator.java in  » Internationalization-Localization » icu4j » com » ibm » icu » dev » tool » docs » 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 » Internationalization Localization » icu4j » com.ibm.icu.dev.tool.docs 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         *******************************************************************************
003:         * Copyright (C) 2005, International Business Machines Corporation and         *
004:         * others. All Rights Reserved.                                                *
005:         *******************************************************************************
006:         */package com.ibm.icu.dev.tool.docs;
007:
008:        import java.io.File;
009:        import java.io.FilenameFilter;
010:        import java.io.PrintWriter;
011:        import java.io.BufferedReader;
012:        import java.io.InputStreamReader;
013:        import java.io.FileInputStream;
014:        import java.util.regex.*;
015:
016:        public final class Deprecator {
017:            private boolean undep;
018:            private int log;
019:
020:            Deprecator(boolean undep, int log) {
021:                this .undep = undep;
022:                this .log = log;
023:            }
024:
025:            public static void main(String[] args) {
026:                String srcPath = null;
027:                String dstPath = null;
028:                boolean undep = false;
029:
030:                int log = 1;
031:                boolean help = false;
032:                StringBuffer err = new StringBuffer();
033:
034:                for (int i = 0; i < args.length; ++i) {
035:                    String arg = args[i];
036:                    if (arg.equals("-src")) {
037:                        srcPath = args[++i];
038:                    } else if (arg.equals("-dst")) {
039:                        dstPath = args[++i];
040:                    } else if (arg.equals("-undep")) {
041:                        undep = true;
042:                    } else if (arg.equals("-help")) {
043:                        help = true;
044:                    } else if (arg.equals("-silent")) {
045:                        log = 0;
046:                    } else if (arg.equals("-log")) {
047:                        log = 2;
048:                    } else if (arg.equals("-logfiles")) {
049:                        log = 3;
050:                    } else if (arg.equals("-verbose")) {
051:                        log = 4;
052:                    } else {
053:                        err.append("\nunrecognized argument: " + arg);
054:                    }
055:                }
056:
057:                File srcDir = null;
058:                File dstDir = null;
059:
060:                if (srcPath == null) {
061:                    err.append("\nsrc must be defined");
062:                } else {
063:                    srcDir = new File(srcPath);
064:                    if (!(srcDir.exists() && srcDir.isDirectory())) {
065:                        err.append("\nsrc must be an existing directory: '"
066:                                + srcPath + "'");
067:                    }
068:                }
069:                if (dstPath == null) {
070:                    err.append("\ndst must be defined");
071:                } else {
072:                    dstDir = new File(dstPath);
073:                    if (!dstDir.exists()) {
074:                        if (!dstDir.mkdirs()) {
075:                            err.append("\nunable to create dst: '" + dstPath
076:                                    + "'");
077:                        }
078:                    } else if (!dstDir.isDirectory()) {
079:                        err.append("\ndst exists but is not directory: '"
080:                                + dstPath + "'");
081:                    }
082:                }
083:
084:                if (help || err.length() > 0) {
085:                    if (!help) {
086:                        System.err.println("Error: " + err.toString());
087:                    }
088:                    usage();
089:                    return;
090:                }
091:
092:                try {
093:                    if (log > 0) {
094:                        System.out.println("src: " + srcDir.getCanonicalPath());
095:                        System.out.println("dst: " + dstDir.getCanonicalPath());
096:                        System.out.println("undep: " + undep);
097:                        System.out.flush();
098:                    }
099:
100:                    new Deprecator(undep, log).process(srcDir, dstDir);
101:
102:                    if (log > 0) {
103:                        System.out.println("done");
104:                        System.out.flush();
105:                    }
106:                } catch (Exception e) {
107:                    System.err.println("Unexpected error: " + e);
108:                }
109:            }
110:
111:            static void usage() {
112:                PrintWriter pw = new PrintWriter(System.out);
113:                pw.println("Usage: Deprecator -src path -dst path [-help]");
114:                pw
115:                        .println("  -src path : the root of the tree of files to work on");
116:                pw
117:                        .println("  -dst path : the root of the tree to put the resulting files");
118:                pw
119:                        .println("  -help     : print this usage message and exit, doing nothing");
120:                pw
121:                        .println("  -undep    : remove deprecation tags if present (default false)");
122:                pw.println();
123:                pw
124:                        .println("  Add or remove warning deprecations for ICU @draft and @internal APIs");
125:                pw.flush();
126:            }
127:
128:            static final String stoplist = "!CVS";
129:            static final FilenameFilter ff = new FilenameFilter() {
130:                public boolean accept(File dir, String name) {
131:                    if (name.endsWith(".java"))
132:                        return true;
133:                    if (new File(dir, name).isDirectory()) {
134:                        if (stoplist.indexOf("!" + name) == -1) {
135:                            return true;
136:                        }
137:                    }
138:                    return false;
139:                }
140:            };
141:
142:            void process(File srcDir, File dstDir) {
143:                File[] files = srcDir.listFiles(ff);
144:                for (int i = 0; i < files.length; ++i) {
145:                    File f = files[i];
146:                    File d = new File(dstDir, f.getName());
147:                    if (f.isDirectory()) {
148:                        if (!d.exists()) {
149:                            if (!d.mkdir()) {
150:                                System.err.println("cannot create directory: "
151:                                        + d.getPath());
152:                                continue;
153:                            }
154:                        } else if (!d.isDirectory()) {
155:                            System.err
156:                                    .println("file already exists but is not directory: "
157:                                            + d.getPath());
158:                            continue;
159:                        }
160:                        if (log > 1) {
161:                            System.out.println("process dir: " + f.getPath());
162:                        }
163:                        process(f, d);
164:                    } else {
165:                        processFile(f, d);
166:                    }
167:                }
168:            }
169:
170:            /*
171:            @ deprecated
172:             *** @deprecated
173:             ** ** ** @deprecated
174:             */
175:            static final Pattern pat = Pattern
176:                    .compile("^[\\s*]*@\\s*deprecated.*");
177:
178:            void processFile(File srcFile, File dstFile) {
179:                if (log > 2) {
180:                    System.out.println("process '" + srcFile.getPath() + "'");
181:                }
182:
183:                try {
184:                    BufferedReader r = new BufferedReader(
185:                            new InputStreamReader(new FileInputStream(srcFile)));
186:                    int n = 0;
187:                    String line = null;
188:                    while (null != (line = r.readLine())) {
189:                        ++n;
190:                        Matcher m = pat.matcher(line);
191:                        if (m.matches()) {
192:                            if (log > 3) {
193:                                System.out.println(String.valueOf(n) + ": "
194:                                        + line);
195:                            }
196:                        }
197:                    }
198:                    r.close();
199:                } catch (Exception e) {
200:                    System.out.flush();
201:                    System.err.println("caught exception: " + e);
202:                }
203:            }
204:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.