Source Code Cross Referenced for AbstractAction.java in  » Ajax » zk » org » zkoss » web » servlet » dsp » action » 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.web.servlet.dsp.action 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* AbstractAction.java
002:
003:        {{IS_NOTE
004:        	Purpose:
005:        		
006:        	Description:
007:        		
008:        	History:
009:        		Wed Sep  7 14:55:38     2005, Created by tomyeh
010:        }}IS_NOTE
011:
012:        Copyright (C) 2005 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.web.servlet.dsp.action;
020:
021:        import java.util.Map;
022:
023:        import org.zkoss.xml.XMLs;
024:
025:        /**
026:         * A skeletal implementation to simplify the implementation of actions.
027:         *
028:         * @author tomyeh
029:         */
030:        abstract public class AbstractAction implements  Action {
031:            /** A special integer to denote no attribute is assigned. */
032:            protected static final int NULL_INT = Integer.MIN_VALUE + 0x68;
033:            /** A special short to denote no attribute is assigned. */
034:            protected static final short NULL_SHORT = Short.MIN_VALUE + 0x68;
035:
036:            private boolean _if = true;
037:            private boolean _unless = false;
038:
039:            /** Returns the if condition.
040:             * If the if condition is false, this tag is ignored.
041:             * If the unless condition ({@link #getUnless}) is true, this tag is
042:             * ignored, too.
043:             * Tags deriving from this class shall invoke {@link #isEffective} to
044:             * know the result.
045:             *
046:             * <p>Default: true.
047:             */
048:            public boolean getIf() {
049:                return _if;
050:            }
051:
052:            /** Sets the if condition.
053:             */
054:            public void setIf(boolean ifcond) {
055:                _if = ifcond;
056:            }
057:
058:            /** Returns the unless condition.
059:             * If the unless condition is true, this tag is ignored.
060:             * If the if condition ({@link #getIf}) is true, this tag is ignored, too.
061:             * Tags deriving from this class shall invoke {@link #isEffective} to
062:             * know the result.
063:             *
064:             * <p>Default: false.
065:             */
066:            public boolean getUnless() {
067:                return _unless;
068:            }
069:
070:            /** Sets the unless condition.
071:             */
072:            public void setUnless(boolean unless) {
073:                _unless = unless;
074:            }
075:
076:            /** Returns whether this tag is effecive. If false, this tag does nothing
077:             * (as if not specified at all).
078:             */
079:            public boolean isEffective() {
080:                return _if && !_unless;
081:            }
082:
083:            //-- Utilities --//
084:            /** Returns one of {@link ActionContext#PAGE_SCOPE}, {@link ActionContext#REQUEST_SCOPE},
085:             * {@link ActionContext#SESSION_SCOPE} and {@link ActionContext#APPLICATION_SCOPE}
086:             * of the specified scope name.
087:             *
088:             * @param scope one of "page", "request", "session" and "application".
089:             */
090:            protected static final int toScope(String scope) {
091:                return "request".equals(scope) ? ActionContext.REQUEST_SCOPE
092:                        : "session".equals(scope) ? ActionContext.SESSION_SCOPE
093:                                : "application".equals(scope) ? ActionContext.APPLICATION_SCOPE
094:                                        : ActionContext.PAGE_SCOPE;
095:            }
096:
097:            /** Puts an attribute to the map,
098:             * if <code>attrValue</code> is not null.
099:             */
100:            protected static final void put(Map params, String attrName,
101:                    String attrValue) {
102:                if (attrValue != null)
103:                    params.put(attrName, attrValue);
104:            }
105:
106:            /** Puts an attribute to the map.
107:             * Unlike othere put(...), it always puts the specified attribute.
108:             */
109:            protected static final void put(Map params, String attrName,
110:                    boolean avail) {
111:                params.put(attrName, Boolean.valueOf(avail));
112:            }
113:
114:            /** Puts an attribute to the map,
115:             * if <code>val</code> is not NULL_INT.
116:             */
117:            protected static final void put(Map params, String attrName, int val) {
118:                if (val != NULL_INT)
119:                    params.put(attrName, new Integer(val));
120:            }
121:
122:            /** Puts an object if it is not null.
123:             */
124:            protected static final void put(Map params, String attrName,
125:                    Object attrValue) {
126:                if (attrValue != null)
127:                    params.put(attrName, attrValue);
128:            }
129:
130:            /** Appends an attribute to the string buffer,
131:             * if <code>attrValue</code> is not null.
132:             */
133:            protected static final void append(StringBuffer sb,
134:                    String attrName, String attrValue) {
135:                if (attrValue != null)
136:                    sb.append(' ').append(attrName).append("=\"").append(
137:                            XMLs.encodeAttribute(attrValue)).append('"');
138:                //it might contain " or other special characters
139:            }
140:
141:            /** Appends an attribute to the string buffer,
142:             * if <code>avail</code> is true.
143:             */
144:            protected static//not final, e.g., xul has different format
145:            void append(StringBuffer sb, String attrName, boolean avail) {
146:                if (avail)
147:                    sb.append(' ').append(attrName);
148:            }
149:
150:            /** Appends an attribute to the string buffer,
151:             * if <code>val</code> is not NULL_INT.
152:             */
153:            protected static final void append(StringBuffer sb,
154:                    String attrName, int val) {
155:                if (val != NULL_INT)
156:                    sb.append(' ').append(attrName).append("=\"").append(
157:                            Integer.toString(val)).append('"');
158:            }
159:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.