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