Source Code Cross Referenced for EventLog.java in  » J2EE » Enhydra-Application-Framework » org » enhydra » util » chiba » 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 » J2EE » Enhydra Application Framework » org.enhydra.util.chiba 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.enhydra.util.chiba;
002:
003:        import org.chiba.xml.util.DOMUtil;
004:        import org.chiba.xml.xforms.XFormsConstants;
005:        import org.chiba.xml.xforms.events.XFormsEvent;
006:        import org.chiba.xml.xforms.events.XFormsEventFactory;
007:        import org.w3c.dom.Document;
008:        import org.w3c.dom.Element;
009:
010:        import java.util.Arrays;
011:        import java.util.Iterator;
012:        import java.util.List;
013:
014:        /**
015:         * EventLog logs all events happening in XForms processor and build a DOM
016:         * document which represent those events.
017:         *
018:         * @author Joern Turner, Slobodan Vujasinovic
019:         * @version $Id: EventLog.java,v 1.1 2007-01-24 16:59:09 sinisa Exp $
020:         */
021:        public class EventLog {
022:            private static List HELPER_ELEMENTS = Arrays.asList(new String[] {
023:                    XFormsConstants.LABEL, XFormsConstants.HELP,
024:                    XFormsConstants.HINT, XFormsConstants.ALERT,
025:                    XFormsConstants.VALUE });
026:            private static List SELECTOR_ELEMENTS = Arrays.asList(new String[] {
027:                    XFormsConstants.SELECT1, XFormsConstants.SELECT });
028:
029:            private Document doc;
030:            private Element root;
031:            private Element selector;
032:
033:            public EventLog() {
034:                this .doc = DOMUtil.newDocument(false, false);
035:                this .root = this .doc.createElement("eventlog");
036:                this .root.setAttribute("id", "eventlog");
037:                this .doc.appendChild(this .root);
038:            }
039:
040:            public Element getLog() {
041:                return (Element) this .root.cloneNode(true);
042:            }
043:
044:            public void add(XFormsEvent event) {
045:                // get target properties
046:                String type = event.getType();
047:                Element target = (Element) event.getTarget();
048:                String targetId = target.getAttributeNS(null, "id");
049:                String targetName = target.getLocalName();
050:
051:                // create event element
052:                Element element;
053:
054:                if (XFormsEventFactory.CHIBA_STATE_CHANGED.equals(type)
055:                        && SELECTOR_ELEMENTS.contains(targetName)) {
056:                    // selector events are always appended to the end of the log
057:                    // to ensure their items' labels and values are updated before
058:                    element = insert(null, type, targetId, targetName);
059:                    if (this .selector == null) {
060:                        this .selector = element;
061:                    }
062:                } else {
063:                    // all other events are inserted before any selector events
064:                    element = insert(this .selector, type, targetId, targetName);
065:                }
066:
067:                if (XFormsEventFactory.CHIBA_STATE_CHANGED.equals(type)
068:                        && HELPER_ELEMENTS.contains(targetName)) {
069:                    // parent id is needed for updating all helper elements cause they
070:                    // are identified by '<parentId>-label' etc. rather than their own id
071:                    String parentId = ((Element) target.getParentNode())
072:                            .getAttributeNS(null, "id");
073:                    addProperty(element, "parentId", parentId);
074:                }
075:
076:                // add event params
077:                Iterator iterator = event.getPropertyNames().iterator();
078:                String name;
079:                while (iterator.hasNext()) {
080:                    name = (String) iterator.next();
081:                    addProperty(element, name, event.getContextInfo(name)
082:                            .toString());
083:                }
084:            }
085:
086:            public Element add(String type, String targetId, String targetName) {
087:                return insert(this .selector, type, targetId, targetName);
088:            }
089:
090:            public Element addProperty(Element element, String name,
091:                    String value) {
092:                Element property = this .doc.createElement("property");
093:                property.setAttribute("name", name);
094:                property.appendChild(this .doc.createTextNode(value));
095:                element.appendChild(property);
096:
097:                return element;
098:            }
099:
100:            private Element insert(Element ref, String type, String targetId,
101:                    String targetName) {
102:                // create event element
103:                Element element = this .doc.createElement("event");
104:                this .root.insertBefore(element, ref);
105:
106:                // add target properties
107:                element.setAttribute("type", type);
108:                element.setAttribute("targetId", targetId);
109:                element.setAttribute("targetName", targetName);
110:                return element;
111:            }
112:
113:            // clean the log
114:            public void flush() {
115:                DOMUtil.removeAllChildren(this.root);
116:                this.selector = null;
117:            }
118:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.