Source Code Cross Referenced for SAXUtil.java in  » Workflow-Engines » wfmopen-2.1.1 » de » danet » an » util » sax » 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 » Workflow Engines » wfmopen 2.1.1 » de.danet.an.util.sax 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * This file is part of the WfMOpen project.
003:         * Copyright (C) 2001-2003 Danet GmbH (www.danet.de), GS-AN.
004:         * All rights reserved.
005:         *
006:         * This program is free software; you can redistribute it and/or modify
007:         * it under the terms of the GNU General Public License as published by
008:         * the Free Software Foundation; either version 2 of the License, or
009:         * (at your option) any later version.
010:         *
011:         * This program is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014:         * GNU General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU General Public License
017:         * along with this program; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
019:         *
020:         * $Id: SAXUtil.java,v 1.2 2006/09/29 12:32:11 drmlipp Exp $
021:         *
022:         * $Log: SAXUtil.java,v $
023:         * Revision 1.2  2006/09/29 12:32:11  drmlipp
024:         * Consistently using WfMOpen as projct name now.
025:         *
026:         * Revision 1.1.1.1  2003/06/30 20:05:12  drmlipp
027:         * Initial import
028:         *
029:         * Revision 1.3  2003/06/27 08:51:46  lipp
030:         * Fixed copyright/license information.
031:         *
032:         * Revision 1.2  2003/04/25 14:50:59  lipp
033:         * Fixed javadoc errors and warnings.
034:         *
035:         * Revision 1.1  2002/08/30 11:00:10  huaiyang
036:         * Help functions for SAXGenerator.
037:         *
038:         *
039:         */
040:        package de.danet.an.util.sax;
041:
042:        import org.xml.sax.Attributes;
043:        import org.xml.sax.ContentHandler;
044:        import org.xml.sax.SAXException;
045:        import org.xml.sax.helpers.AttributesImpl;
046:
047:        /**
048:         * The <code>SAXUtil</code> provides help functions for generating SAX
049:         * events. 
050:         */
051:        public class SAXUtil {
052:
053:            //
054:            // Helper methods
055:            //
056:
057:            /**
058:             * Generate all notifications corresponding to an XML element
059:             * with the given name and parameters that has the given
060:             * text as content.
061:             *
062:             * @param contentHandler the content handler.
063:             * @param elementName the unqualified element name.
064:             * @param attrs optional attributes (may not be <code>null</code>).
065:             * @param text the content.
066:             * @throws SAXException if a general SAX error or warning occurs.
067:             */
068:            public static void textElement(ContentHandler contentHandler,
069:                    String elementName, Attributes attrs, String text)
070:                    throws SAXException {
071:                contentHandler
072:                        .startElement("", elementName, elementName, attrs);
073:                if (text != null) {
074:                    contentHandler.characters(text.toCharArray(), 0, text
075:                            .length());
076:                }
077:                contentHandler.endElement("", elementName, elementName);
078:            }
079:
080:            /**
081:             * Generate a "dialog hint node", i.e. a hint how a node's
082:             * attribute or a node's value is to be represented in a dialog.
083:             *
084:             * @param contentHandler main interface that most SAX applications 
085:             * implement. It will receive notification of the logic content of a
086:             * document.
087:             * @param attribute the name of the node's attribute which is 
088:             * attributed by the dialog hint. This parameter may be
089:             * <code>null</code> if the dialog hint applies to the value of the node.
090:             * @param type the type attribute of the dialog hint node.
091:             * @param maxlength the maximum length of the attribute or node value.
092:             * @throws SAXException if a general SAX error or warning occurs.
093:             */
094:            public static void generateDialogHint(
095:                    ContentHandler contentHandler, String attribute,
096:                    String type, int maxlength) throws SAXException {
097:                AttributesImpl attrs = new AttributesImpl();
098:                if (attribute != null) {
099:                    attrs.addAttribute("", "attribute", "attribute", "CDATA",
100:                            attribute);
101:                }
102:                attrs.addAttribute("", "type", "type", "CDATA", type);
103:                attrs.addAttribute("", "maxlength", "maxlength", "CDATA",
104:                        Integer.toString(maxlength));
105:                contentHandler.startElement("", "dialog-hint", "dialog-hint",
106:                        attrs);
107:                contentHandler.endElement("", "dialog-hint", "dialog-hint");
108:            }
109:
110:            /**
111:             * Generate a "dialog hint node", i.e. a hint how a node's
112:             * attribute or a node's value is to be represented in a dialog.
113:             *
114:             * @param contentHandler main interface that most SAX applications 
115:             * implement. It will receive notification of the logic content of a
116:             * document.
117:             * @param attribute the name of the node's attribute which is 
118:             * attributed by the dialog hint. This parameter may be
119:             * <code>null</code> if the dialog hint applies to the value of the node.
120:             * @param type the type attribute of the dialog hint node.
121:             * @throws SAXException if a general SAX error or warning occurs.
122:             */
123:            public static void generateDialogHint(
124:                    ContentHandler contentHandler, String attribute, String type)
125:                    throws SAXException {
126:                AttributesImpl attrs = new AttributesImpl();
127:                if (attribute != null) {
128:                    attrs.addAttribute("", "attribute", "attribute", "CDATA",
129:                            attribute);
130:                }
131:                attrs.addAttribute("", "type", "type", "CDATA", type);
132:                contentHandler.startElement("", "dialog-hint", "dialog-hint",
133:                        attrs);
134:                contentHandler.endElement("", "dialog-hint", "dialog-hint");
135:            }
136:
137:            /**
138:             * Generate a element having text with a "dialog hint node",
139:             * i.e. a hint how a node's attribute or a node's value is to be
140:             * represented in a dialog.
141:             *
142:             * @param contentHandler main interface that most SAX applications 
143:             * implement. It will receive notification of the logic content of a
144:             * document.
145:             * @param elementName the name of the element to be generated.
146:             * @param attrs the attributes of the element to be generated. 
147:             * @param text the text of the element to be generated. 
148:             * @param dialogHintType the type attribute of the dialog hint node.
149:             * @param dialogHintLength the maximum length of the attribute or node 
150:             * value.
151:             * @throws SAXException if a general SAX error or warning occurs.
152:             */
153:            public static void textElementWithDialogHint(
154:                    ContentHandler contentHandler, String elementName,
155:                    Attributes attrs, String text, String dialogHintType,
156:                    int dialogHintLength) throws SAXException {
157:                contentHandler
158:                        .startElement("", elementName, elementName, attrs);
159:                generateDialogHint(contentHandler, null, dialogHintType,
160:                        dialogHintLength);
161:                if (text != null) {
162:                    contentHandler.characters(text.toCharArray(), 0, text
163:                            .length());
164:                }
165:                contentHandler.endElement("", elementName, elementName);
166:            }
167:
168:            /**
169:             * Generate a element having text with a "dialog hint node",
170:             * i.e. a hint how a node's attribute or a node's value is to be
171:             * represented in a dialog.
172:             *
173:             * @param contentHandler main interface that most SAX applications 
174:             * implement. It will receive notification of the logic content of a
175:             * document.
176:             * @param elementName the name of the element to be generated.
177:             * @param attrs the attributes of the element to be generated. 
178:             * @param text the text of the element to be generated. 
179:             * @param dialogHintType the type attribute of the dialog hint node.
180:             * @throws SAXException if a general SAX error or warning occurs.
181:             */
182:            private static void textElementWithDialogHint(
183:                    ContentHandler contentHandler, String elementName,
184:                    Attributes attrs, String text, String dialogHintType)
185:                    throws SAXException {
186:                contentHandler
187:                        .startElement("", elementName, elementName, attrs);
188:                generateDialogHint(contentHandler, null, dialogHintType);
189:                if (text != null) {
190:                    contentHandler.characters(text.toCharArray(), 0, text
191:                            .length());
192:                }
193:                contentHandler.endElement("", elementName, elementName);
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.