Source Code Cross Referenced for ShowValidatorAction.java in  » J2EE » webwork-2.2.6 » com » opensymphony » webwork » config_browser » 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 » webwork 2.2.6 » com.opensymphony.webwork.config_browser 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.opensymphony.webwork.config_browser;
002:
003:        import com.opensymphony.xwork.util.OgnlUtil;
004:        import com.opensymphony.xwork.validator.Validator;
005:        import ognl.Ognl;
006:        import ognl.OgnlException;
007:        import org.apache.commons.logging.Log;
008:        import org.apache.commons.logging.LogFactory;
009:
010:        import java.beans.BeanInfo;
011:        import java.beans.IntrospectionException;
012:        import java.beans.Introspector;
013:        import java.beans.PropertyDescriptor;
014:        import java.util.Collections;
015:        import java.util.Map;
016:        import java.util.Set;
017:        import java.util.TreeSet;
018:
019:        /**
020:         * ShowValidatorAction
021:         *
022:         * @author Jason Carreira
023:         *         Date: Jun 1, 2004 9:01:02 PM
024:         */
025:        public class ShowValidatorAction extends ListValidatorsAction {
026:            private static Log log = LogFactory
027:                    .getLog(ShowValidatorAction.class);
028:
029:            Set properties = Collections.EMPTY_SET;
030:            int selected = 0;
031:
032:            public int getSelected() {
033:                return selected;
034:            }
035:
036:            public void setSelected(int selected) {
037:                this .selected = selected;
038:            }
039:
040:            public Set getProperties() {
041:                return properties;
042:            }
043:
044:            public Validator getSelectedValidator() {
045:                return (Validator) validators.get(selected);
046:            }
047:
048:            public String execute() throws Exception {
049:                loadValidators();
050:                Validator validator = getSelectedValidator();
051:                properties = new TreeSet();
052:                try {
053:                    Map context = Ognl.createDefaultContext(validator);
054:                    BeanInfo beanInfoFrom = null;
055:                    try {
056:                        beanInfoFrom = Introspector.getBeanInfo(validator
057:                                .getClass(), Object.class);
058:                    } catch (IntrospectionException e) {
059:                        log.error("An error occurred", e);
060:                        addActionError("An error occurred while introspecting a validator of type "
061:                                + validator.getClass().getName());
062:                        return ERROR;
063:                    }
064:
065:                    PropertyDescriptor[] pds = beanInfoFrom
066:                            .getPropertyDescriptors();
067:
068:                    for (int i = 0; i < pds.length; i++) {
069:                        PropertyDescriptor pd = pds[i];
070:                        String name = pd.getName();
071:                        Object value = null;
072:                        if (pd.getReadMethod() == null) {
073:                            value = "No read method for property";
074:                        } else {
075:                            try {
076:                                Object expr = OgnlUtil.compile(name);
077:                                value = Ognl.getValue(expr, context, validator);
078:                            } catch (OgnlException e) {
079:                                addActionError("Caught OGNL exception while getting property value for '"
080:                                        + name
081:                                        + "' on validator of type "
082:                                        + validator.getClass().getName());
083:                            }
084:                        }
085:                        properties.add(new PropertyInfo(name, pd
086:                                .getPropertyType(), value));
087:                    }
088:                } catch (Exception e) {
089:                    log.warn("Unable to retrieve properties.", e);
090:                    addActionError("Unable to retrieve properties: "
091:                            + e.toString());
092:                }
093:
094:                if (hasErrors())
095:                    return ERROR;
096:                else
097:                    return SUCCESS;
098:            }
099:
100:            public static class PropertyInfo implements  Comparable {
101:                private String name;
102:                private Class type;
103:                private Object value;
104:
105:                public PropertyInfo(String name, Class type, Object value) {
106:                    if (name == null) {
107:                        throw new IllegalArgumentException(
108:                                "Name must not be null");
109:                    }
110:                    if (type == null) {
111:                        throw new IllegalArgumentException(
112:                                "Type must not be null");
113:                    }
114:                    this .name = name;
115:                    this .type = type;
116:                    this .value = value;
117:                }
118:
119:                public Class getType() {
120:                    return type;
121:                }
122:
123:                public void setType(Class type) {
124:                    this .type = type;
125:                }
126:
127:                public Object getValue() {
128:                    return value;
129:                }
130:
131:                public void setValue(Object value) {
132:                    this .value = value;
133:                }
134:
135:                public String getName() {
136:                    return name;
137:                }
138:
139:                public void setName(String name) {
140:                    this .name = name;
141:                }
142:
143:                public boolean equals(Object o) {
144:                    if (this  == o)
145:                        return true;
146:                    if (!(o instanceof  PropertyInfo))
147:                        return false;
148:
149:                    final PropertyInfo propertyInfo = (PropertyInfo) o;
150:
151:                    if (!name.equals(propertyInfo.name))
152:                        return false;
153:                    if (!type.equals(propertyInfo.type))
154:                        return false;
155:                    if (value != null ? !value.equals(propertyInfo.value)
156:                            : propertyInfo.value != null)
157:                        return false;
158:
159:                    return true;
160:                }
161:
162:                public int hashCode() {
163:                    int result;
164:                    result = name.hashCode();
165:                    result = 29 * result + type.hashCode();
166:                    result = 29 * result
167:                            + (value != null ? value.hashCode() : 0);
168:                    return result;
169:                }
170:
171:                public int compareTo(Object o) {
172:                    PropertyInfo other = (PropertyInfo) o;
173:                    return this.name.compareTo(other.name);
174:                }
175:            }
176:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.