Source Code Cross Referenced for Prompt.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.ArrayList;
004:        import java.util.Iterator;
005:        import java.util.List;
006:
007:        /**
008:         * Represents a user prompt used by AndroMDApp.
009:         *
010:         * @author Chad Brandon
011:         */
012:        public class Prompt {
013:            /**
014:             * The unique prompt identifier.
015:             */
016:            private String id;
017:
018:            /**
019:             * Gets the unique id of this prompt.
020:             *
021:             * @return Returns the id.
022:             */
023:            public String getId() {
024:                return id;
025:            }
026:
027:            /**
028:             * Sets the unique id of this prompt.
029:             *
030:             * @param id The id to set.
031:             */
032:            public void setId(String id) {
033:                this .id = id;
034:            }
035:
036:            /**
037:             * Whether or not this prompt is required.
038:             */
039:            private boolean required = true;
040:
041:            /**
042:             * Sets whether or not this prompt is required,
043:             * by default the prompt is <strong>required</strong>.
044:             *
045:             * @param required whether or not this prompt is required
046:             */
047:            public void setRequired(final boolean required) {
048:                this .required = required;
049:            }
050:
051:            /**
052:             * Indicates whether or not this prompt is required.
053:             *
054:             * @return true/false
055:             */
056:            public boolean isRequired() {
057:                return this .required;
058:            }
059:
060:            /**
061:             * Stores the actual text of the prompt.
062:             */
063:            private String text;
064:
065:            /**
066:             * Gets the text of the prompt.
067:             *
068:             * @return Returns the text.
069:             */
070:            public String getText() {
071:                final StringBuffer text = new StringBuffer();
072:                if (this .text != null) {
073:                    text.append(this .text);
074:                }
075:                if (!this .responses.isEmpty()) {
076:                    text.append(" " + this .getResponsesAsString());
077:                }
078:                text.append(": ");
079:                return text.toString();
080:            }
081:
082:            /**
083:             * Sets the prompt text.
084:             *
085:             * @param text The text to set.
086:             */
087:            public void setText(String text) {
088:                this .text = text != null ? text.trim() : null;
089:            }
090:
091:            /**
092:             * Stores the possible responses of the prompt.
093:             */
094:            private List responses = new ArrayList();
095:
096:            /**
097:             * Adds a reponse to the possible responses.
098:             *
099:             * @param response the response to add.
100:             * @param type the full qualified type of the response (if undefined
101:             *        the type is left as a string).
102:             */
103:            public void addResponse(final String response) {
104:                if (response != null && response.trim().length() > 0) {
105:                    this .responses.add(response.trim());
106:                }
107:            }
108:
109:            /**
110:             * Indicates whether or not the given <code>response</code> is valid
111:             * according to the valid responses contained in this prompt instance.
112:             *
113:             * @param response the response to check.
114:             * @return true/false
115:             */
116:            public boolean isValidResponse(final String response) {
117:                return this .responses.contains(response)
118:                        || (this .responses.isEmpty() && (!this .isRequired() || (response != null && response
119:                                .trim().length() > 0)));
120:            }
121:
122:            /**
123:             * Gets the response object converted to the appropriate
124:             * type or just as it is (if no conversion took place or conversion
125:             * failed).
126:             *
127:             * @param response the response to convert.
128:             * @return the response as an object.
129:             */
130:            public Object getResponse(final Object response) {
131:                return AndroMDAppUtils.convert(response, this .responseType);
132:            }
133:
134:            /**
135:             * Stores the response type.
136:             */
137:            private String responseType;
138:
139:            /**
140:             * Sets the response type to use (i.e the fully qualified name of the
141:             * type to which it should be converted when placed into the the template context).
142:             *
143:             * @param responseType the fully qualified response type name.
144:             */
145:            public void setResponseType(final String responseType) {
146:                this .responseType = responseType;
147:            }
148:
149:            /**
150:             * Gets the responses as a formatted string.
151:             *
152:             * @return the responses list as a string.
153:             */
154:            private String getResponsesAsString() {
155:                final StringBuffer responses = new StringBuffer("[");
156:                for (final Iterator iterator = this .responses.iterator(); iterator
157:                        .hasNext();) {
158:                    responses.append(iterator.next());
159:                    if (iterator.hasNext()) {
160:                        responses.append(", ");
161:                    }
162:                }
163:                responses.append("]");
164:                return responses.toString();
165:            }
166:
167:            /**
168:             * The conditions that apply to this prompt.
169:             */
170:            private List conditions = new ArrayList();
171:
172:            /**
173:             * Adds a condition to this prompt.
174:             *
175:             * @param condition the condition which must apply to this prompt.
176:             */
177:            public void addCondition(final Condition condition) {
178:                this .conditions.add(condition);
179:            }
180:
181:            /**
182:             * Gets the conditions defined in this prompt.
183:             *
184:             * @return the conditions that are defined within this prompt.
185:             */
186:            public List getConditions() {
187:                return this .conditions;
188:            }
189:
190:            /**
191:             * The preconditions that must be valid for this prompt
192:             * in order for it to be executed.
193:             */
194:            private List preconditions = new ArrayList();
195:
196:            /**
197:             * Adds preconditions to this prompt.
198:             *
199:             * @param preconditions the preconditions to add.
200:             */
201:            public void addPreconditions(final Conditions preconditions) {
202:                this .preconditions.add(preconditions);
203:            }
204:
205:            /**
206:             * Gets the preconditions for this prompt.
207:             *
208:             * @return the prompt preconditions.
209:             */
210:            public List getPreconditions() {
211:                return this .preconditions;
212:            }
213:
214:            /**
215:             * Whether or not the value of the response should be
216:             * set to a boolean value of true.
217:             */
218:            private boolean setResponseAsTrue;
219:
220:            /**
221:             * Whether or not the response should be set to a boolean value of <code>true</code>.
222:             *
223:             * @return Returns the setResponseAsTrue.
224:             */
225:            public boolean isSetResponseAsTrue() {
226:                return setResponseAsTrue;
227:            }
228:
229:            /**
230:             * Sets whether or not the response should be set to a boolean value of true.
231:             *
232:             * @param setResponseAsTrue The setResponseAsTrue to set.
233:             */
234:            public void setSetResponseAsTrue(boolean setResponseAsBoolean) {
235:                this.setResponseAsTrue = setResponseAsBoolean;
236:            }
237:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.