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


001:        package de.tisje.java2html;
002:
003:        import java.io.File;
004:        import java.io.FileWriter;
005:        import java.io.IOException;
006:        import java.io.StringWriter;
007:
008:        import de.java2html.converter.AbstractJavaSourceToXmlConverter;
009:        import de.java2html.converter.JavaSource2XhtmlConverter;
010:        import de.java2html.converter.JavaSource2XmlConverter;
011:        import de.java2html.javasource.JavaSource;
012:        import de.java2html.javasource.JavaSourceParser;
013:        import de.java2html.options.JavaSourceConversionOptions;
014:        import de.java2html.util.IoUtilities;
015:
016:        /**
017:         * This class is an interface between XSL and Java2Html.
018:         * Before invoking, a namespace def must be added to the <code>xsl:stylesheet</code> tag:<br>
019:         * <code>xmlns:j2h="de.tisje.java2html.XsltTask"</code><br>
020:         * After that, it may be used this way:
021:         * <pre>
022:         *    &lt;xsl:value-of select="j2h:setSource(.)"/>
023:         *    &lt;xsl:value-of select="j2h:writeFile('temp.xml')"/>
024:         *    &lt;xsl:copy-of select="document('temp.xml')"/>
025:         * </pre>
026:         *
027:         * @author <a href="mailto:Jan.Tisje@gmx.de">Jan Tisje</a>
028:         * @version 1.0
029:         */
030:        //TODO Mar 11, 2004 (Markus Gebhard): This class urgently needs refactoring. Static instance variables - arg...
031:        public class XsltTask {
032:
033:            private static JavaSourceConversionOptions options = JavaSourceConversionOptions
034:                    .getDefault();
035:            private static AbstractJavaSourceToXmlConverter converter = new JavaSource2XhtmlConverter();
036:            private static JavaSource source = null;
037:            private static boolean xhtml = false;
038:
039:            /**
040:             * set options from xsl.
041:             * @param lineNumbers if line numbers should be in the output code.
042:             * @param pre if output code should be formatted using non-breaking spaces and &lt;br>.
043:             * @param xhtml if output should be viewable stand-alone.
044:             */
045:            public static void setOptions(boolean lineNumbers, boolean pre,
046:                    boolean xhtml) {
047:                if (xhtml) {
048:                    converter = new JavaSource2XhtmlConverter();
049:                } else {
050:                    converter = new JavaSource2XmlConverter();
051:                }
052:                converter.setOptions(lineNumbers, pre);
053:                XsltTask.xhtml = xhtml;
054:            }
055:
056:            /** hand over java source read from main xml file. */
057:            public static void setSource(String javaSource) {
058:                source = new JavaSourceParser().parse(javaSource);
059:            }
060:
061:            /** read java source from file. */
062:            public static void readFile(String javaFile) throws IOException {
063:                source = new JavaSourceParser().parse(new File(javaFile));
064:            }
065:
066:            /** return java source in text form, html codes will be escaped. */
067:            public static String getSource() throws IOException {
068:                StringWriter writer = new StringWriter();
069:                writer.write(converter.getDocumentHeader(options, "")); //$NON-NLS-1$
070:                converter.convert(source, options, writer);
071:                writer.write(converter.getDocumentFooter(options));
072:                return writer.getBuffer().toString();
073:            }
074:
075:            /** output file to a separate xml file, less problems. 
076:             * @deprecated As of Mar 11, 2004 (Markus Gebhard), replaced by {@link #writeFile(File)}*/
077:            public static void writeFile(String filename) throws IOException {
078:                writeFile(new File(filename));
079:            }
080:
081:            /** output file to a separate xml file */
082:            public static void writeFile(File file) throws IOException {
083:                FileWriter fileWriter = new FileWriter(file);
084:                try {
085:                    fileWriter.write(converter.getDocumentHeader(options, "")); //$NON-NLS-1$
086:                    converter.convert(source, options, fileWriter);
087:                    fileWriter.write(converter.getDocumentFooter(options));
088:                } finally {
089:                    IoUtilities.close(fileWriter);
090:                }
091:            }
092:
093:            /** use this class like a common comandline tool.
094:             changing of options is not supported, yet */
095:            public static void main(String args[]) {
096:                String ext = ".xhtml"; //$NON-NLS-1$
097:                if (!xhtml)
098:                    ext = ".xml"; //$NON-NLS-1$
099:                for (int i = 0; args.length > i; i++) {
100:                    try {
101:                        readFile(args[i]);
102:                        writeFile(args[i] + ext);
103:                    } catch (IOException e) {
104:                        e.printStackTrace();
105:                    }
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.