Source Code Cross Referenced for CachingXHTMLSerializer.java in  » Portal » uPortal_rel-2-6-1-GA » org » jasig » portal » serialize » 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 » Portal » uPortal_rel 2 6 1 GA » org.jasig.portal.serialize 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.jasig.portal.serialize;
002:
003:        import java.io.IOException;
004:        import java.io.OutputStream;
005:        import java.io.UnsupportedEncodingException;
006:        import java.io.Writer;
007:
008:        /**
009:         * Caching version of the XHTML serializer
010:         * @author Peter Kharchenko
011:         * @author <a href="mailto:arkin@exoffice.com">Assaf Arkin</a>
012:         * @see Serializer
013:         */
014:        public final class CachingXHTMLSerializer extends XHTMLSerializer
015:                implements  CachingSerializer {
016:
017:            CharacterCachingWriter cacher;
018:            String encoding;
019:
020:            /**
021:             * Constructs a new serializer. The serializer cannot be used without
022:             * calling {@link #setOutputCharStream} or {@link #setOutputByteStream}
023:             * first.
024:             */
025:            public CachingXHTMLSerializer() {
026:                super (new OutputFormat(Method.XHTML, null, false));
027:            }
028:
029:            /**
030:             * Constructs a new serializer. The serializer cannot be used without
031:             * calling {@link #setOutputCharStream} or {@link #setOutputByteStream}
032:             * first.
033:             */
034:            public CachingXHTMLSerializer(OutputFormat format) {
035:                super (format != null ? format : new OutputFormat(Method.XHTML,
036:                        null, false));
037:                this .encoding = format.getEncoding();
038:            }
039:
040:            /**
041:             * Constructs a new serializer that writes to the specified writer
042:             * using the specified output format. If <tt>format</tt> is null,
043:             * will use a default output format.
044:             *
045:             * @param writer The writer to use
046:             * @param format The output format to use, null for the default
047:             */
048:            public CachingXHTMLSerializer(Writer writer, OutputFormat format) {
049:                super (format != null ? format : new OutputFormat(Method.XHTML,
050:                        null, false));
051:                CachingWriter cw = new CachingWriter(writer);
052:                this .cacher = cw;
053:                setOutputCharStream(cw);
054:                this .encoding = format.getEncoding();
055:            }
056:
057:            public void setOutputCharStream(Writer writer) {
058:                CachingWriter cw = new CachingWriter(writer);
059:                this .cacher = cw;
060:                super .setOutputCharStream(cw);
061:            }
062:
063:            /**
064:             * Constructs a new serializer that writes to the specified output
065:             * stream using the specified output format. If <tt>format</tt>
066:             * is null, will use a default output format.
067:             *
068:             * @param output The output stream to use
069:             * @param format The output format to use, null for the default
070:             */
071:            public CachingXHTMLSerializer(OutputStream output,
072:                    OutputFormat format) {
073:                super (format != null ? format : new OutputFormat(Method.XHTML,
074:                        null, false));
075:                CachingOutputStream cos = new CachingOutputStream(output);
076:                this .cacher = cos;
077:                setOutputByteStream(cos);
078:                this .encoding = format.getEncoding();
079:            }
080:
081:            public void setOutputByteStream(OutputStream output) {
082:                CachingOutputStream cos = new CachingOutputStream(output);
083:                this .cacher = cos;
084:                super .setOutputByteStream(cos);
085:            }
086:
087:            public void setOutputFormat(OutputFormat format) {
088:                super .setOutputFormat(format != null ? format
089:                        : new OutputFormat(Method.XHTML, null, false));
090:                this .encoding = format.getEncoding();
091:            }
092:
093:            // caching methods
094:
095:            /**
096:             * When starting caching if we are inside an opening tag the ">" will
097:             * be written in order for the ">" to be included with the correct cache.
098:             * 
099:             * Normally the serializer doesn't know if a ">" or "/>" should be written
100:             * until some content is received or the tag is closed. When starting
101:             * caching after an opening tag the tag will be assumed to have some content
102:             * and will write out the ">" before starting the cache.
103:             */
104:            public boolean startCaching() throws IOException {
105:                content();
106:                _printer.flush();
107:                return cacher.startCaching();
108:            }
109:
110:            /**
111:             * When stopping caching if we are inside an opening tag the ">" will
112:             * be written in order for the ">" to be included with the correct cache.
113:             * 
114:             * Normally the serializer doesn't know if a ">" or "/>" should be written
115:             * until some content is received or the tag is closed. When starting
116:             * caching after an opening tag the tag will be assumed to have some content
117:             * and will write out the ">" before starting the cache.
118:             */
119:            public boolean stopCaching() throws IOException {
120:                content();
121:                _printer.flush();
122:                return cacher.stopCaching();
123:            }
124:
125:            public String getCache() throws UnsupportedEncodingException,
126:                    IOException {
127:                _printer.flush();
128:                return cacher.getCache(this .encoding);
129:            }
130:
131:            /**
132:             * Allows one to print a <code>String</code> of characters directly to the output stream.
133:             *
134:             * @param text a <code>String</code> value
135:             */
136:            public void printRawCharacters(String text) throws IOException {
137:                content();
138:                _printer.printText(text);
139:                //        _printer.flush();
140:            }
141:
142:            /**
143:             * Let the serializer know if the document has already been started.
144:             *
145:             * @param setting a <code>boolean</code> value
146:             */
147:            public void setDocumentStarted(boolean setting) {
148:                _started = setting;
149:            }
150:
151:            public void flush() throws IOException {
152:                _printer.flush();
153:                cacher.flush();
154:            }
155:
156:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.