Source Code Cross Referenced for XBaseValidator.java in  » XML-UI » XUI » net » xoetrope » xui » validation » 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 » XML UI » XUI » net.xoetrope.xui.validation 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.xoetrope.xui.validation;
002:
003:        import java.lang.reflect.InvocationTargetException;
004:        import java.lang.reflect.Method;
005:
006:        import java.awt.Component;
007:        import java.awt.Container;
008:
009:        import net.xoetrope.xui.XTextHolder;
010:        import net.xoetrope.xui.helper.MessageHelper;
011:        import net.xoetrope.xml.XmlElement;
012:
013:        /**
014:         * <p>A basic implementation of the XValidator interface</p>
015:         * <p>Copyright: Copyright (c) Xoetrope Ltd., 1998-2003<br>
016:         * License:      see license.txt</p>
017:         * $Revision: 1.14 $
018:         */
019:        public abstract class XBaseValidator implements  XValidator {
020:            protected boolean mandatory;
021:            protected String message, value, formattedMessage, validationName;
022:            protected Container container;
023:            protected Method validationMethod;
024:            protected int mask;
025:            protected int errorLevel = XValidator.LEVEL_IGNORE;
026:            protected boolean start = true;
027:
028:            public XBaseValidator() {
029:            }
030:
031:            /**
032:             * Constructor sets up member variables
033:             * @param name
034:             * @param validatorMask
035:             */
036:            public XBaseValidator(String name, int validatorMask) {
037:                validationName = name;
038:                mask = validatorMask;
039:            }
040:
041:            /**
042:             * Get the event mask. The mask helps filter the events for which the
043:             * validator is invoked
044:             * @return the mask
045:             */
046:            public int getMask() {
047:                return mask;
048:            }
049:
050:            /**
051:             * Set the event mask. The mask helps filter the events for which the
052:             * validator is invoked
053:             * @return the new mask value
054:             */
055:            public void setMask(int newMask) {
056:                mask = newMask;
057:            }
058:
059:            /**
060:             * Set the Method of the XPage to be invoked when we are doing a funcion
061:             * validation
062:             * @param m The method to be invoked
063:             * @param page The XPage which contains the Method.
064:             */
065:            public void setValidationMethod(Method m, Container c) {
066:                container = c;
067:                validationMethod = m;
068:            }
069:
070:            /**
071:             * Get the name of the validation
072:             * @return The name
073:             */
074:            public String getName() {
075:                return validationName;
076:            }
077:
078:            /**
079:             * Set the name of the validation
080:             * @param name the new name
081:             */
082:            public void setName(String name) {
083:                validationName = name;
084:            }
085:
086:            /**
087:             * Get the validation message which is formatted after the tokens have been
088:             * replaced
089:             * @return The formatted message.
090:             */
091:            public String getMessage() {
092:                return formattedMessage;
093:            }
094:
095:            /**
096:             * Set the validation parameters
097:             * @param element the validator parameters
098:             */
099:            public void setup(XmlElement element) {
100:                message = element.getAttribute("msg");
101:                formattedMessage = message;
102:            }
103:
104:            /**
105:             * Get the value as a string object
106:             * @return the value as string
107:             */
108:            public String getValueAsString() {
109:                return value;
110:            }
111:
112:            /**
113:             * Get the error level of the validations
114:             * @return the error level
115:             */
116:            public int getLevel() {
117:                return errorLevel;
118:            }
119:
120:            /**
121:             * Call the funcion to get the value we are validating.
122:             * @return The result of the function call
123:             */
124:            public Object invokeMethod() {
125:                if (validationMethod != null) {
126:                    try {
127:                        return validationMethod.invoke(container, null);
128:                    } catch (IllegalAccessException ex) {
129:                        return null;
130:                    } catch (IllegalArgumentException ex) {
131:                        return null;
132:                    } catch (InvocationTargetException ex) {
133:                        return null;
134:                    }
135:                }
136:                return "";
137:            }
138:
139:            /**
140:             * Carry out a replacement on the validation message
141:             * @param lookup The text to find
142:             * @param replacement The text to replace the text with
143:             */
144:            protected void replaceToken(String lookup, String replacement) {
145:                if (start)
146:                    formattedMessage = message;
147:                formattedMessage = MessageHelper.getInstance().replaceToken(
148:                        formattedMessage, lookup, replacement);
149:                start = false;
150:            }
151:
152:            /**
153:             * Replace any further tokens in the message
154:             */
155:            protected void replaceTokens() {
156:                if (start)
157:                    formattedMessage = message;
158:                formattedMessage = MessageHelper.getInstance().replaceTokens(
159:                        formattedMessage);
160:                start = false;
161:            }
162:
163:            /**
164:             * Get the text value of the component.
165:             * @param c The component
166:             * @return The text components value
167:             */
168:            protected String getText(Component c) {
169:                return ((XTextHolder) c).getText();
170:            }
171:
172:            /**
173:             * Replace the remaining tokens and throw the exception
174:             * @throws Exception
175:             */
176:            protected void throwException() throws Exception {
177:                replaceTokens();
178:                start = true;
179:                throw new Exception(formattedMessage);
180:            }
181:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.