Source Code Cross Referenced for Java2Html.java in  » Code-Analyzer » Java2Html » de » java2html » 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 » Java2Html » de.java2html 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package de.java2html;
002:
003:        import java.io.IOException;
004:        import java.io.StringReader;
005:        import java.io.StringWriter;
006:
007:        import de.java2html.commandline.IJava2HtmlConversion;
008:        import de.java2html.commandline.IllegalCommandlineParametersException;
009:        import de.java2html.commandline.Java2HtmlCommandline;
010:        import de.java2html.converter.IJavaSourceConverter;
011:        import de.java2html.javasource.JavaSource;
012:        import de.java2html.javasource.JavaSourceParser;
013:        import de.java2html.options.JavaSourceConversionOptions;
014:
015:        /**
016:         * A convenience class providing methods to use the Java2Html converter. By using this class you
017:         * will not have the ability to benefit from all the features of the Java2Html converter library.
018:         * However for most standard use cases the methods here will fit your needs.
019:         */
020:
021:        public class Java2Html {
022:            private Java2Html() {
023:                //nothing to do
024:            }
025:
026:            /** Converts the given <code>String</code> containing Java source code to HTML
027:             * by using the standard options of the converter.
028:             * Will return <code>null</code> if an error occures.
029:             * The result itself does not have &lt;html&gt; and &lt;/html&gt; tags and so
030:             * can be embedded in any HTML page.
031:             * 
032:             * @param javaSource The Java source code as plain text. 
033:             * @return A HTML representation of the Java source code or <code>null</code>
034:             *          if an error occures. 
035:             * @see #convertToHtml(String, JavaSourceConversionOptions) 
036:             * @see #convertToHtmlPage(String)
037:             */
038:            public static String convertToHtml(String javaSource) {
039:                return convertToHtml(javaSource,
040:                        (JavaSourceConversionSettings) null);
041:            }
042:
043:            /** Converts the given <code>String</code> containing Java source code to HTML
044:             * by using the given options for the converter.
045:             * Will return <code>null</code> if an error occures.
046:             * The result itself does not have &lt;html&gt; and &lt;/html&gt; tags and so
047:             * can be embedded in any HTML page.
048:             * 
049:             * @param javaSource The Java source code as plain text.
050:             * @param settings conversion options or <code>null</code> to use the standard options 
051:             * @return A HTML representation of the Java source code or <code>null</code>
052:             *          if an error occures. 
053:             * @see #convertToHtml(String)
054:             * @see #convertToHtmlPage(String, JavaSourceConversionSettings) 
055:             */
056:            public static String convertToHtml(String javaSource,
057:                    JavaSourceConversionSettings settings) {
058:                if (javaSource == null) {
059:                    return null;
060:                }
061:                if (settings == null) {
062:                    settings = JavaSourceConversionSettings.getDefault();
063:                }
064:
065:                StringReader stringReader = new StringReader(javaSource);
066:                JavaSource source = null;
067:                try {
068:                    source = new JavaSourceParser(settings
069:                            .getConversionOptions()).parse(stringReader);
070:                } catch (IOException e) {
071:                    return null;
072:                }
073:
074:                IJavaSourceConverter converter = settings.createConverter();
075:                StringWriter writer = new StringWriter();
076:                try {
077:                    converter.convert(source, settings.getConversionOptions(),
078:                            writer);
079:                } catch (IOException e) {
080:                    return null;
081:                }
082:                return writer.toString();
083:            }
084:
085:            /** Converts the given <code>String</code> containing Java source code to a complete
086:             * HTML page by using the standard options of the converter.
087:             * Will return <code>null</code> if an error occures.
088:             * 
089:             * @param javaSource The Java source code as plain text.
090:             * @return A HTML representation of the Java source code or <code>null</code>
091:             *          if an error occures. 
092:             * @see #convertToHtmlPage(String, JavaSourceConversionSettings)
093:             * @see #convertToHtml(String)
094:             */
095:            public static String convertToHtmlPage(String javaSource) {
096:                return convertToHtmlPage(javaSource,
097:                        (JavaSourceConversionSettings) null);
098:            }
099:
100:            /** Converts the given <code>String</code> containing Java source code to a complete
101:             * HTML page by using the given options for the converter.
102:             * Will return <code>null</code> if an error occures.
103:             * 
104:             * @param javaSource The Java source code as plain text.
105:             * @param settings conversion options or <code>null</code> to use the standard options 
106:             * @return A HTML representation of the Java source code or <code>null</code>
107:             *          if an error occures. 
108:             * @see #convertToHtmlPage(String)
109:             * @see #convertToHtmlPage(String, JavaSourceConversionSettings)
110:             */
111:            public static String convertToHtmlPage(String javaSource,
112:                    JavaSourceConversionSettings settings) {
113:                if (settings == null) {
114:                    settings = JavaSourceConversionSettings.getDefault();
115:                }
116:                IJavaSourceConverter converter = settings.createConverter();
117:                StringWriter writer = new StringWriter();
118:                try {
119:                    converter.writeDocumentHeader(writer, settings
120:                            .getConversionOptions(), ""); //$NON-NLS-1$
121:                    writer.write(convertToHtml(javaSource, settings));
122:                    converter.writeDocumentFooter(writer, settings
123:                            .getConversionOptions());
124:                } catch (IOException e) {
125:                    return null;
126:                }
127:                return writer.toString();
128:            }
129:
130:            /**
131:             * The commandline conversion from {@link Java2HtmlCommandline} 
132:             * can be invoked by running this class.
133:             */
134:            public static void main(String[] args) {
135:                IJava2HtmlConversion commandlineConversion = null;
136:                try {
137:                    commandlineConversion = Java2HtmlCommandline
138:                            .createCommandlineConversion(args);
139:                } catch (IllegalCommandlineParametersException exception) {
140:                    System.err.println("Illegal commandline parameters: "
141:                            + exception.getMessage());
142:                    Java2HtmlCommandline.printUsage();
143:                    System.exit(-1);
144:                }
145:                commandlineConversion.execute();
146:            }
147:
148:            public static String convertToHtml(String text,
149:                    JavaSourceConversionOptions options) {
150:                return convertToHtml(text, new JavaSourceConversionSettings(
151:                        options));
152:            }
153:
154:            public static String convertToHtmlPage(String text,
155:                    JavaSourceConversionOptions options) {
156:                return convertToHtmlPage(text,
157:                        new JavaSourceConversionSettings(options));
158:            }
159:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.