Source Code Cross Referenced for TagLibraryInfoImpl.java in  » Web-Server » jo » com » tagtraum » jo » jsp » tagext » 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 » jo » com.tagtraum.jo.jsp.tagext 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright © 2002-2005tagtraum industries.
003:         */
004:        package com.tagtraum.jo.jsp.tagext;
005:
006:        import com.tagtraum.framework.log.C_Log;
007:        import com.tagtraum.framework.log.Log;
008:        import com.tagtraum.framework.util.EntityResolverImpl;
009:        import com.tagtraum.jo.I_JoServletContextPeer;
010:        import com.tagtraum.jo.jsp.C_Jsp;
011:        import com.tagtraum.jo.jsp.GeneratorException;
012:        import org.w3c.dom.Document;
013:        import org.w3c.dom.DocumentType;
014:        import org.xml.sax.ErrorHandler;
015:        import org.xml.sax.SAXException;
016:        import org.xml.sax.SAXParseException;
017:
018:        import javax.servlet.jsp.tagext.TagExtraInfo;
019:        import javax.servlet.jsp.tagext.TagLibraryInfo;
020:        import javax.servlet.jsp.tagext.TagLibraryValidator;
021:        import javax.xml.parsers.DocumentBuilder;
022:        import javax.xml.parsers.DocumentBuilderFactory;
023:        import java.io.IOException;
024:        import java.net.URL;
025:
026:        /**
027:         *
028:         * @author <a href="mailto:hs@tagtraum.com">Hendrik Schreiber</a>
029:         * @version 1.1beta1 ($Revision: 1.10 $)
030:         */
031:        public class TagLibraryInfoImpl extends TagLibraryInfo implements  C_Jsp {
032:
033:            /**
034:             * Source-Version
035:             */
036:            public static String vcid = "$Id: TagLibraryInfoImpl.java,v 1.10 2005/03/15 20:09:43 hendriks73 Exp $";
037:            private static final String DTD_JSP_TAG_LIBRARY_1_1_PUBLIC_ID = "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN";
038:            private static final String DTD_JSP_TAG_LIBRARY_1_2_PUBLIC_ID = "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN";
039:            private static final String[] EMPTY_STRING_ARRAY = new String[0];
040:
041:            private I_JoServletContextPeer peer;
042:            private String[] listeners = EMPTY_STRING_ARRAY;
043:            private TagLibraryValidator tagLibraryValidator;
044:
045:            protected TagLibraryInfoImpl(String prefix, String uri,
046:                    I_JoServletContextPeer peer) {
047:                super (prefix, uri);
048:                this .peer = peer;
049:            }
050:
051:            public TagLibraryValidator getTagLibraryValidator() {
052:                return tagLibraryValidator;
053:            }
054:
055:            public void setTagLibraryValidator(
056:                    TagLibraryValidator tagLibraryValidator) {
057:                this .tagLibraryValidator = tagLibraryValidator;
058:            }
059:
060:            public String[] getListeners() {
061:                return listeners;
062:            }
063:
064:            public void setListeners(String[] listeners) {
065:                this .listeners = listeners;
066:            }
067:
068:            public I_JoServletContextPeer getPeer() {
069:                return peer;
070:            }
071:
072:            public static TagLibraryInfoImpl create(
073:                    I_JoServletContextPeer peer, URL url, String anURI,
074:                    String prefix) throws IOException {
075:                Document tld = null;
076:                try {
077:                    EntityResolverImpl resolver = new EntityResolverImpl();
078:                    ErrorHandler errorHandler = new SAXErrorHandler(Log
079:                            .getLog(peer.getHost().getName()), url);
080:                    URL stdTld1_1 = findResourceInJar(TagLibraryInfoImpl.class
081:                            .getName(),
082:                            "com/tagtraum/jo/jsp/tagext/web-jsptaglibrary_1_1.dtd");
083:                    resolver.put(DTD_JSP_TAG_LIBRARY_1_1_PUBLIC_ID, stdTld1_1);
084:                    URL stdTld1_2 = findResourceInJar(TagLibraryInfoImpl.class
085:                            .getName(),
086:                            "com/tagtraum/jo/jsp/tagext/web-jsptaglibrary_1_2.dtd");
087:                    resolver.put(DTD_JSP_TAG_LIBRARY_1_2_PUBLIC_ID, stdTld1_2);
088:                    // read TLD and build DOM
089:                    DocumentBuilderFactory xmlParserFactory = DocumentBuilderFactory
090:                            .newInstance();
091:                    // setValidating to true
092:                    xmlParserFactory.setValidating(true);
093:                    // setNamespaceAware to false
094:                    // xmlParserFactory.setNamespaceAware(false);
095:                    // get DocumentBuilder
096:                    DocumentBuilder xmlParser = xmlParserFactory
097:                            .newDocumentBuilder();
098:                    xmlParser.setEntityResolver(resolver);
099:                    xmlParser.setErrorHandler(errorHandler);
100:                    // get TLD DOM
101:                    tld = xmlParser.parse(url.openStream());
102:                } catch (Exception ex) {
103:                    ex.printStackTrace();
104:                    throw new GeneratorException(
105:                            "An error occured while parsing the TLD " + url
106:                                    + ": " + ex.toString());
107:                }
108:                DocumentType documentType = tld.getDoctype();
109:                String publicId = documentType.getPublicId();
110:                if (DTD_JSP_TAG_LIBRARY_1_1_PUBLIC_ID
111:                        .equalsIgnoreCase(publicId)) {
112:                    return new TagLibraryInfoImpl11(tld, peer, url, anURI,
113:                            prefix);
114:                } else if (DTD_JSP_TAG_LIBRARY_1_2_PUBLIC_ID
115:                        .equalsIgnoreCase(publicId)) {
116:                    return new TagLibraryInfoImpl12(tld, peer, url, anURI,
117:                            prefix);
118:                }
119:                throw new GeneratorException("Unknown TLD type: " + publicId);
120:            }
121:
122:            protected static final String trim(String toTrim) {
123:                if (toTrim == null) {
124:                    return null;
125:                }
126:                return toTrim.trim();
127:            }
128:
129:            protected static final boolean booleanValue(String val)
130:                    throws GeneratorException {
131:                if ("true".equals(val) || "yes".equals(val)) {
132:                    return true;
133:                }
134:                if ("false".equals(val) || "no".equals(val)) {
135:                    return false;
136:                }
137:                throw new GeneratorException(
138:                        "Malformed TLD. Expected element value true|false|yes|no but got: "
139:                                + val);
140:            }
141:
142:            public static URL findResourceInJar(String sibling, String name)
143:                    throws ClassNotFoundException {
144:                URL url = null;
145:                ClassLoader loader = Class.forName(sibling).getClassLoader();
146:                url = loader.getResource(name);
147:                return url;
148:            }
149:
150:            protected TagExtraInfo newInstance(String teiclass)
151:                    throws ClassNotFoundException, InstantiationException,
152:                    IllegalAccessException {
153:                Class teiclassClass = peer.getClassLoader().loadClass(teiclass);
154:                return (TagExtraInfo) teiclassClass.newInstance();
155:            }
156:
157:            protected static class SAXErrorHandler implements  ErrorHandler {
158:
159:                private Log log;
160:                private URL url;
161:
162:                public SAXErrorHandler(Log log, URL url) {
163:                    this .log = log;
164:                    this .url = url;
165:                }
166:
167:                public void warning(SAXParseException e) throws SAXException {
168:                    if (log.isLog(C_Log.VERBOSE)) {
169:                        log.log(getMessage(e), C_Log.VERBOSE);
170:                        log.log(e, C_Log.VERBOSE);
171:                    }
172:                }
173:
174:                public void error(SAXParseException e) throws SAXException {
175:                    if (log.isLog(C_Log.ERROR)) {
176:                        log.log(getMessage(e), C_Log.ERROR);
177:                        log.log(e, C_Log.VERBOSE);
178:                    }
179:                }
180:
181:                public void fatalError(SAXParseException e) throws SAXException {
182:                    if (log.isLog(C_Log.ERROR)) {
183:                        log.log(getMessage(e), C_Log.ERROR);
184:                        log.log(e, C_Log.ERROR);
185:                    }
186:                    throw e;
187:                }
188:
189:                private String getMessage(SAXParseException spe) {
190:                    return "A SAX parse error occured while parsing " + url
191:                            + " (line " + spe.getLineNumber() + "/column "
192:                            + spe.getColumnNumber() + "): "
193:                            + spe.getLocalizedMessage();
194:                }
195:            }
196:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.