Source Code Cross Referenced for BeanTestTag.java in  » Portal » Open-Portal » com » sun » portal » wireless » taglibs » base » 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 » Portal » Open Portal » com.sun.portal.wireless.taglibs.base 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * $Id: BeanTestTag.java,v 1.6 2005/09/21 10:50:27 dg154973 Exp $
003:         * Copyright 2002 Sun Microsystems, Inc. All
004:         * rights reserved. Use of this product is subject
005:         * to license terms. Federal Acquisitions:
006:         * Commercial Software -- Government Users
007:         * Subject to Standard License Terms and
008:         * Conditions.
009:         *
010:         * Sun, Sun Microsystems, the Sun logo, and Sun ONE
011:         * are trademarks or registered trademarks of Sun Microsystems,
012:         * Inc. in the United States and other countries.
013:         */package com.sun.portal.wireless.taglibs.base;
014:
015:        import com.sun.portal.log.common.PortalLogger;
016:
017:        import java.beans.*;
018:        import java.util.logging.Logger;
019:        import java.util.logging.Level;
020:        import javax.servlet.jsp.*;
021:
022:        /**
023:         * BeanTestTag - test a bean property
024:         * 
025:         * Evaluates the body if the property is true; else skips the body.
026:         *
027:         * A bean property is evaluated as follows:
028:         * - if the property value is null then return false
029:         * - if the value is a boolean then return the boolean value
030:         * - if the value is some other object then compare it to the specified value
031:         * 
032:         * Attributes:
033:         * 
034:         * property
035:         *   name of the bean property to test
036:         * value
037:         *   string value of the bean property to test; optional
038:         * id
039:         *   object value of the bean property to test; optional
040:         * name
041:         *   name to use to find the bean on the page context
042:         * 
043:         * @author Robert O'Brien
044:         * @version 1.0
045:         * @see BeanSetTag
046:         * @see BeanSupport
047:         */
048:        public class BeanTestTag extends BeanSupport {
049:
050:            // Create a logger for this class
051:            private static Logger debugLogger = PortalLogger
052:                    .getLogger(BeanTestTag.class);
053:
054:            /**
055:             * The value of the bean property to test
056:             */
057:            public String value;
058:
059:            /**
060:             * Get the value of the bean property
061:             * 
062:             * @return the value
063:             */
064:            public String getValue() {
065:                return value;
066:            }
067:
068:            /**
069:             * Set the value of the bean property
070:             * 
071:             * @param value  the value
072:             */
073:            public void setValue(String value) {
074:                this .value = evalAttribute(value);
075:            }
076:
077:            /**
078:             * Evaluate a bean property
079:             * 
080:             * @param prop   the bean property value to test
081:             * @param test   the test value to compare against
082:             * @return true if the two values are considered equivalent
083:             */
084:            public boolean evaluate(Object prop, Object test) {
085:
086:                debugLogger.finest("prop=" + prop + ", test=" + test);
087:
088:                if (prop == null) {
089:                    return false;
090:                }
091:
092:                if (prop instanceof  String && test == null) {
093:                    String pstring = (String) prop;
094:                    if (pstring.equals("")) {
095:                        return false;
096:                    }
097:                }
098:
099:                if (prop instanceof  Boolean && test == null) {
100:                    return ((Boolean) prop).booleanValue();
101:                }
102:
103:                if (test == null) {
104:                    return true;
105:                }
106:
107:                try {
108:                    Class propclass = prop.getClass();
109:                    Class testclass = test.getClass();
110:
111:                    if (propclass != testclass) {
112:                        test = getInstanceOf(test, propclass);
113:                    }
114:
115:                    return prop.equals(test);
116:
117:                } catch (InstantiationException e) {
118:                }
119:
120:                return false;
121:            }
122:
123:            /**
124:             * Test a bean property
125:             * 
126:             * @return SKIP_BODY
127:             * @exception JspException
128:             */
129:            public int doStartTag() throws JspException {
130:                Object value, propval;
131:
132:                try {
133:                    bean = findBean();
134:                } catch (Exception e) {
135:                    debugLogger.log(Level.FINE, "PSMA_CSPWTB0007", e);
136:                    throw new JspException(this .getClass().getName()
137:                            + ".doStartTag():  No bean found: "
138:                            + e.getMessage());
139:                }
140:
141:                if (property == null) {
142:                    debugLogger.fine("PSMA_CSPWTB0002");
143:                    throw new JspException(this .getClass().getName()
144:                            + ".doStartTag(): property attribute is required");
145:                }
146:
147:                if (id != null) {
148:                    value = pageContext.findAttribute(id);
149:                } else {
150:                    value = getValue();
151:                }
152:
153:                try {
154:                    propval = readProperty(bean);
155:                } catch (IntrospectionException e) {
156:                    debugLogger.log(Level.FINE, "PSMA_CSPWTB0005",
157:                            getProperty());
158:                    throw new JspException(this .getClass().getName()
159:                            + ".doStartTag():  Couldn't read " + getProperty()
160:                            + " property");
161:                }
162:
163:                return (evaluate(propval, value)) ? EVAL_BODY_INCLUDE
164:                        : SKIP_BODY;
165:            }
166:
167:            /**
168:             * Cleanup
169:             */
170:            public void release() {
171:                super.release();
172:                value = null;
173:            }
174:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.