Source Code Cross Referenced for AbstractPropertyData.java in  » Workflow-Engines » osbl-1_0 » org » conform » 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 » Workflow Engines » osbl 1_0 » org.conform 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* $Id: AbstractPropertyData.java 812 2007-01-15 20:48:12Z hengels $ */
002:        package org.conform;
003:
004:        import java.util.*;
005:
006:        /**
007:         * @version $Revision: 812 $
008:         */
009:        public abstract class AbstractPropertyData extends AbstractData
010:                implements  PropertyData {
011:            PropertyMeta propertyMeta;
012:            AbstractBeanData beanData;
013:            Object invalidValue;
014:            boolean invalid = true;
015:            private final Issue requiredIssue;
016:
017:            protected AbstractPropertyData(AbstractBeanData beanData,
018:                    PropertyMeta propertyMeta) {
019:                this .beanData = beanData;
020:                this .propertyMeta = propertyMeta;
021:                requiredIssue = new Issue(0, this .propertyMeta,
022:                        "validation.required");
023:            }
024:
025:            public PropertyMeta getPropertyMeta() {
026:                return propertyMeta;
027:            }
028:
029:            public Meta getMeta() {
030:                return propertyMeta;
031:            }
032:
033:            public BeanData getBeanData() {
034:                return beanData;
035:            }
036:
037:            public void setValue(Object value) {
038:                Object oldValue = getValue();
039:                if (!isDifferent(oldValue, value)) {
040:                    return;
041:                }
042:
043:                try {
044:                    if (propertyMeta.isWritable())
045:                        value = validate(value);
046:
047:                    doSetValue(value);
048:                    unsetInvalidValue();
049:                } catch (ValidationException e) {
050:                    setInvalidValue(value);
051:                }
052:                beanData.changeSupport.firePropertyChange(propertyMeta
053:                        .getName(), oldValue, value);
054:            }
055:
056:            private boolean isDifferent(Object oldObject, Object newObject) {
057:                if (oldObject == newObject)
058:                    return false;
059:
060:                if (oldObject == null)
061:                    return true;
062:
063:                return !oldObject.equals(newObject);
064:            }
065:
066:            public Object getValue() {
067:                return isInvalid() ? getInvalidValue() : doGetValue();
068:            }
069:
070:            public Object getInvalidValue() {
071:                return invalidValue;
072:            }
073:
074:            public void setInvalidValue(Object invalidValue) {
075:                this .invalidValue = invalidValue;
076:                invalid = true;
077:            }
078:
079:            public void unsetInvalidValue() {
080:                invalidValue = null;
081:                invalid = false;
082:            }
083:
084:            public boolean isInvalid() {
085:                return invalid;
086:            }
087:
088:            public void revalidate() {
089:                try {
090:                    Object value = doGetValue();
091:                    doSetValue(validate(value));
092:                } catch (ValidationException e) {
093:                }
094:            }
095:
096:            public Object validate(Object value) throws ValidationException {
097:                ValidationEvent addEvent = new ValidationEvent(this );
098:                ValidationEvent removeEvent = new ValidationEvent(this );
099:                List<ValidationException.Message> messages = new LinkedList<ValidationException.Message>();
100:
101:                if (propertyMeta.isMandatory() && propertyMeta.isWritable()) {
102:                    if (value == null) {
103:                        addEvent.addIssue(requiredIssue);
104:                        messages.add(new ValidationException.Message(
105:                                "validation.required"));
106:                    } else {
107:                        removeEvent.addIssue(requiredIssue);
108:                    }
109:                }
110:
111:                Collection validators = propertyMeta.getValidators();
112:                if (validators != null) {
113:                    Iterator iter = validators.iterator();
114:                    while (iter.hasNext()) {
115:                        Validator validator = (Validator) iter.next();
116:                        try {
117:                            value = validator.validate(value);
118:                            removeEvent
119:                                    .addIssue(new Issue(System
120:                                            .identityHashCode(validator),
121:                                            propertyMeta));
122:                        } catch (ValidationException e) {
123:                            messages.addAll(e.getMessages());
124:                            for (ValidationException.Message message : e
125:                                    .getMessages()) {
126:                                addEvent.addIssue(new Issue(System
127:                                        .identityHashCode(validator),
128:                                        propertyMeta, message.getCode(),
129:                                        message.getArguments()));
130:                            }
131:                        }
132:                    }
133:                }
134:
135:                // fireRemoveIssue sends the issue to be removed
136:                if (removeEvent.getIssues().size() != 0) {
137:                    fireRemoveIssue(removeEvent);
138:                }
139:
140:                // fireAddIssue sends an update of the issue
141:                if (addEvent.getIssues().size() != 0) {
142:                    fireAddIssue(addEvent);
143:                    throw new ValidationException(messages);
144:                }
145:
146:                return value;
147:            }
148:
149:            public void initialize() {
150:                Initializer initializer = propertyMeta.getInitializer();
151:                if (initializer != null) {
152:                    Object oldValue = getValue();
153:                    Object value = initializer.getValue();
154:                    doSetValue(value);
155:                    unsetInvalidValue();
156:                    beanData.changeSupport.firePropertyChange(propertyMeta
157:                            .getName(), oldValue, value);
158:                }
159:                unsetInvalidValue();
160:            }
161:
162:            public void update() {
163:                unsetInvalidValue();
164:                doSetValue(doGetValue());
165:            }
166:
167:            public void clear() {
168:            }
169:
170:            public void flush() {
171:            }
172:
173:            protected abstract void doSetValue(Object value);
174:
175:            protected abstract Object doGetValue();
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.