Source Code Cross Referenced for A_CmsConfiguredHtmlParser.java in  » Content-Management-System » opencms » org » opencms » jsp » parse » 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 » Content Management System » opencms » org.opencms.jsp.parse 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * File   : $Source: /usr/local/cvs/opencms/src/org/opencms/jsp/parse/A_CmsConfiguredHtmlParser.java,v $
003:         * Date   : $Date: 2008-02-27 12:05:50 $
004:         * Version: $Revision: 1.7 $
005:         *
006:         * This library is part of OpenCms -
007:         * the Open Source Content Management System
008:         *
009:         * Copyright (c) 2002 - 2008 Alkacon Software GmbH (http://www.alkacon.com)
010:         *
011:         * This library is free software; you can redistribute it and/or
012:         * modify it under the terms of the GNU Lesser General Public
013:         * License as published by the Free Software Foundation; either
014:         * version 2.1 of the License, or (at your option) any later version.
015:         *
016:         * This library is distributed in the hope that it will be useful,
017:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
018:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019:         * Lesser General Public License for more details.
020:         *
021:         * For further information about Alkacon Software GmbH, please see the
022:         * company website: http://www.alkacon.com
023:         *
024:         * For further information about OpenCms, please see the
025:         * project website: http://www.opencms.org
026:         * 
027:         * You should have received a copy of the GNU Lesser General Public
028:         * License along with this library; if not, write to the Free Software
029:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
030:         */
031:
032:        package org.opencms.jsp.parse;
033:
034:        import org.opencms.file.CmsObject;
035:        import org.opencms.main.CmsException;
036:        import org.opencms.util.I_CmsHtmlNodeVisitor;
037:
038:        import java.util.List;
039:
040:        import org.htmlparser.util.ParserException;
041:
042:        /**
043:         * Base class for all classes that are specified for the <cms:parse parserClass="name"
044:         * param="config" /&gt; tag in the parserClass Attribute.<p>
045:         * 
046:         * Entry point for the tag implementation ({@link org.opencms.jsp.CmsJspTagParse}). The tag will
047:         * provide a valid {@link org.opencms.file.CmsObject} and it's configuration parameter String to
048:         * subclasses of this instances. Implementations just choose the type of
049:         * {@link org.opencms.util.I_CmsHtmlNodeVisitor} they will use for visiting the content to be
050:         * parsed.<p>
051:         * 
052:         * To implement a custom class that may be used with the <nobr>&lt;cms:parse parserClass="name"
053:         * param="config" /&gt;</nobr> tag the only thing that has to be done is to implement the method
054:         * {@link #createVisitorInstance()} and return the desired {@link org.opencms.util.I_CmsHtmlNodeVisitor} 
055:         * implementation.<p>
056:         * 
057:         * @author Achim Westermann
058:         * 
059:         * @version $Revision: 1.7 $
060:         * 
061:         * @since 6.1.7
062:         */
063:        public abstract class A_CmsConfiguredHtmlParser {
064:
065:            /** The internal cms object for accessing core functionality. */
066:            private CmsObject m_cmsObject;
067:
068:            /** The attribute value of the attribute param of the &lt;cms:parse&gt; tag. */
069:            private String m_param;
070:
071:            /** The internal visitor implementation that will do the parsing. */
072:            private I_CmsHtmlNodeVisitor m_visitor;
073:
074:            /**
075:             * Default constructor that initializes the internal visitor by using the abstract template
076:             * method {@link #createVisitorInstance()}.<p>
077:             */
078:            protected A_CmsConfiguredHtmlParser() {
079:
080:                // nop
081:            }
082:
083:            /**
084:             * Subclasses have to create their desired instance for parsing the html here.<p> 
085:             * 
086:             * You have access to {@link #getCmsObject()} and {@link #getParam()} already here and may pass those to
087:             * the visitor to return.<p>
088:             * 
089:             * @return the instance to be used for parsing the html
090:             * 
091:             * @throws CmsException if sth. goes wrong
092:             */
093:            protected abstract I_CmsHtmlNodeVisitor createVisitorInstance()
094:                    throws CmsException;
095:
096:            /**
097:             * Returns the result of subsequent parsing to the &lt;cms:parse&lt; tag implementation.<p>
098:             * 
099:             * @param encoding the encoding to use for parsing
100:             * @param html the html content to parse
101:             * @param noAutoCloseTags a list of upper case tag names for which parsing / visiting should not correct missing closing tags.
102:             * 
103:             * @return the result of subsequent parsing to the &lt;cms:parse&lt; tag implementation
104:             * 
105:             * @throws ParserException if sth. goes wrong at parsing
106:             * @throws CmsException if sth. goes wrong at accessing OpenCms core functionality
107:             */
108:            public String doParse(String html, String encoding,
109:                    List noAutoCloseTags) throws ParserException, CmsException {
110:
111:                m_visitor = createVisitorInstance();
112:                m_visitor.setNoAutoCloseTags(noAutoCloseTags);
113:                String result = "";
114:                m_visitor.process(html, encoding);
115:                result = m_visitor.getResult();
116:                // fool Checkstyle - we need to grant this exception for more complex subclasses that e.g.
117:                // have to be configured from VFS:
118:                if (false) {
119:                    throw new CmsException(null);
120:                }
121:                return result;
122:            }
123:
124:            /**
125:             * Returns the internal cms object for accessing core functionality.<p>
126:             * 
127:             * This value will be initialized by the &lt;cms:parse&gt; tag.<p>
128:             * 
129:             * @return the internal cms object for accessing core functionality
130:             */
131:            protected CmsObject getCmsObject() {
132:
133:                return m_cmsObject;
134:            }
135:
136:            /**
137:             * Returns the param.<p>
138:             * 
139:             * @return the param
140:             */
141:            protected String getParam() {
142:
143:                return m_param;
144:            }
145:
146:            /**
147:             * Returns the visitor.<p>
148:             * 
149:             * @return the visitor
150:             */
151:            protected I_CmsHtmlNodeVisitor getVisitor() {
152:
153:                return m_visitor;
154:            }
155:
156:            /**
157:             * Sets the internal cms object for accessing core functionality.<p>
158:             * 
159:             * This will be invokde by the &tl;cms:parse&gt; tag implementation.<p>
160:             * 
161:             * @param cmsObject the internal cms object for accessing core functionality to set
162:             */
163:            public void setCmsObject(CmsObject cmsObject) {
164:
165:                m_cmsObject = cmsObject;
166:            }
167:
168:            /**
169:             * The attribute value of the attribute param of the &lt;cms:parse&gt; tag.<p>
170:             * 
171:             * Will be set by the &lt;cms:parse&gt; implementation.<p>
172:             * 
173:             * @param param the param to set
174:             */
175:            public void setParam(String param) {
176:
177:                m_param = param;
178:            }
179:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.