Source Code Cross Referenced for Utils.java in  » Ajax » zk » org » zkoss » jsp » zul » impl » 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 » Ajax » zk » org.zkoss.jsp.zul.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Utils.java
002:
003:        {{IS_NOTE
004:        	Purpose:
005:        		
006:        	Description:
007:        		
008:        	History:
009:        		Fri Jul 20 19:30:17     2007, Created by tomyeh
010:        }}IS_NOTE
011:
012:        Copyright (C) 2007 Potix Corporation. All Rights Reserved.
013:
014:        {{IS_RIGHT
015:        	This program is distributed under GPL Version 2.0 in the hope that
016:        	it will be useful, but WITHOUT ANY WARRANTY.
017:        }}IS_RIGHT
018:         */
019:        package org.zkoss.jsp.zul.impl;
020:
021:        import java.util.Collection;
022:        import java.util.Iterator;
023:        import java.util.ArrayList;
024:        import java.io.Writer;
025:        import java.io.IOException;
026:
027:        import org.zkoss.lang.Objects;
028:
029:        import org.zkoss.zk.ui.Page;
030:        import org.zkoss.zk.ui.Component;
031:
032:        /**
033:         * A utility to be shared by {@link BranchTag} and {@link RootTag} to
034:         * implement the capability to hold a list of children.
035:         *
036:         * @author tomyeh
037:         */
038:        /*package*/class Utils {
039:            private static final String MARK_PREFIX = "<zk~u[",
040:                    MARK_POSTFIX = "]>";
041:
042:            /** Adjust the children based the output generated by the inner
043:             * tags of {@link BranchTag} (aka., body).
044:             *
045:             * @param page the page. Specified ony if parent is null (aka. root).
046:             * @param parent the parent component. If null, page must be specified.
047:             */
048:            /*package*/static void adjustChildren(Page page, Component parent,
049:                    Collection children, String body) {
050:
051:                Iterator it = new ArrayList(children).iterator();
052:
053:                for (int j = 0, len = body != null ? body.length() : 0; j < len;) {
054:                    int k = body.indexOf(MARK_PREFIX, j);
055:                    String txt = null;
056:                    Component child = null;
057:                    if (k >= 0) {
058:                        int l = k + MARK_PREFIX.length();
059:                        int m = body.indexOf(MARK_POSTFIX, l);
060:                        if (m <= l) { //not found or empty uuid
061:                            k = -1;
062:                        } else {
063:                            txt = body.substring(j, k).trim();
064:                            child = matchNext(it, body.substring(l, m));
065:                            k = m + MARK_POSTFIX.length();
066:                        }
067:                    }
068:                    if (k < 0)
069:                        txt = body.substring(j).trim();
070:                    //inline handle...
071:                    if (txt.length() > 0) {
072:                        final Inline inl = new Inline(txt);
073:                        if (child != null) {
074:                            if (parent != null)
075:                                parent.insertBefore(inl, child);
076:                            else
077:                                inl.setPageBefore(page, child);
078:                        } else {
079:                            if (parent != null)
080:                                parent.appendChild(inl);
081:                            else
082:                                inl.setPage(page);
083:                        }
084:                    }
085:
086:                    if (k < 0)
087:                        break; //no more
088:                    j = k;
089:                }
090:
091:                //		while (it.hasNext())
092:                //			((Component)it.next()).detach();
093:            }
094:
095:            /** Matches the next component with the specified uuid,
096:             * returns null if no match at all.
097:             * Note: if it.next().getUuid() is not uuid, it will be removed.
098:             */
099:            private static Component matchNext(Iterator it, String uuid) {
100:                while (it.hasNext()) {
101:                    final Component child = (Component) it.next();
102:                    if (Objects.equals(uuid, child.getUuid()))
103:                        return child; //found
104:                    child.detach(); //remove it
105:                    //Note: it assumes it has the full set and they are
106:                    //in the same order
107:                }
108:                return null;
109:            }
110:
111:            /** Writes a special mark to the output to represent the component
112:             * of the specified child.
113:             * The mark is then used by {@link #adjustChildren}
114:             */
115:            /*package*/static void writeComponentMark(Writer out,
116:                    Component comp) throws IOException {
117:                out.write(MARK_PREFIX);
118:                out.write(comp.getUuid());
119:                out.write(MARK_POSTFIX);
120:            }
121:
122:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.