Source Code Cross Referenced for Condition.java in  » UML » AndroMDA-3.2 » org » andromda » andromdapp » 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 » UML » AndroMDA 3.2 » org.andromda.andromdapp 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.andromda.andromdapp;
002:
003:        import java.util.LinkedHashMap;
004:        import java.util.Map;
005:
006:        /**
007:         * Represents a prompt "condition".  That is, a prompt
008:         * value will be set if the condition is satisfied.
009:         *
010:         * @author Chad Brandon
011:         */
012:        public class Condition {
013:            /**
014:             * The id of the prompt to which this condition applies.
015:             */
016:            private String id;
017:
018:            /**
019:             * Gets the id of the prompt to which this condition applies.
020:             *
021:             * @return Returns the id.
022:             */
023:            public String getId() {
024:                return id;
025:            }
026:
027:            /**
028:             * Sets the id of the prompt to which this condition applies.
029:             *
030:             * @param id The id to set.
031:             */
032:            public void setId(String id) {
033:                this .id = id;
034:            }
035:
036:            /**
037:             * Stores the properties to set if the condition is true.
038:             */
039:            private final Map properties = new LinkedHashMap();
040:
041:            /**
042:             * Sets the value of the property in the template context
043:             * with the given <code>id</code> to have the given <code>value</code>
044:             * if this condition is true.
045:             *
046:             * @param id the identifier of the prompt.
047:             * @param value the value to give the prompt.
048:             * @param type the fully qualified type name.
049:             */
050:            public void setProperty(final String id, final String value,
051:                    final String type) {
052:                this .properties.put(id, AndroMDAppUtils.convert(value, type));
053:            }
054:
055:            /**
056:             * Gets all properties to set for this condition.
057:             *
058:             * @return the prompt values.
059:             */
060:            public Map getProperties() {
061:                return this .properties;
062:            }
063:
064:            /**
065:             * The value of which the condition must be equal.
066:             */
067:            private String equal;
068:
069:            /**
070:             * Gets the value of which the condition must be equal.
071:             *
072:             * @return Returns the equal.
073:             */
074:            public String getEqual() {
075:                return equal;
076:            }
077:
078:            /**
079:             * Sets the value of which the condition must be equal.
080:             *
081:             * @param equal The equal to set.
082:             */
083:            public void setEqual(final String equal) {
084:                this .equal = equal;
085:            }
086:
087:            /**
088:             * The value of which the condition must not be equal.
089:             */
090:            private String notEqual;
091:
092:            /**
093:             * Gets the value of which the condition must <strong>not</strong> be equal.
094:             *
095:             * @return Returns the notEqual.
096:             */
097:            public String getNotEqual() {
098:                return notEqual;
099:            }
100:
101:            /**
102:             * Sets the value of which the condition must <strong>not</strong> be equal.
103:             *
104:             * @param notEqual The notEqual to set.
105:             */
106:            public void setNotEqual(final String notEqual) {
107:                this .notEqual = notEqual;
108:            }
109:
110:            /**
111:             * The value of which the condition must be present.
112:             */
113:            private Boolean present;
114:
115:            /**
116:             * Sets whether or not the condition must be present.
117:             *
118:             * @param present The present to set.
119:             */
120:            public void setPresent(final boolean present) {
121:                this .present = Boolean.valueOf(present);
122:            }
123:
124:            /**
125:             * Evalutes whether or not the value is valid according to this condition.
126:             *
127:             * @param value the value to evaluate.
128:             * @return true/false
129:             */
130:            public boolean evaluate(Object value) {
131:                boolean valid = true;
132:                if (this .present != null) {
133:                    // - if the condition must be present, very that it is
134:                    if (this .present.booleanValue()) {
135:                        valid = value != null;
136:                    } else if (!this .present.booleanValue()) {
137:                        // - otherwise verify that the condition is not present (if it shouldn't be)
138:                        valid = value == null;
139:                    }
140:                }
141:                if (valid) {
142:                    final String equal = this .getEqual();
143:                    final String notEqual = this .getNotEqual();
144:                    final boolean equalConditionPresent = equal != null;
145:                    final boolean notEqualConditionPresent = notEqual != null;
146:                    value = String.valueOf(value);
147:                    if (equalConditionPresent || notEqualConditionPresent) {
148:                        if (equalConditionPresent) {
149:                            valid = equal.equals(value);
150:                        } else if (notEqualConditionPresent) {
151:                            valid = !notEqual.equals(value);
152:                        }
153:                    }
154:                }
155:                return valid;
156:            }
157:
158:            /**
159:             * @see java.lang.Object#toString()
160:             */
161:            public String toString() {
162:                return super .toString() + "[id=" + this .id + ", equal="
163:                        + this .equal + ", notEqual=" + this .notEqual + "]";
164:            }
165:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.