Source Code Cross Referenced for ToHTMLConfig.java in  » Portal » jboss-portal-2.6.4 » org » jboss » portal » format » render » bbcodehtml » 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 » jboss portal 2.6.4 » org.jboss.portal.format.render.bbcodehtml 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /******************************************************************************
002:         * JBoss, a division of Red Hat                                               *
003:         * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
004:         * contributors as indicated by the @authors tag. See the                     *
005:         * copyright.txt in the distribution for a full listing of                    *
006:         * individual contributors.                                                   *
007:         *                                                                            *
008:         * This is free software; you can redistribute it and/or modify it            *
009:         * under the terms of the GNU Lesser General Public License as                *
010:         * published by the Free Software Foundation; either version 2.1 of           *
011:         * the License, or (at your option) any later version.                        *
012:         *                                                                            *
013:         * This software is distributed in the hope that it will be useful,           *
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
016:         * Lesser General Public License for more details.                            *
017:         *                                                                            *
018:         * You should have received a copy of the GNU Lesser General Public           *
019:         * License along with this software; if not, write to the Free                *
020:         * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
021:         * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
022:         ******************************************************************************/package org.jboss.portal.format.render.bbcodehtml;
023:
024:        import org.apache.log4j.Logger;
025:        import org.jboss.portal.format.template.BuildException;
026:        import org.jboss.portal.format.template.Template;
027:        import org.jboss.portal.format.template.TemplateLoader;
028:        import org.jboss.portal.format.template.TemplateRepository;
029:        import org.jboss.portal.format.util.CLLoader;
030:        import org.jboss.portal.format.util.Loader;
031:
032:        import java.util.HashSet;
033:        import java.util.Set;
034:
035:        /**
036:         */
037:        public class ToHTMLConfig {
038:
039:            /** Template name constants. */
040:
041:            public static final String TPL_THEME_CODE_B_CLOSE = "b_close";
042:            public static final String TPL_THEME_CODE_B_OPEN = "b_open";
043:            public static final String TPL_THEME_CODE_CODE_CLOSE = "code_close";
044:            public static final String TPL_THEME_CODE_CODE_OPEN = "code_open";
045:            public static final String TPL_THEME_CODE_COLOR_CLOSE = "color_close";
046:            public static final String TPL_THEME_CODE_COLOR_OPEN = "color_open";
047:            public static final String TPL_THEME_CODE_EMAIL = "email";
048:            public static final String TPL_THEME_CODE_I_CLOSE = "i_close";
049:            public static final String TPL_THEME_CODE_I_OPEN = "i_open";
050:            public static final String TPL_THEME_CODE_IMG = "img";
051:            public static final String TPL_THEME_CODE_LISTITEM = "listitem";
052:            public static final String TPL_THEME_CODE_OLIST_CLOSE = "olist_close";
053:            public static final String TPL_THEME_CODE_OLIST_OPEN = "olist_open";
054:            public static final String TPL_THEME_CODE_QUOTE_CLOSE = "quote_close";
055:            public static final String TPL_THEME_CODE_QUOTE_OPEN = "quote_open";
056:            public static final String TPL_THEME_CODE_QUOTE_USERNAME_OPEN = "quote_username_open";
057:            public static final String TPL_THEME_CODE_SIZE_CLOSE = "size_close";
058:            public static final String TPL_THEME_CODE_SIZE_OPEN = "size_open";
059:            public static final String TPL_THEME_CODE_U_CLOSE = "u_close";
060:            public static final String TPL_THEME_CODE_U_OPEN = "u_open";
061:            public static final String TPL_THEME_CODE_ULIST_CLOSE = "ulist_close";
062:            public static final String TPL_THEME_CODE_ULIST_OPEN = "ulist_open";
063:            public static final String TPL_THEME_CODE_URL = "url";
064:
065:            public static final int FILTER_MODE_ALWAYS_PRINT = 0;
066:            public static final int FILTER_MODE_NEVER_PRINT = 1;
067:            public static final int FILTER_MODE_PRINT_IF_NOT_IN_TAGS = 2;
068:            public static final int FILTER_MODE_PRINT_IF_IN_TAGS = 3;
069:
070:            public static final int OUTPUT_MODE_REMOVE = 0;
071:            public static final int OUTPUT_MODE_DISPLAY = 1;
072:
073:            private static final Loader loader = new CLLoader(
074:                    ToHTMLRenderer.class.getClassLoader(), "");
075:            private static final TemplateRepository defaultRepository = createRepository(loader);
076:
077:            Template r_ulist_open;
078:            Template r_ulist_close;
079:            Template r_olist_open;
080:            Template r_olist_close;
081:            Template r_listitem;
082:            Template r_quote_open;
083:            Template r_quote_close;
084:            Template r_quote_username_open;
085:            Template r_code_open;
086:            Template r_code_close;
087:            Template r_b_open;
088:            Template r_b_close;
089:            Template r_u_open;
090:            Template r_u_close;
091:            Template r_i_open;
092:            Template r_i_close;
093:            Template r_color_open;
094:            Template r_color_close;
095:            Template r_size_open;
096:            Template r_size_close;
097:            Template r_img;
098:            Template r_url;
099:            Template r_email;
100:
101:            private Set tags = new HashSet();
102:            private int filterMode = FILTER_MODE_ALWAYS_PRINT;
103:            private int ouputMode = OUTPUT_MODE_REMOVE;
104:            private int maxTextWidth = 100;
105:
106:            public ToHTMLConfig() {
107:                setRepository(defaultRepository);
108:            }
109:
110:            public void setLoader(Loader loader) {
111:                TemplateRepository repository = createRepository(loader);
112:                setRepository(repository);
113:            }
114:
115:            public int getMaxTextWidth() {
116:                return maxTextWidth;
117:            }
118:
119:            public void setMaxTextWidth(int maxTextWidth) {
120:                this .maxTextWidth = maxTextWidth;
121:            }
122:
123:            public void setTags(Set tags) {
124:                this .tags = tags;
125:            }
126:
127:            public Set getTags() {
128:                return tags;
129:            }
130:
131:            public int getFilterMode() {
132:                return filterMode;
133:            }
134:
135:            public void setFilterMode(int filterMode) {
136:                this .filterMode = filterMode;
137:            }
138:
139:            public int getOuputMode() {
140:                return ouputMode;
141:            }
142:
143:            public void setOuputMode(int ouputMode) {
144:                this .ouputMode = ouputMode;
145:            }
146:
147:            public boolean print(String tag) {
148:                switch (filterMode) {
149:                case FILTER_MODE_NEVER_PRINT:
150:                    return false;
151:                case FILTER_MODE_PRINT_IF_NOT_IN_TAGS:
152:                    return !tags.contains(tag);
153:                case FILTER_MODE_PRINT_IF_IN_TAGS:
154:                    return tags.contains(tag);
155:                case FILTER_MODE_ALWAYS_PRINT:
156:                    return true;
157:                }
158:                return false;
159:            }
160:
161:            private void setRepository(TemplateRepository repository) {
162:                r_ulist_open = repository
163:                        .createTemplate(TPL_THEME_CODE_ULIST_OPEN);
164:                r_ulist_close = repository
165:                        .createTemplate(TPL_THEME_CODE_ULIST_CLOSE);
166:                r_olist_open = repository
167:                        .createTemplate(TPL_THEME_CODE_OLIST_OPEN);
168:                r_olist_close = repository
169:                        .createTemplate(TPL_THEME_CODE_OLIST_CLOSE);
170:                r_listitem = repository.createTemplate(TPL_THEME_CODE_LISTITEM);
171:                r_quote_open = repository
172:                        .createTemplate(TPL_THEME_CODE_QUOTE_OPEN);
173:                r_quote_close = repository
174:                        .createTemplate(TPL_THEME_CODE_QUOTE_CLOSE);
175:                r_quote_username_open = repository
176:                        .createTemplate(TPL_THEME_CODE_QUOTE_USERNAME_OPEN);
177:                r_code_open = repository
178:                        .createTemplate(TPL_THEME_CODE_CODE_OPEN);
179:                r_code_close = repository
180:                        .createTemplate(TPL_THEME_CODE_CODE_CLOSE);
181:                r_b_open = repository.createTemplate(TPL_THEME_CODE_B_OPEN);
182:                r_b_close = repository.createTemplate(TPL_THEME_CODE_B_CLOSE);
183:                r_u_open = repository.createTemplate(TPL_THEME_CODE_U_OPEN);
184:                r_u_close = repository.createTemplate(TPL_THEME_CODE_U_CLOSE);
185:                r_i_open = repository.createTemplate(TPL_THEME_CODE_I_OPEN);
186:                r_i_close = repository.createTemplate(TPL_THEME_CODE_I_CLOSE);
187:                r_color_open = repository
188:                        .createTemplate(TPL_THEME_CODE_COLOR_OPEN);
189:                r_color_close = repository
190:                        .createTemplate(TPL_THEME_CODE_COLOR_CLOSE);
191:                r_size_open = repository
192:                        .createTemplate(TPL_THEME_CODE_SIZE_OPEN);
193:                r_size_close = repository
194:                        .createTemplate(TPL_THEME_CODE_SIZE_CLOSE);
195:                r_img = repository.createTemplate(TPL_THEME_CODE_IMG);
196:                r_url = repository.createTemplate(TPL_THEME_CODE_URL);
197:                r_email = repository.createTemplate(TPL_THEME_CODE_EMAIL);
198:            }
199:
200:            private static void loadTemplate(TemplateLoader repository,
201:                    String name) {
202:                try {
203:                    repository.addTemplate(name, "/" + name + ".tpl");
204:                } catch (BuildException e) {
205:                    Logger.getLogger(ToHTMLRenderer.class).error(
206:                            "Cannot load template : " + name, e);
207:                }
208:            }
209:
210:            private static TemplateLoader createRepository(Loader loader) {
211:                TemplateLoader repository = new TemplateLoader(loader);
212:                loadTemplate(repository, TPL_THEME_CODE_ULIST_OPEN);
213:                loadTemplate(repository, TPL_THEME_CODE_ULIST_CLOSE);
214:                loadTemplate(repository, TPL_THEME_CODE_OLIST_OPEN);
215:                loadTemplate(repository, TPL_THEME_CODE_OLIST_CLOSE);
216:                loadTemplate(repository, TPL_THEME_CODE_LISTITEM);
217:                loadTemplate(repository, TPL_THEME_CODE_QUOTE_OPEN);
218:                loadTemplate(repository, TPL_THEME_CODE_QUOTE_CLOSE);
219:                loadTemplate(repository, TPL_THEME_CODE_QUOTE_USERNAME_OPEN);
220:                loadTemplate(repository, TPL_THEME_CODE_CODE_OPEN);
221:                loadTemplate(repository, TPL_THEME_CODE_CODE_CLOSE);
222:                loadTemplate(repository, TPL_THEME_CODE_B_OPEN);
223:                loadTemplate(repository, TPL_THEME_CODE_B_CLOSE);
224:                loadTemplate(repository, TPL_THEME_CODE_U_OPEN);
225:                loadTemplate(repository, TPL_THEME_CODE_U_CLOSE);
226:                loadTemplate(repository, TPL_THEME_CODE_I_OPEN);
227:                loadTemplate(repository, TPL_THEME_CODE_I_CLOSE);
228:                loadTemplate(repository, TPL_THEME_CODE_COLOR_OPEN);
229:                loadTemplate(repository, TPL_THEME_CODE_COLOR_CLOSE);
230:                loadTemplate(repository, TPL_THEME_CODE_SIZE_OPEN);
231:                loadTemplate(repository, TPL_THEME_CODE_SIZE_CLOSE);
232:                loadTemplate(repository, TPL_THEME_CODE_IMG);
233:                loadTemplate(repository, TPL_THEME_CODE_URL);
234:                loadTemplate(repository, TPL_THEME_CODE_EMAIL);
235:                return repository;
236:            }
237:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.