Source Code Cross Referenced for PageViewer.java in  » Web-Server » simple » simple » template » page » 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 » Web Server » simple » simple.template.page 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * PageViewer.java December 2003
003:         *
004:         * Copyright (C) 2003, Niall Gallagher <niallg@users.sf.net>
005:         *
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation.
009:         *
010:         * This library is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
013:         * GNU Lesser General Public License for more details.
014:         *
015:         * You should have received a copy of the GNU Lesser General 
016:         * Public License along with this library; if not, write to the 
017:         * Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
018:         * Boston, MA  02111-1307  USA
019:         */
020:
021:        package simple.template.page;
022:
023:        import simple.template.layout.Viewer;
024:        import simple.page.Model;
025:        import simple.page.Page;
026:        import java.io.PrintWriter;
027:
028:        /**
029:         * The <code>PageViewer</code> provides an implementation
030:         * of the <code>Viewer</code> interface. This provides a
031:         * simple that delegates directly to the <code>Page</code>
032:         * provides by the <cite>Page</code> templating system.
033:         * This provides all the methods nessecary to populate the
034:         * data source used and to render the template content.
035:         *
036:         * @author Niall Gallagher
037:         */
038:        final class PageViewer extends PageDatabase implements  Viewer {
039:
040:            /**
041:             * The template instance used to generate the content.
042:             */
043:            private Page page;
044:
045:            /**
046:             * Constructor for the <code>PageViewer</code> object.
047:             * This creates a viewer using the issued template object.
048:             * The viewer is initialized using the properties of the
049:             * issued <code>Model</code>. These properties can be
050:             * overridden without affecting the containers database.
051:             * 
052:             * @param page template object used to generate output
053:             * @param data properties used to configure the output 
054:             */
055:            public PageViewer(Page page, Model data) {
056:                this .data = data;
057:                this .page = page;
058:            }
059:
060:            /**
061:             * Displays the contents of the generated template output to
062:             * the issued <code>Writer</code>. This encapsulates the means
063:             * of rendering the template to a single method. Internally
064:             * the properties that are set within the document will be
065:             * used to configure the template, enabling dynamic output.
066:             * <p>
067:             * If there are any problems parsing the template or emitting
068:             * its contents an exception is thrown. However, if it is
069:             * successfully processed it will be written to the issued
070:             * output, which will remain unflushed for performance.
071:             *
072:             * @param out the output to write the template rendering to
073:             *
074:             * @throws Exception thrown if there is a problem parsing or 
075:             * emitting the template 
076:             */
077:            public void write(PrintWriter out) throws Exception {
078:                page.write(out, data);
079:            }
080:
081:            /**
082:             * This is used to acquire a HTTP Content-Type header, which
083:             * can be used to describe the contents of the viewer. This
084:             * will typically be the MIME type and character set of the
085:             * template, for example "text/html; charset=UTF-8". This is
086:             * provided so that the document can describe the type.
087:             *
088:             * @return this returns the content type of the contents
089:             */
090:            public String getContentType() {
091:                return page.getContentType();
092:            }
093:
094:            /**
095:             * This provides the character encoding of the page. This is
096:             * typically UTF-8, however it can be any supported character
097:             * encoding for the Java platform. This is used to ensure the
098:             * conversion from characters to bytes is known.
099:             * 
100:             * @return this returns the character encoding of the page
101:             */
102:            public String getCharset() {
103:                return page.getCharset();
104:            }
105:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.