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


0001:        package org.andromda.cartridges.bpm4struts.metafacades;
0002:
0003:        import java.util.ArrayList;
0004:        import java.util.Arrays;
0005:        import java.util.Collection;
0006:        import java.util.Collections;
0007:        import java.util.Iterator;
0008:        import java.util.LinkedHashMap;
0009:        import java.util.LinkedHashSet;
0010:        import java.util.List;
0011:        import java.util.Map;
0012:
0013:        import org.andromda.cartridges.bpm4struts.Bpm4StrutsGlobals;
0014:        import org.andromda.cartridges.bpm4struts.Bpm4StrutsProfile;
0015:        import org.andromda.cartridges.bpm4struts.Bpm4StrutsUtils;
0016:        import org.andromda.metafacades.uml.ClassifierFacade;
0017:        import org.andromda.metafacades.uml.EventFacade;
0018:        import org.andromda.metafacades.uml.FrontEndActivityGraph;
0019:        import org.andromda.metafacades.uml.ModelElementFacade;
0020:        import org.andromda.metafacades.uml.TransitionFacade;
0021:        import org.andromda.metafacades.uml.UMLMetafacadeUtils;
0022:        import org.andromda.metafacades.uml.UMLProfile;
0023:        import org.andromda.metafacades.uml.UseCaseFacade;
0024:        import org.andromda.utils.StringUtilsHelper;
0025:        import org.apache.commons.lang.StringUtils;
0026:
0027:        /**
0028:         * MetafacadeLogic implementation.
0029:         *
0030:         * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsParameter
0031:         */
0032:        public class StrutsParameterLogicImpl extends StrutsParameterLogic {
0033:            public StrutsParameterLogicImpl(java.lang.Object metaObject,
0034:                    java.lang.String context) {
0035:                super (metaObject, context);
0036:            }
0037:
0038:            protected Object handleGetStrutsAction() {
0039:                Object actionObject = null;
0040:
0041:                final EventFacade event = getEvent();
0042:                if (event != null) {
0043:                    final TransitionFacade transition = event.getTransition();
0044:                    if (transition instanceof  StrutsAction) {
0045:                        actionObject = transition;
0046:                    }
0047:                }
0048:                return actionObject;
0049:            }
0050:
0051:            protected String handleGetStyleId() {
0052:                String styleId = null;
0053:
0054:                final StrutsAction action = this .getStrutsAction();
0055:                if (action != null) {
0056:                    // if this parameter's action links to a table we use a specific styleId
0057:                    if (action.isTableLink()) {
0058:                        styleId = action.getTableLinkName()
0059:                                + StringUtilsHelper
0060:                                        .upperCamelCaseName(getName());
0061:                    } else {
0062:                        final EventFacade trigger = action.getTrigger();
0063:                        if (trigger != null) {
0064:                            styleId = StringUtilsHelper
0065:                                    .lowerCamelCaseName(trigger.getName())
0066:                                    + StringUtilsHelper
0067:                                            .upperCamelCaseName(getName());
0068:                        }
0069:                    }
0070:                }
0071:
0072:                return styleId;
0073:            }
0074:
0075:            protected Object handleGetJsp() {
0076:                Object jspObject = null;
0077:
0078:                final EventFacade event = getEvent();
0079:                if (event != null) {
0080:                    final TransitionFacade transition = event.getTransition();
0081:                    if (transition instanceof  StrutsAction) {
0082:                        final StrutsAction action = (StrutsAction) transition;
0083:                        jspObject = action.getInput();
0084:                    } else if (transition instanceof  StrutsForward) {
0085:                        final StrutsForward forward = (StrutsForward) transition;
0086:                        if (forward.isEnteringPage()) {
0087:                            jspObject = forward.getTarget();
0088:                        }
0089:                    }
0090:                }
0091:
0092:                return jspObject;
0093:            }
0094:
0095:            protected List handleGetFormFields() {
0096:                final List formFields;
0097:                if (isControllerOperationArgument() && getName() != null) {
0098:                    final String name = getName();
0099:                    formFields = new ArrayList();
0100:                    Collection actions = this .getControllerOperation()
0101:                            .getDeferringActions();
0102:                    for (final Iterator actionIterator = actions.iterator(); actionIterator
0103:                            .hasNext();) {
0104:                        StrutsAction action = (StrutsAction) actionIterator
0105:                                .next();
0106:                        Collection actionFormFields = action
0107:                                .getActionFormFields();
0108:                        for (final Iterator fieldIterator = actionFormFields
0109:                                .iterator(); fieldIterator.hasNext();) {
0110:                            StrutsParameter parameter = (StrutsParameter) fieldIterator
0111:                                    .next();
0112:                            if (name.equals(parameter.getName())) {
0113:                                formFields.add(parameter);
0114:                            }
0115:                        }
0116:                    }
0117:                } else {
0118:                    formFields = Collections.EMPTY_LIST;
0119:                }
0120:                return formFields;
0121:            }
0122:
0123:            /**
0124:             * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsParameter#getResetValue()()
0125:             */
0126:            protected java.lang.String handleGetNullValue() {
0127:                String nullValue = null;
0128:
0129:                final ClassifierFacade type = getType();
0130:                if (type != null) {
0131:                    nullValue = type.getJavaNullString();
0132:                }
0133:                return nullValue;
0134:            }
0135:
0136:            /**
0137:             * @see StrutsParameter#isResetRequired()
0138:             */
0139:            protected boolean handleIsResetRequired() {
0140:                final boolean resetRequired;
0141:
0142:                if (isSelectable()) {
0143:                    resetRequired = true;
0144:                } else {
0145:                    final ClassifierFacade type = getType();
0146:                    if (type == null) {
0147:                        resetRequired = false;
0148:                    } else {
0149:                        resetRequired = (type.isArrayType() || type
0150:                                .isFileType()) ? true : this 
0151:                                .isValidatorBoolean();
0152:                    }
0153:                }
0154:                return resetRequired;
0155:            }
0156:
0157:            /**
0158:             * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsParameter#getMessageKey()()
0159:             */
0160:            protected java.lang.String handleGetMessageKey() {
0161:                final StringBuffer messageKey = new StringBuffer();
0162:
0163:                if (!normalizeMessages()) {
0164:                    if (isActionParameter()) {
0165:                        final StrutsAction action = this .getStrutsAction();
0166:                        if (action != null) {
0167:                            messageKey.append(action.getMessageKey());
0168:                            messageKey.append('.');
0169:                        }
0170:                    } else {
0171:                        final StrutsJsp page = getJsp();
0172:                        if (page != null) {
0173:                            messageKey.append(page.getMessageKey());
0174:                            messageKey.append('.');
0175:                        }
0176:                    }
0177:                    messageKey.append("param.");
0178:                }
0179:
0180:                messageKey.append(StringUtilsHelper.toResourceMessageKey(super 
0181:                        .getName()));
0182:                return messageKey.toString();
0183:            }
0184:
0185:            /**
0186:             * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsParameter#getMessageValue()()
0187:             */
0188:            protected java.lang.String handleGetMessageValue() {
0189:                return StringUtilsHelper.toPhrase(super .getName()); // the actual name is used for displaying
0190:            }
0191:
0192:            /**
0193:             * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsParameter#getTitleKey()()
0194:             */
0195:            protected java.lang.String handleGetTitleKey() {
0196:                return getMessageKey() + ".title";
0197:            }
0198:
0199:            /**
0200:             * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsParameter#getTitleValue()()
0201:             */
0202:            protected java.lang.String handleGetTitleValue() {
0203:                String requiredSuffix = "";
0204:                if (isRequired()) {
0205:                    requiredSuffix = " is required";
0206:                }
0207:
0208:                String dateSuffix = "";
0209:                if (isDate()) {
0210:                    dateSuffix = (isStrictDateFormat()) ? " (use this strict format: "
0211:                            + getDateFormat() + ")"
0212:                            : " (use this lenient format: " + getDateFormat()
0213:                                    + ")";
0214:                }
0215:
0216:                String documentation = getDocumentation("", 64, false);
0217:                return StringUtilsHelper.toResourceMessage((StringUtils
0218:                        .isBlank(documentation)) ? super .getName()
0219:                        + requiredSuffix + dateSuffix : documentation.trim()
0220:                        .replaceAll("\n", "<br/>"));
0221:            }
0222:
0223:            protected String handleGetDocumentationKey() {
0224:                return this .getMessageKey() + ".documentation";
0225:            }
0226:
0227:            protected String handleGetDocumentationValue() {
0228:                final String value = StringUtilsHelper.toResourceMessage(this 
0229:                        .getDocumentation("", 64, false));
0230:                return (value == null) ? "" : value;
0231:            }
0232:
0233:            protected String handleGetOnlineHelpKey() {
0234:                return this .getMessageKey() + ".online.help";
0235:            }
0236:
0237:            protected String handleGetOnlineHelpValue() {
0238:                final String crlf = "<br/>";
0239:                final String format = getValidatorFormat();
0240:                final StringBuffer buffer = new StringBuffer();
0241:
0242:                final String value = StringUtilsHelper.toResourceMessage(this 
0243:                        .getDocumentation("", 64, false));
0244:                buffer
0245:                        .append((value == null) ? "No field documentation has been specified"
0246:                                : value);
0247:                buffer.append(crlf);
0248:                buffer.append(crlf);
0249:
0250:                buffer.append(isRequired() ? "This field is required"
0251:                        : "This field is optional");
0252:                buffer.append(crlf);
0253:
0254:                if ("password".equals(getWidgetType())) {
0255:                    buffer
0256:                            .append(
0257:                                    "This is a password field, it will not show the data you enter, ")
0258:                            .append(
0259:                                    "each character will be masked using an asterisk");
0260:                    buffer.append(crlf);
0261:                }
0262:
0263:                if (isCreditCardFormat(format)) {
0264:                    buffer
0265:                            .append("The value of this field should reflect a ")
0266:                            .append(
0267:                                    "<a href=\"http://www.beachnet.com/~hstiles/cardtype.html\" target=\"_blank\">creditcard</a> ");
0268:                    buffer.append(crlf);
0269:                }
0270:
0271:                if (isDate()) {
0272:                    String dateFormat = getDateFormat();
0273:                    buffer
0274:                            .append(
0275:                                    "This field represents a date and should be formatted in the matter described here")
0276:                            .append(
0277:                                    "<a href=\"http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html\" ")
0278:                            .append("target=\"_jdk\">");
0279:                    buffer.append(dateFormat).append("</a> ");
0280:
0281:                    if (isStrictDateFormat())
0282:                        buffer
0283:                                .append(
0284:                                        "This format is strict in the sense that the parser will not use any heuristics in ")
0285:                                .append(
0286:                                        "order to guess the intended date in case the input would not perfectly match the format");
0287:                    else {
0288:                        buffer
0289:                                .append(
0290:                                        "This format is lenient in the sense that the parser will attempt to use heuristics in ")
0291:                                .append(
0292:                                        "order to guess the intended date in case the input would not perfectly match the format");
0293:                    }
0294:                    buffer.append(crlf);
0295:                    buffer
0296:                            .append(
0297:                                    "A calendar has been foreseen to select a date from, it will automatically convert the date ")
0298:                            .append("to the appropriate format.");
0299:                    buffer.append(crlf);
0300:                }
0301:
0302:                if (this .isValidatorTime()) {
0303:                    String dateFormat = getDateFormat();
0304:                    buffer
0305:                            .append(
0306:                                    "This field represents a time and should be formatted in the manner described here (for time) ")
0307:                            .append(
0308:                                    "<a href=\"http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html\" ")
0309:                            .append("target=\"_jdk\">");
0310:                    buffer.append(dateFormat).append("</a> ");
0311:                }
0312:
0313:                if (isEmailFormat(format)) {
0314:                    buffer
0315:                            .append("The value of this field should reflect an email address");
0316:                    buffer.append(crlf);
0317:                }
0318:
0319:                if (isMaxLengthFormat(format)) {
0320:                    buffer.append("This field should not contain more than ");
0321:                    buffer.append(getMaxLengthValue(format));
0322:                    buffer.append(" characters");
0323:                    buffer.append(crlf);
0324:                }
0325:
0326:                if (isMinLengthFormat(format)) {
0327:                    buffer.append("This field should contain at least ");
0328:                    buffer.append(getMinLengthValue(format));
0329:                    buffer.append(" characters");
0330:                    buffer.append(crlf);
0331:                }
0332:
0333:                if (isPatternFormat(format)) {
0334:                    buffer.append("The value should match this ");
0335:                    buffer
0336:                            .append("<a href=\"http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html\" target=\"_jdk\">");
0337:                    buffer.append("regular expression</a>: ");
0338:                    buffer.append(getPatternValue(format));
0339:                    buffer.append(crlf);
0340:                }
0341:
0342:                if (isRangeFormat(format)) {
0343:                    buffer
0344:                            .append("The value of this field should be in the range of ");
0345:                    buffer.append(getRangeStart(format));
0346:                    buffer.append(" to ");
0347:                    buffer.append(getRangeEnd(format));
0348:                    buffer.append(crlf);
0349:                }
0350:
0351:                final String validWhen = getValidWhen();
0352:                if (validWhen != null) {
0353:                    buffer
0354:                            .append(
0355:                                    "This field is only valid under specific conditions, more concretely the following ")
0356:                            .append("expression must evaluate true: ").append(
0357:                                    validWhen);
0358:                    buffer.append(crlf);
0359:                }
0360:
0361:                if (isReadOnly()) {
0362:                    buffer
0363:                            .append("The value of this field cannot be changed, it is read-only");
0364:                    buffer.append(crlf);
0365:                }
0366:
0367:                if (isValidatorBoolean()) {
0368:                    buffer
0369:                            .append("The value of this field should reflect a ")
0370:                            .append(
0371:                                    "<a href=\"http://java.sun.com/docs/books/tutorial/java/nutsandbolts/datatypes.html\" ")
0372:                            .append("target=\"_jdk\">boolean</a> value");
0373:                    buffer.append(crlf);
0374:                } else if (isValidatorByte()) {
0375:                    buffer
0376:                            .append("The value of this field should reflect a ")
0377:                            .append(
0378:                                    "<a href=\"http://java.sun.com/docs/books/tutorial/java/nutsandbolts/datatypes.html\" ")
0379:                            .append("target=\"_jdk\">byte</a> value");
0380:                    buffer.append(crlf);
0381:                } else if (isValidatorChar()) {
0382:                    buffer
0383:                            .append("The value of this field should reflect a ")
0384:                            .append(
0385:                                    "<a href=\"http://java.sun.com/docs/books/tutorial/java/nutsandbolts/datatypes.html\" ")
0386:                            .append("target=\"_jdk\">character</a> value");
0387:                    buffer.append(crlf);
0388:                } else if (isValidatorDouble()) {
0389:                    buffer
0390:                            .append("The value of this field should reflect a ")
0391:                            .append(
0392:                                    "<a href=\"http://java.sun.com/docs/books/tutorial/java/nutsandbolts/datatypes.html\" ")
0393:                            .append(
0394:                                    "target=\"_jdk\">double precision integer</a> value");
0395:                    buffer.append(crlf);
0396:                } else if (isValidatorFloat()) {
0397:                    buffer
0398:                            .append("The value of this field should reflect a ")
0399:                            .append(
0400:                                    "<a href=\"http://java.sun.com/docs/books/tutorial/java/nutsandbolts/datatypes.html\" ")
0401:                            .append("target=\"_jdk\">floating point</a> value");
0402:                    buffer.append(crlf);
0403:                } else if (isValidatorInteger()) {
0404:                    buffer
0405:                            .append("The value of this field should reflect a ")
0406:                            .append(
0407:                                    "<a href=\"http://java.sun.com/docs/books/tutorial/java/nutsandbolts/datatypes.html\" ")
0408:                            .append("target=\"_jdk\">integer</a> value");
0409:                    buffer.append(crlf);
0410:                } else if (isValidatorLong()) {
0411:                    buffer
0412:                            .append("The value of this field should reflect a ")
0413:                            .append(
0414:                                    "<a href=\"http://java.sun.com/docs/books/tutorial/java/nutsandbolts/datatypes.html\" ")
0415:                            .append("target=\"_jdk\">long integer</a> value");
0416:                    buffer.append(crlf);
0417:                } else if (isValidatorShort()) {
0418:                    buffer
0419:                            .append("The value of this field should reflect a ")
0420:                            .append(
0421:                                    "<a href=\"http://java.sun.com/docs/books/tutorial/java/nutsandbolts/datatypes.html\" ")
0422:                            .append("target=\"_jdk\">short integer</a> value");
0423:                    buffer.append(crlf);
0424:                } else if (isValidatorUrl()) {
0425:                    buffer
0426:                            .append("The value of this field should reflect a ")
0427:                            .append(
0428:                                    "<a href=\"http://java.sun.com/j2se/1.4.2/docs/api/java/net/URL.html\" ")
0429:                            .append("target=\"_jdk\">URL</a> value");
0430:                    buffer.append(crlf);
0431:                }
0432:
0433:                return StringUtilsHelper.toResourceMessage(buffer.toString());
0434:            }
0435:
0436:            protected boolean handleIsCalendarRequired() {
0437:                return isDate()
0438:                        && String
0439:                                .valueOf(
0440:                                        findTaggedValue(Bpm4StrutsProfile.TAGGEDVALUE_INPUT_CALENDAR))
0441:                                .equals("true");
0442:            }
0443:
0444:            /**
0445:             * Overridden since StrutsAction does not extend FrontEndAction.
0446:             *
0447:             * @see org.andromda.metafacades.uml.FrontEndParameter#isActionParameter()
0448:             */
0449:            public boolean isActionParameter() {
0450:                final StrutsAction action = getStrutsAction();
0451:                return (action != null)
0452:                        && action.getActionParameters().contains(this );
0453:            }
0454:
0455:            protected String handleGetCollectionImplementationType() {
0456:                String typeName = null;
0457:
0458:                final ClassifierFacade type = this .getType();
0459:                if (type != null) {
0460:                    if (type.isCollectionType() || type.isListType()) {
0461:                        typeName = "java.util.ArrayList";
0462:                    } else if (type.isSetType()) {
0463:                        typeName = "java.util.HashSet";
0464:                    } else {
0465:                        typeName = type.getFullyQualifiedName();
0466:                    }
0467:                }
0468:                return typeName;
0469:            }
0470:
0471:            protected boolean handleIsTableDecoratorRequired() {
0472:                boolean required = false;
0473:
0474:                if (isTable()) {
0475:                    final Object taggedValue = findTaggedValue(Bpm4StrutsProfile.TAGGEDVALUE_TABLE_DECORATOR);
0476:                    if (taggedValue != null) {
0477:                        final String taggedValueString = String
0478:                                .valueOf(taggedValue);
0479:                        required = Boolean.valueOf(taggedValueString)
0480:                                .booleanValue();
0481:                    } else {
0482:                        final Object property = getConfiguredProperty(Bpm4StrutsGlobals.PROPERTY_GENERATE_TABLE_DECORATORS);
0483:                        final String propertyString = String.valueOf(property);
0484:                        required = Boolean.valueOf(propertyString)
0485:                                .booleanValue();
0486:                    }
0487:                }
0488:
0489:                return required;
0490:            }
0491:
0492:            /**
0493:             * Override to not allow selectable parameters to be considered tables.
0494:             * 
0495:             * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsParameterLogic#isTable()
0496:             */
0497:            public boolean isTable() {
0498:                return super .isTable() && !this .isSelectable();
0499:            }
0500:
0501:            protected boolean handleIsAllGlobalTableActionsHaveSameParameter() {
0502:                boolean sameParameter = true;
0503:
0504:                String name = null;
0505:                String type = null;
0506:
0507:                final Collection actions = this .getTableGlobalActions();
0508:                for (final Iterator actionIterator = actions.iterator(); actionIterator
0509:                        .hasNext()
0510:                        && sameParameter;) {
0511:                    final StrutsAction action = (StrutsAction) actionIterator
0512:                            .next();
0513:                    final List parameters = action.getActionParameters();
0514:                    if (!parameters.isEmpty()) {
0515:                        final StrutsParameter parameter = (StrutsParameter) parameters
0516:                                .iterator().next();
0517:                        if (name == null || type == null) {
0518:                            name = parameter.getName();
0519:                            type = parameter.getType().getFullyQualifiedName();
0520:                        } else {
0521:                            sameParameter = name.equals(parameter.getName())
0522:                                    && type.equals(parameter.getType()
0523:                                            .getFullyQualifiedName());
0524:                        }
0525:                    }
0526:                }
0527:
0528:                return sameParameter;
0529:            }
0530:
0531:            protected List handleGetTableFormActions() {
0532:                return this .internalGetTableActions(false, true, false);
0533:            }
0534:
0535:            protected List handleGetTableHyperlinkActions() {
0536:                return this .internalGetTableActions(true, false, false);
0537:            }
0538:
0539:            protected Collection handleGetTableGlobalActions() {
0540:                return this .internalGetTableActions(false, false, true);
0541:            }
0542:
0543:            protected Object handleGetTableGlobalActionParameter() {
0544:                Object parameter = null;
0545:
0546:                final Collection actions = this .getTableGlobalActions();
0547:                if (!actions.isEmpty()) {
0548:                    final List actionParameters = ((StrutsAction) actions
0549:                            .iterator().next()).getActionParameters();
0550:                    if (!actionParameters.isEmpty()) {
0551:                        parameter = actionParameters.iterator().next();
0552:                    }
0553:                }
0554:
0555:                return parameter;
0556:            }
0557:
0558:            protected boolean handleIsTableFormActionSharingWidgets() {
0559:                // @todo (wouter)
0560:                return true;
0561:            }
0562:
0563:            /**
0564:             * If this is a table this method returns all those actions that are declared to work
0565:             * on this table.
0566:             */
0567:            private List internalGetTableActions(boolean hyperlink,
0568:                    boolean formPost, boolean tableAction) {
0569:                final String name = StringUtils.trimToNull(getName());
0570:                if (name == null || !isTable()) {
0571:                    return Collections.EMPTY_LIST;
0572:                }
0573:
0574:                final StrutsJsp page = this .getJsp();
0575:
0576:                final Collection tableActions = new LinkedHashSet();
0577:
0578:                final Collection allUseCases = getModel().getAllUseCases();
0579:                for (final Iterator useCaseIterator = allUseCases.iterator(); useCaseIterator
0580:                        .hasNext();) {
0581:                    final UseCaseFacade useCase = (UseCaseFacade) useCaseIterator
0582:                            .next();
0583:                    if (useCase instanceof  StrutsUseCase) {
0584:                        final FrontEndActivityGraph graph = ((StrutsUseCase) useCase)
0585:                                .getActivityGraph();
0586:                        if (graph != null) {
0587:                            final Collection transitions = graph
0588:                                    .getTransitions();
0589:                            for (final Iterator transitionIterator = transitions
0590:                                    .iterator(); transitionIterator.hasNext();) {
0591:                                final TransitionFacade transition = (TransitionFacade) transitionIterator
0592:                                        .next();
0593:                                if (transition.getSource().equals(page)
0594:                                        && transition instanceof  StrutsAction) {
0595:                                    final StrutsAction action = (StrutsAction) transition;
0596:                                    if (action.isTableLink()
0597:                                            && name.equals(action
0598:                                                    .getTableLinkName())) {
0599:                                        if ((hyperlink && action.isHyperlink())
0600:                                                || (formPost && action
0601:                                                        .isFormPost())
0602:                                                || (tableAction && action
0603:                                                        .isTableAction())) {
0604:                                            tableActions.add(action);
0605:                                        }
0606:                                    }
0607:                                }
0608:                            }
0609:                        }
0610:                    }
0611:                }
0612:                return new ArrayList(tableActions);
0613:            }
0614:
0615:            protected String handleGetTableDecoratorFullyQualifiedName() {
0616:                String name = getTableDecoratorPackageName();
0617:                name = (StringUtils.trimToEmpty(name) == null) ? ""
0618:                        : name + '.';
0619:                return name + getTableDecoratorClassName();
0620:            }
0621:
0622:            protected String handleGetTableDecoratorPackageName() {
0623:                final StrutsJsp jsp = getJsp();
0624:                return (jsp == null) ? null : jsp.getPackageName();
0625:            }
0626:
0627:            protected String handleGetTableDecoratorClassName() {
0628:                String tableDecoratorClassName = null;
0629:
0630:                final StrutsJsp jsp = getJsp();
0631:                if (jsp != null) {
0632:                    String suffix = String
0633:                            .valueOf(getConfiguredProperty(Bpm4StrutsGlobals.PROPERTY_TABLE_DECORATOR_SUFFIX));
0634:                    tableDecoratorClassName = StringUtilsHelper
0635:                            .upperCamelCaseName(getName())
0636:                            + suffix;
0637:                }
0638:
0639:                return tableDecoratorClassName;
0640:            }
0641:
0642:            protected String handleGetTableDecoratorFullPath() {
0643:                return getTableDecoratorFullyQualifiedName().replace('.', '/');
0644:            }
0645:
0646:            protected String handleGetTableExportTypes() {
0647:                return Bpm4StrutsUtils
0648:                        .getDisplayTagExportTypes(
0649:                                this 
0650:                                        .findTaggedValues(Bpm4StrutsProfile.TAGGEDVALUE_TABLE_EXPORT),
0651:                                (String) getConfiguredProperty(Bpm4StrutsGlobals.PROPERTY_DEFAULT_TABLE_EXPORT_TYPES));
0652:            }
0653:
0654:            protected boolean handleIsTableExportable() {
0655:                return this .getTableExportTypes().indexOf("none") == -1;
0656:            }
0657:
0658:            protected boolean handleIsTableSortable() {
0659:                final Object taggedValue = this 
0660:                        .findTaggedValue(Bpm4StrutsProfile.TAGGEDVALUE_TABLE_SORTABLE);
0661:                return (taggedValue == null) ? Bpm4StrutsProfile.TAGGEDVALUE_TABLE_SORTABLE_DEFAULT_VALUE
0662:                        : Bpm4StrutsUtils.isTrue(String.valueOf(taggedValue));
0663:            }
0664:
0665:            protected boolean handleIsTableHyperlinkColumn() {
0666:                boolean tableHyperlinkColumn = false;
0667:
0668:                final String name = this .getName();
0669:                if (name != null) {
0670:                    // this parameter's action must be a table hyperlink
0671:                    final StrutsAction action = this .getStrutsAction();
0672:                    if (action.isHyperlink() && action.isTableLink()) {
0673:                        // get the table and check whether this parameter is part of that table's columns
0674:                        final StrutsParameter table = action
0675:                                .getTableLinkParameter();
0676:                        if (table != null) {
0677:                            final Collection tableColumns = table
0678:                                    .getTableColumns();
0679:                            // if this parameter's name matches that targetted column name then we have found our column
0680:                            tableHyperlinkColumn = tableColumns.contains(this )
0681:                                    && name.equals(action
0682:                                            .getTableLinkColumnName());
0683:                        }
0684:                    }
0685:                }
0686:
0687:                return tableHyperlinkColumn;
0688:            }
0689:
0690:            protected List handleGetTableColumnActions(final String columnName) {
0691:                final List columnActions = new ArrayList();
0692:
0693:                if (columnName != null) {
0694:                    // only hyperlinks can target table columns
0695:                    final List hyperlinkActions = this 
0696:                            .getTableHyperlinkActions();
0697:                    for (int i = 0; i < hyperlinkActions.size(); i++) {
0698:                        final StrutsAction action = (StrutsAction) hyperlinkActions
0699:                                .get(i);
0700:                        if (columnName.equals(action.getTableLinkColumnName())) {
0701:                            columnActions.add(action);
0702:                        }
0703:                    }
0704:                }
0705:
0706:                return columnActions;
0707:            }
0708:
0709:            /**
0710:             * @return true if this parameter represents a table and is an array of custom types (no datatype)
0711:             */
0712:            private boolean isCustomArrayTable() {
0713:                final ClassifierFacade type = this .getType();
0714:                return type != null && this .isTable() && type.isArrayType()
0715:                        && !type.isDataType();
0716:            }
0717:
0718:            /**
0719:             * Overridden since StrutsAction doesn't extend FrontEndAction.
0720:             * 
0721:             * @see org.andromda.metafacades.uml.FrontEndParameter#getTableColumns()
0722:             */
0723:            public Collection getTableColumns() {
0724:                // in this method we collect the elements that represent the columns of a table
0725:                // if no specific element (parameter, attribute) can be found a simple String instance
0726:                // is used
0727:                // the event parameters have priority to be included in the collection because
0728:                // they contain additional information such as validation constraint and widget type, ...
0729:
0730:                // try to preserve the order of the elements encountered
0731:                final Map tableColumnsMap = new LinkedHashMap();
0732:
0733:                // order is important
0734:                final List actions = new ArrayList();
0735:
0736:                // all table actions need the exact same parameters, just not always all of them
0737:                actions.addAll(this .getTableFormActions());
0738:                // if there are any actions that are hyperlinks then their parameters get priority
0739:                // the user should not have modeled it that way (constraints will warn him/her)
0740:                actions.addAll(this .getTableHyperlinkActions());
0741:
0742:                for (final Iterator actionIterator = actions.iterator(); actionIterator
0743:                        .hasNext();) {
0744:                    final StrutsAction action = (StrutsAction) actionIterator
0745:                            .next();
0746:                    final Collection actionParameters = action
0747:                            .getActionParameters();
0748:                    for (final Iterator parameterIterator = actionParameters
0749:                            .iterator(); parameterIterator.hasNext();) {
0750:                        final StrutsParameter parameter = (StrutsParameter) parameterIterator
0751:                                .next();
0752:                        final String parameterName = parameter.getName();
0753:                        if (parameterName != null) {
0754:                            // never overwrite column specific table links
0755:                            // the hyperlink table links working on a real column get priority
0756:                            final StrutsParameter existingParameter = (StrutsParameter) tableColumnsMap
0757:                                    .get(parameterName);
0758:                            if (existingParameter == null
0759:                                    || (action.isHyperlink() && parameterName
0760:                                            .equals(action
0761:                                                    .getTableLinkColumnName()))) {
0762:                                tableColumnsMap.put(parameterName, parameter);
0763:                            }
0764:                        }
0765:                    }
0766:                }
0767:
0768:                final Collection columnNames = this .getTableColumnNames();
0769:
0770:                // in case of a custom array just add the attributes
0771:                if (this .isCustomArrayTable()) {
0772:                    final Collection attributes = this .getType().getNonArray()
0773:                            .getAttributes();
0774:                    for (final Iterator attributeIterator = attributes
0775:                            .iterator(); attributeIterator.hasNext();) {
0776:                        final ModelElementFacade attribute = (ModelElementFacade) attributeIterator
0777:                                .next();
0778:                        // don't override
0779:                        if (!tableColumnsMap.containsKey(attribute.getName())) {
0780:                            tableColumnsMap.put(attribute.getName(), attribute);
0781:                        }
0782:                    }
0783:                } else {
0784:                    for (final Iterator columnNameIterator = columnNames
0785:                            .iterator(); columnNameIterator.hasNext();) {
0786:                        final String columnName = (String) columnNameIterator
0787:                                .next();
0788:                        // don't override
0789:                        if (!tableColumnsMap.containsKey(columnName)) {
0790:                            tableColumnsMap.put(columnName, columnName);
0791:                        }
0792:                    }
0793:                }
0794:
0795:                // return everything in the same order as it has been modeled (using the table tagged value)
0796:                // note that only those columns mentioned in the tagged value are returned
0797:                final Collection tableColumns = new ArrayList();
0798:                for (final Iterator columnNameIterator = columnNames.iterator(); columnNameIterator
0799:                        .hasNext();) {
0800:                    final Object columnObject = columnNameIterator.next();
0801:                    tableColumns.add(tableColumnsMap.get(columnObject));
0802:                }
0803:                return tableColumns;
0804:            }
0805:
0806:            protected String handleGetTableColumnMessageKey(String columnName) {
0807:                StringBuffer messageKey = null;
0808:
0809:                if (isTable()) {
0810:                    messageKey = new StringBuffer();
0811:
0812:                    if (!normalizeMessages()) {
0813:                        final StrutsJsp page = getJsp();
0814:                        if (page != null) {
0815:                            messageKey.append(getMessageKey());
0816:                            messageKey.append('.');
0817:                        }
0818:                    }
0819:
0820:                    messageKey.append(StringUtilsHelper
0821:                            .toResourceMessageKey(columnName));
0822:                }
0823:
0824:                return (messageKey == null) ? null : messageKey.toString();
0825:            }
0826:
0827:            protected String handleGetTableColumnMessageValue(String columnName) {
0828:                return (isTable()) ? StringUtilsHelper.toPhrase(columnName)
0829:                        : null;
0830:            }
0831:
0832:            protected int handleGetTableMaxRows() {
0833:                final Object taggedValue = this 
0834:                        .findTaggedValue(Bpm4StrutsProfile.TAGGEDVALUE_TABLE_MAXROWS);
0835:                int pageSize;
0836:
0837:                try {
0838:                    pageSize = Integer.parseInt(String.valueOf(taggedValue));
0839:                } catch (Exception e) {
0840:                    pageSize = Bpm4StrutsProfile.TAGGEDVALUE_TABLE_MAXROWS_DEFAULT_COUNT;
0841:                }
0842:
0843:                return pageSize;
0844:            }
0845:
0846:            protected String handleGetWidgetType() {
0847:                Object value = findTaggedValue(Bpm4StrutsProfile.TAGGEDVALUE_INPUT_TYPE);
0848:                final String fieldType = value == null ? null : value
0849:                        .toString();
0850:
0851:                String widgetType = null;
0852:
0853:                if (isActionParameter()) {
0854:                    if (fieldType == null) {
0855:                        // no widget type has been specified
0856:                        final ClassifierFacade type = getType();
0857:                        if (type != null) {
0858:                            if (type.isFileType())
0859:                                widgetType = Bpm4StrutsProfile.TAGGEDVALUE_INPUT_TYPE_FILE;
0860:                            else if (isValidatorBoolean())
0861:                                widgetType = Bpm4StrutsProfile.TAGGEDVALUE_INPUT_TYPE_CHECKBOX;
0862:                            else if (isMultiple())
0863:                                widgetType = Bpm4StrutsProfile.TAGGEDVALUE_INPUT_TYPE_SELECT;
0864:                            else
0865:                                widgetType = Bpm4StrutsProfile.TAGGEDVALUE_INPUT_TYPE_TEXT;
0866:                        }
0867:                    } else if (Bpm4StrutsProfile.TAGGEDVALUE_INPUT_TYPE_SELECT
0868:                            .equalsIgnoreCase(fieldType)) {
0869:                        widgetType = "select";
0870:                    } else if (Bpm4StrutsProfile.TAGGEDVALUE_INPUT_TYPE_PASSWORD
0871:                            .equalsIgnoreCase(fieldType)) {
0872:                        widgetType = "password";
0873:                    } else if (Bpm4StrutsProfile.TAGGEDVALUE_INPUT_TYPE_TEXTAREA
0874:                            .equalsIgnoreCase(fieldType)) {
0875:                        widgetType = "textarea";
0876:                    } else if (Bpm4StrutsProfile.TAGGEDVALUE_INPUT_TYPE_HIDDEN
0877:                            .equalsIgnoreCase(fieldType)) {
0878:                        widgetType = HIDDEN_INPUT_TYPE;
0879:                    } else if (fieldType.toLowerCase().startsWith(
0880:                            Bpm4StrutsProfile.TAGGEDVALUE_INPUT_TYPE_RADIO)) {
0881:                        widgetType = "radio";
0882:                    } else if (Bpm4StrutsProfile.TAGGEDVALUE_INPUT_TYPE_CHECKBOX
0883:                            .equalsIgnoreCase(fieldType)) {
0884:                        widgetType = "checkbox";
0885:                    } else if (Bpm4StrutsProfile.TAGGEDVALUE_INPUT_TYPE_PLAINTEXT
0886:                            .equalsIgnoreCase(fieldType)) {
0887:                        widgetType = "plaintext";
0888:                    } else if (Bpm4StrutsProfile.TAGGEDVALUE_INPUT_TYPE_TEXT
0889:                            .equalsIgnoreCase(fieldType)) {
0890:                        widgetType = "text";
0891:                    } else if (Bpm4StrutsProfile.TAGGEDVALUE_INPUT_TYPE_MULTIBOX
0892:                            .equalsIgnoreCase(fieldType)) {
0893:                        if (getMultiboxPropertyName() != null) {
0894:                            widgetType = "multibox";
0895:                        }
0896:                    } else if (Bpm4StrutsProfile.TAGGEDVALUE_INPUT_TYPE_LINK
0897:                            .equalsIgnoreCase(fieldType)) {
0898:                        final StrutsAction action = getStrutsAction();
0899:                        if (action != null) {
0900:                            if (action.isTableLink()) {
0901:                                widgetType = "link";
0902:                            }
0903:                        }
0904:                    } else {
0905:                        widgetType = (isMultiple()) ? "select" : "text";
0906:                    }
0907:                }
0908:                return widgetType;
0909:            }
0910:
0911:            /**
0912:             * The input type representing a 'hidden' parameter.
0913:             */
0914:            static final String HIDDEN_INPUT_TYPE = "hidden";
0915:
0916:            protected boolean handleIsFile() {
0917:                boolean file = false;
0918:
0919:                ClassifierFacade type = getType();
0920:                if (type != null) {
0921:                    file = type.isFileType();
0922:                }
0923:                return file;
0924:            }
0925:
0926:            protected boolean handleIsMultiple() {
0927:                boolean multiple = false;
0928:
0929:                ClassifierFacade type = getType();
0930:                if (type != null) {
0931:                    multiple = type.isCollectionType() || type.isArrayType();
0932:                }
0933:                return multiple;
0934:            }
0935:
0936:            protected String handleGetBackingListName() {
0937:                return getName() + "BackingList";
0938:            }
0939:
0940:            protected String handleGetValueListResetValue() {
0941:                return constructArray();
0942:            }
0943:
0944:            protected boolean handleIsSelectable() {
0945:                boolean selectable = false;
0946:
0947:                if (isActionParameter()) {
0948:                    selectable = Bpm4StrutsProfile.TAGGEDVALUE_INPUT_TYPE_SELECT
0949:                            .equals(getWidgetType());
0950:                    final ClassifierFacade type = getType();
0951:
0952:                    if (!selectable && type != null) {
0953:                        final String name = getName();
0954:                        final String typeName = type.getFullyQualifiedName();
0955:
0956:                        /**
0957:                         * if the parameter is not selectable but on a targetting page it _is_ selectable we must
0958:                         * allow the user to set the backing list too
0959:                         */
0960:                        final Collection pages = getStrutsAction()
0961:                                .getTargetPages();
0962:                        for (final Iterator pageIterator = pages.iterator(); pageIterator
0963:                                .hasNext()
0964:                                && !selectable;) {
0965:                            final StrutsJsp page = (StrutsJsp) pageIterator
0966:                                    .next();
0967:                            final Collection parameters = page
0968:                                    .getAllActionParameters();
0969:                            for (final Iterator parameterIterator = parameters
0970:                                    .iterator(); parameterIterator.hasNext()
0971:                                    && !selectable;) {
0972:                                final StrutsParameter parameter = (StrutsParameter) parameterIterator
0973:                                        .next();
0974:                                final String parameterName = parameter
0975:                                        .getName();
0976:                                final ClassifierFacade parameterType = parameter
0977:                                        .getType();
0978:                                if (parameterType != null) {
0979:                                    final String parameterTypeName = parameterType
0980:                                            .getFullyQualifiedName();
0981:                                    if (name.equals(parameterName)
0982:                                            && typeName
0983:                                                    .equals(parameterTypeName)) {
0984:                                        selectable = Bpm4StrutsProfile.TAGGEDVALUE_INPUT_TYPE_SELECT
0985:                                                .equals(parameter
0986:                                                        .getWidgetType());
0987:                                    }
0988:                                }
0989:                            }
0990:                        }
0991:                    }
0992:                } else if (isControllerOperationArgument()) {
0993:                    final String name = this .getName();
0994:                    final Collection actions = this .getControllerOperation()
0995:                            .getDeferringActions();
0996:                    for (final Iterator actionIterator = actions.iterator(); actionIterator
0997:                            .hasNext();) {
0998:                        final StrutsAction action = (StrutsAction) actionIterator
0999:                                .next();
1000:                        final Collection formFields = action
1001:                                .getActionFormFields();
1002:                        for (final Iterator fieldIterator = formFields
1003:                                .iterator(); fieldIterator.hasNext()
1004:                                && !selectable;) {
1005:                            final StrutsParameter parameter = (StrutsParameter) fieldIterator
1006:                                    .next();
1007:                            if (name.equals(parameter.getName())) {
1008:                                selectable = parameter.isSelectable();
1009:                            }
1010:                        }
1011:                    }
1012:                }
1013:                return selectable;
1014:            }
1015:
1016:            /**
1017:             * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsParameter#getValueListName()
1018:             */
1019:            protected String handleGetValueListName() {
1020:                return getName() + "ValueList";
1021:            }
1022:
1023:            /**
1024:             * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsParameter#getLabelListName()
1025:             */
1026:            protected String handleGetLabelListName() {
1027:                return getName() + "LabelList";
1028:            }
1029:
1030:            /**
1031:             * @return A String representing Java code for the initialization of an array using 5 elements.
1032:             */
1033:            private String constructArray() {
1034:                final String name = getName();
1035:                return "new Object[] {\"" + name + "-1\", \"" + name
1036:                        + "-2\", \"" + name + "-3\", \"" + name + "-4\", \""
1037:                        + name + "-5\"}";
1038:            }
1039:
1040:            /**
1041:             * Override normal parameter facade required implementation.
1042:             *
1043:             * @see org.andromda.metafacades.uml.ParameterFacade#isRequired()
1044:             */
1045:            public boolean isRequired() {
1046:                final Object value = this 
1047:                        .findTaggedValue(Bpm4StrutsProfile.TAGGEDVALUE_INPUT_REQUIRED);
1048:                return Bpm4StrutsUtils.isTrue(value == null ? null : String
1049:                        .valueOf(value));
1050:            }
1051:
1052:            /**
1053:             * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsParameter#isReadOnly()
1054:             */
1055:            protected boolean handleIsReadOnly() {
1056:                final Object value = this 
1057:                        .findTaggedValue(Bpm4StrutsProfile.TAGGEDVALUE_INPUT_READONLY);
1058:                return Bpm4StrutsUtils.isTrue(value == null ? null : String
1059:                        .valueOf(value));
1060:            }
1061:
1062:            /**
1063:             * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsParameter#isDate()
1064:             */
1065:            protected boolean handleIsDate() {
1066:                return this .isValidatorDate();
1067:            }
1068:
1069:            /**
1070:             * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsParameter#getDateFormat()
1071:             */
1072:            protected String handleGetDateFormat() {
1073:                final String format = this .getValidatorFormat();
1074:                return format == null ? this .getDefaultDateFormat() : this 
1075:                        .getDateFormat(format);
1076:            }
1077:
1078:            /**
1079:             * @return the default date format pattern as defined using the configured property
1080:             */
1081:            private String getDefaultDateFormat() {
1082:                return (String) getConfiguredProperty(Bpm4StrutsGlobals.PROPERTY_DEFAULT_DATEFORMAT);
1083:            }
1084:
1085:            /**
1086:             * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsParameter#getTimeFormat()
1087:             */
1088:            protected String handleGetTimeFormat() {
1089:                final String format = this .getValidatorFormat();
1090:                return format == null ? this .getDefaultTimeFormat() : format;
1091:            }
1092:
1093:            /**
1094:             * @return the default time format pattern as defined using the configured property
1095:             */
1096:            private String getDefaultTimeFormat() {
1097:                return (String) this 
1098:                        .getConfiguredProperty(Bpm4StrutsGlobals.PROPERTY_DEFAULT_TIMEFORMAT);
1099:            }
1100:
1101:            /**
1102:             * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsParameter#isStrictDateFormat()
1103:             */
1104:            protected boolean handleIsStrictDateFormat() {
1105:                final String format = this .getValidatorFormat();
1106:                return format == null ? Bpm4StrutsUtils
1107:                        .isTrue((String) this 
1108:                                .getConfiguredProperty(Bpm4StrutsGlobals.PROPERTY_STRICT_DATETIMEFORMAT))
1109:                        : this .isStrictDateFormat(format);
1110:            }
1111:
1112:            /**
1113:             * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsParameter#getResetValue()
1114:             */
1115:            protected String handleGetResetValue() {
1116:                final ClassifierFacade type = getType();
1117:                if (type != null) {
1118:                    final String name = getName();
1119:
1120:                    if (isValidatorString())
1121:                        return "\"" + name + "-test" + "\"";
1122:                    if (isValidatorDate())
1123:                        return "new java.util.Date()";
1124:
1125:                    if (type.isPrimitive()) {
1126:                        if (isValidatorInteger())
1127:                            return "(int)" + name.hashCode();
1128:                        if (isValidatorBoolean())
1129:                            return "false";
1130:                        if (isValidatorLong())
1131:                            return "(long)" + name.hashCode();
1132:                        if (isValidatorChar())
1133:                            return "(char)" + name.hashCode();
1134:                        if (isValidatorFloat())
1135:                            return "(float)" + name.hashCode();
1136:                        if (isValidatorDouble())
1137:                            return "(double)" + name.hashCode();
1138:                        if (isValidatorShort())
1139:                            return "(short)" + name.hashCode();
1140:                        if (isValidatorByte())
1141:                            return "(byte)" + name.hashCode();
1142:                    } else {
1143:                        if (isValidatorInteger())
1144:                            return "new Integer((int)" + name.hashCode() + ")";
1145:                        if (isValidatorBoolean())
1146:                            return "Boolean.FALSE";
1147:                        if (isValidatorLong())
1148:                            return "new Long((long)" + name.hashCode() + ")";
1149:                        if (isValidatorChar())
1150:                            return "new Character(char)" + name.hashCode()
1151:                                    + ")";
1152:                        if (isValidatorFloat())
1153:                            return "new Float((float)" + name.hashCode() + ")";
1154:                        if (isValidatorDouble())
1155:                            return "new Double((double)" + name.hashCode()
1156:                                    + ")";
1157:                        if (isValidatorShort())
1158:                            return "new Short((short)" + name.hashCode() + ")";
1159:                        if (isValidatorByte())
1160:                            return "new Byte((byte)" + name.hashCode() + ")";
1161:                    }
1162:
1163:                    if (type.isArrayType())
1164:                        return constructArray();
1165:                    if (type.isSetType())
1166:                        return "new java.util.HashSet(java.util.Arrays.asList("
1167:                                + constructArray() + "))";
1168:                    if (type.isCollectionType())
1169:                        return "java.util.Arrays.asList(" + constructArray()
1170:                                + ")";
1171:
1172:                    // maps and others types will simply not be treated
1173:                }
1174:                return "null";
1175:            }
1176:
1177:            /**
1178:             * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsParameter#isValidationRequired()
1179:             */
1180:            protected boolean handleIsValidationRequired() {
1181:                final String disableValidationForHiddenFormFields = (String) getConfiguredProperty(Bpm4StrutsGlobals.DISABLE_VALIDATION_FOR_HIDDEN_FORM_FIELDS);
1182:                return !("true".equals(disableValidationForHiddenFormFields) && "hidden"
1183:                        .equals(getWidgetType()))
1184:                        && !getValidatorTypes().isEmpty();
1185:            }
1186:
1187:            private String getValidatorFormat() {
1188:                Object value = findTaggedValue(Bpm4StrutsProfile.TAGGEDVALUE_INPUT_FORMAT);
1189:                final String format = value == null ? null : String
1190:                        .valueOf(value);
1191:                return (format == null) ? null : format.trim();
1192:            }
1193:
1194:            protected java.util.Collection handleGetValidatorTypes() {
1195:                final Collection validatorTypesList = new ArrayList();
1196:
1197:                ClassifierFacade type = getType();
1198:                if (type != null) {
1199:                    final String format = getValidatorFormat();
1200:                    final boolean isRangeFormat = (format != null)
1201:                            && isRangeFormat(format);
1202:
1203:                    if (isRequired())
1204:                        validatorTypesList.add("required");
1205:
1206:                    if (isValidatorByte())
1207:                        validatorTypesList.add("byte");
1208:                    else if (isValidatorShort())
1209:                        validatorTypesList.add("short");
1210:                    else if (isValidatorInteger())
1211:                        validatorTypesList.add("integer");
1212:                    else if (isValidatorLong())
1213:                        validatorTypesList.add("long");
1214:                    else if (isValidatorFloat())
1215:                        validatorTypesList.add("float");
1216:                    else if (isValidatorDouble())
1217:                        validatorTypesList.add("double");
1218:                    else if (isValidatorDate())
1219:                        validatorTypesList.add("date");
1220:                    else if (isValidatorTime())
1221:                        validatorTypesList.add("time");
1222:                    else if (isValidatorUrl())
1223:                        validatorTypesList.add("url");
1224:
1225:                    if (isRangeFormat) {
1226:                        if (isValidatorInteger() || isValidatorShort()
1227:                                || isValidatorLong())
1228:                            validatorTypesList.add("intRange");
1229:                        if (isValidatorFloat())
1230:                            validatorTypesList.add("floatRange");
1231:                        if (isValidatorDouble())
1232:                            validatorTypesList.add("doubleRange");
1233:                    }
1234:
1235:                    if (format != null) {
1236:                        if (isValidatorString() && isEmailFormat(format))
1237:                            validatorTypesList.add("email");
1238:                        else if (isValidatorString()
1239:                                && isCreditCardFormat(format))
1240:                            validatorTypesList.add("creditCard");
1241:                        else {
1242:                            Collection formats = findTaggedValues(Bpm4StrutsProfile.TAGGEDVALUE_INPUT_FORMAT);
1243:                            for (final Iterator formatIterator = formats
1244:                                    .iterator(); formatIterator.hasNext();) {
1245:                                String additionalFormat = String
1246:                                        .valueOf(formatIterator.next());
1247:                                if (isMinLengthFormat(additionalFormat))
1248:                                    validatorTypesList.add("minlength");
1249:                                else if (isMaxLengthFormat(additionalFormat))
1250:                                    validatorTypesList.add("maxlength");
1251:                                else if (isPatternFormat(additionalFormat))
1252:                                    validatorTypesList.add("mask");
1253:                            }
1254:                        }
1255:                    }
1256:
1257:                    if (getValidWhen() != null) {
1258:                        validatorTypesList.add("validwhen");
1259:                    }
1260:                }
1261:
1262:                // custom (paramterized) validators are allowed here
1263:                Collection taggedValues = findTaggedValues(Bpm4StrutsProfile.TAGGEDVALUE_INPUT_VALIDATORS);
1264:                for (final Iterator iterator = taggedValues.iterator(); iterator
1265:                        .hasNext();) {
1266:                    String validator = String.valueOf(iterator.next());
1267:                    validatorTypesList.add(Bpm4StrutsUtils
1268:                            .parseValidatorName(validator));
1269:                }
1270:
1271:                return validatorTypesList;
1272:            }
1273:
1274:            /**
1275:             * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsParameter#getValidatorMsgKey()
1276:             */
1277:            protected String handleGetValidatorMsgKey() {
1278:                return getMessageKey();
1279:            }
1280:
1281:            /**
1282:             * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsParameter#getValidatorArgs(java.lang.String)
1283:             */
1284:            protected java.util.Collection handleGetValidatorArgs(
1285:                    java.lang.String validatorType) {
1286:                final Collection args = new ArrayList();
1287:                if ("intRange".equals(validatorType)
1288:                        || "floatRange".equals(validatorType)
1289:                        || "doubleRange".equals(validatorType)) {
1290:                    args.add("${var:min}");
1291:                    args.add("${var:max}");
1292:                } else if ("minlength".equals(validatorType)) {
1293:                    args.add("${var:minlength}");
1294:                } else if ("maxlength".equals(validatorType)) {
1295:                    args.add("${var:maxlength}");
1296:                } else if ("date".equals(validatorType)) {
1297:                    final String validatorFormat = getValidatorFormat();
1298:                    if (validatorFormat != null
1299:                            && isStrictDateFormat(validatorFormat)) {
1300:                        args.add("${var:datePatternStrict}");
1301:                    } else {
1302:                        args.add("${var:datePattern}");
1303:                    }
1304:                } else if ("time".equals(validatorType)) {
1305:                    args.add("${var:timePattern}");
1306:                }
1307:
1308:                // custom (paramterized) validators are allowed here
1309:                Collection taggedValues = findTaggedValues(Bpm4StrutsProfile.TAGGEDVALUE_INPUT_VALIDATORS);
1310:                for (final Iterator iterator = taggedValues.iterator(); iterator
1311:                        .hasNext();) {
1312:                    String validator = String.valueOf(iterator.next());
1313:                    if (validatorType.equals(Bpm4StrutsUtils
1314:                            .parseValidatorName(validator))) {
1315:                        args.addAll(Bpm4StrutsUtils
1316:                                .parseValidatorArgs(validator));
1317:                    }
1318:                }
1319:
1320:                return args;
1321:            }
1322:
1323:            /**
1324:             * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsParameter#getValidatorVars()
1325:             */
1326:            protected java.util.Collection handleGetValidatorVars() {
1327:                final Map vars = new LinkedHashMap();
1328:
1329:                final ClassifierFacade type = getType();
1330:                if (type != null) {
1331:                    final String format = getValidatorFormat();
1332:                    if (format != null) {
1333:                        final boolean isRangeFormat = isRangeFormat(format);
1334:
1335:                        if (isRangeFormat) {
1336:                            vars.put("min", Arrays.asList(new Object[] { "min",
1337:                                    getRangeStart(format) }));
1338:                            vars.put("max", Arrays.asList(new Object[] { "max",
1339:                                    getRangeEnd(format) }));
1340:                        } else {
1341:                            final Collection formats = findTaggedValues(Bpm4StrutsProfile.TAGGEDVALUE_INPUT_FORMAT);
1342:                            for (final Iterator formatIterator = formats
1343:                                    .iterator(); formatIterator.hasNext();) {
1344:                                final String additionalFormat = String
1345:                                        .valueOf(formatIterator.next());
1346:                                if (isMinLengthFormat(additionalFormat))
1347:                                    vars
1348:                                            .put(
1349:                                                    "minlength",
1350:                                                    Arrays
1351:                                                            .asList(new Object[] {
1352:                                                                    "minlength",
1353:                                                                    this 
1354:                                                                            .getMinLengthValue(additionalFormat) }));
1355:                                else if (isMaxLengthFormat(additionalFormat))
1356:                                    vars
1357:                                            .put(
1358:                                                    "maxlength",
1359:                                                    Arrays
1360:                                                            .asList(new Object[] {
1361:                                                                    "maxlength",
1362:                                                                    this 
1363:                                                                            .getMaxLengthValue(additionalFormat) }));
1364:                                else if (isPatternFormat(additionalFormat))
1365:                                    vars
1366:                                            .put(
1367:                                                    "mask",
1368:                                                    Arrays
1369:                                                            .asList(new Object[] {
1370:                                                                    "mask",
1371:                                                                    this 
1372:                                                                            .getPatternValue(additionalFormat) }));
1373:                            }
1374:                        }
1375:                    }
1376:                    if (isValidatorDate()) {
1377:                        if (format != null && isStrictDateFormat(format)) {
1378:                            vars.put("datePatternStrict", Arrays
1379:                                    .asList(new Object[] { "datePatternStrict",
1380:                                            this .getDateFormat() }));
1381:                        } else {
1382:                            vars.put("datePattern", Arrays.asList(new Object[] {
1383:                                    "datePattern", this .getDateFormat() }));
1384:                        }
1385:                    }
1386:                    if (this .isValidatorTime()) {
1387:                        vars.put("timePattern", Arrays.asList(new Object[] {
1388:                                "timePattern", this .getTimeFormat() }));
1389:                    }
1390:
1391:                    final String validWhen = getValidWhen();
1392:                    if (validWhen != null) {
1393:                        vars.put("test", Arrays.asList(new Object[] { "test",
1394:                                validWhen }));
1395:                    }
1396:                }
1397:
1398:                // custom (paramterized) validators are allowed here
1399:                // in this case we will reuse the validator arg values
1400:                Collection taggedValues = findTaggedValues(Bpm4StrutsProfile.TAGGEDVALUE_INPUT_VALIDATORS);
1401:                for (final Iterator iterator = taggedValues.iterator(); iterator
1402:                        .hasNext();) {
1403:                    String validator = String.valueOf(iterator.next());
1404:
1405:                    // guaranteed to be of the same length
1406:                    List validatorVars = Bpm4StrutsUtils
1407:                            .parseValidatorVars(validator);
1408:                    List validatorArgs = Bpm4StrutsUtils
1409:                            .parseValidatorArgs(validator);
1410:
1411:                    for (int i = 0; i < validatorVars.size(); i++) {
1412:                        String validatorVar = (String) validatorVars.get(i);
1413:                        String validatorArg = (String) validatorArgs.get(i);
1414:
1415:                        vars.put(validatorVar, Arrays.asList(new Object[] {
1416:                                validatorVar, validatorArg }));
1417:                    }
1418:                }
1419:
1420:                return vars.values();
1421:            }
1422:
1423:            /**
1424:             * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsParameter#getValidWhen()
1425:             */
1426:            protected java.lang.String handleGetValidWhen() {
1427:                final Object value = findTaggedValue(Bpm4StrutsProfile.TAGGEDVALUE_INPUT_VALIDWHEN);
1428:                return value == null ? null : '(' + value.toString() + ')';
1429:            }
1430:
1431:            /**
1432:             * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsParameter#getMultiboxPropertyName()
1433:             */
1434:            protected String handleGetMultiboxPropertyName() {
1435:                Object value = findTaggedValue(Bpm4StrutsProfile.TAGGEDVALUE_INPUT_MULTIBOX);
1436:                return (value == null) ? null : StringUtils.trimToNull(value
1437:                        .toString());
1438:            }
1439:
1440:            /**
1441:             * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsParameter#getOptionKeys()
1442:             */
1443:            protected List handleGetOptionKeys() {
1444:                final String key = getMessageKey() + '.';
1445:                final List optionKeys = new ArrayList();
1446:                final int optionCount = getOptionCount();
1447:                for (int i = 0; i < optionCount; i++)
1448:                    optionKeys.add(key + i);
1449:                return optionKeys;
1450:            }
1451:
1452:            /**
1453:             * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsParameter#getOptionValues()
1454:             */
1455:            protected List handleGetOptionValues() {
1456:                final List optionValues = new ArrayList();
1457:                final Object taggedValueObject = this 
1458:                        .findTaggedValue(Bpm4StrutsProfile.TAGGEDVALUE_INPUT_RADIO);
1459:
1460:                if (taggedValueObject == null) {
1461:                    // we resort to the default values
1462:                    optionValues.add("0");
1463:                    optionValues.add("1");
1464:                    optionValues.add("2");
1465:                } else {
1466:                    final String taggedValue = String
1467:                            .valueOf(taggedValueObject).trim();
1468:
1469:                    int optionCount;
1470:                    try {
1471:                        optionCount = Integer.parseInt(taggedValue);
1472:                        for (int i = 0; i < optionCount; i++) {
1473:                            optionValues.add(String.valueOf(i));
1474:                        }
1475:                    } catch (Exception exception) {
1476:                        // this means the value wasn't a valid integer, we'll interpret it is a comma-separated
1477:                        // list of option-values
1478:                        final String[] options = taggedValue.split("[,]");
1479:                        for (int i = 0; i < options.length; i++) {
1480:                            optionValues.add(options[i].trim());
1481:                        }
1482:                    }
1483:                }
1484:                return optionValues;
1485:            }
1486:
1487:            /**
1488:             * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsParameter#getOptionCount()
1489:             */
1490:            protected int handleGetOptionCount() {
1491:                return this .getOptionValues().size();
1492:            }
1493:
1494:            /**
1495:             * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsParameter#isShouldReset()
1496:             */
1497:            protected boolean handleIsShouldReset() {
1498:                boolean shouldReset = false;
1499:                Object value = this 
1500:                        .findTaggedValue(Bpm4StrutsProfile.TAGGEDVALUE_INPUT_RESET);
1501:                if (value != null) {
1502:                    shouldReset = Boolean.valueOf(
1503:                            StringUtils.trimToEmpty((String) value))
1504:                            .booleanValue();
1505:                }
1506:                return shouldReset;
1507:            }
1508:
1509:            /**
1510:             * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsParameter#getResetName()
1511:             */
1512:            protected String handleGetResetName() {
1513:                return "reset"
1514:                        + StringUtils.capitalize(StringUtils.trimToEmpty(this 
1515:                                .getName()));
1516:            }
1517:
1518:            protected boolean handleIsPassword() {
1519:                return Bpm4StrutsProfile.TAGGEDVALUE_INPUT_TYPE_PASSWORD
1520:                        .equals(this .getWidgetType());
1521:            }
1522:
1523:            protected boolean handleIsCombobox() {
1524:                return "select".equals(this .getWidgetType());
1525:            }
1526:
1527:            protected boolean handleIsCheckbox() {
1528:                return "checkbox".equals(this .getWidgetType());
1529:            }
1530:
1531:            protected boolean handleIsTextField() {
1532:                return "text".equals(this .getWidgetType());
1533:            }
1534:
1535:            protected boolean handleIsTextArea() {
1536:                return "textarea".equals(this .getWidgetType());
1537:            }
1538:
1539:            protected boolean handleIsMultibox() {
1540:                return "multibox".equals(this .getWidgetType());
1541:            }
1542:
1543:            protected boolean handleIsRadioButton() {
1544:                return "radio".equals(this .getWidgetType());
1545:            }
1546:
1547:            protected boolean handleIsHiddenField() {
1548:                return "hidden".equals(this .getWidgetType());
1549:            }
1550:
1551:            protected boolean handleIsHyperlink() {
1552:                return "link".equals(this .getWidgetType());
1553:            }
1554:
1555:            /**
1556:             * @return <code>true</code> if the type of this field is a boolean, <code>false</code> otherwise
1557:             */
1558:            private boolean isValidatorBoolean() {
1559:                return UMLMetafacadeUtils.isType(this .getType(),
1560:                        UMLProfile.BOOLEAN_TYPE_NAME);
1561:            }
1562:
1563:            /**
1564:             * @return <code>true</code> if the type of this field is a character, <code>false</code> otherwise
1565:             */
1566:            private boolean isValidatorChar() {
1567:                return UMLMetafacadeUtils.isType(this .getType(),
1568:                        Bpm4StrutsProfile.CHARACTER_TYPE_NAME);
1569:            }
1570:
1571:            /**
1572:             * @return <code>true</code> if the type of this field is a byte, <code>false</code> otherwise
1573:             */
1574:            private boolean isValidatorByte() {
1575:                return UMLMetafacadeUtils.isType(this .getType(),
1576:                        Bpm4StrutsProfile.BYTE_TYPE_NAME);
1577:            }
1578:
1579:            /**
1580:             * @return <code>true</code> if the type of this field is a short, <code>false</code> otherwise
1581:             */
1582:            private boolean isValidatorShort() {
1583:                return UMLMetafacadeUtils.isType(this .getType(),
1584:                        Bpm4StrutsProfile.SHORT_TYPE_NAME);
1585:            }
1586:
1587:            /**
1588:             * @return <code>true</code> if the type of this field is an integer, <code>false</code> otherwise
1589:             */
1590:            private boolean isValidatorInteger() {
1591:                return UMLMetafacadeUtils.isType(this .getType(),
1592:                        Bpm4StrutsProfile.INTEGER_TYPE_NAME);
1593:            }
1594:
1595:            /**
1596:             * @return <code>true</code> if the type of this field is a long integer, <code>false</code> otherwise
1597:             */
1598:            private boolean isValidatorLong() {
1599:                return UMLMetafacadeUtils.isType(this .getType(),
1600:                        Bpm4StrutsProfile.LONG_TYPE_NAME);
1601:            }
1602:
1603:            /**
1604:             * @return <code>true</code> if the type of this field is a floating point, <code>false</code> otherwise
1605:             */
1606:            private boolean isValidatorFloat() {
1607:                return UMLMetafacadeUtils.isType(this .getType(),
1608:                        Bpm4StrutsProfile.FLOAT_TYPE_NAME);
1609:            }
1610:
1611:            /**
1612:             * @return <code>true</code> if the type of this field is a double precision floating point, <code>false</code> otherwise
1613:             */
1614:            private boolean isValidatorDouble() {
1615:                return UMLMetafacadeUtils.isType(this .getType(),
1616:                        Bpm4StrutsProfile.DOUBLE_TYPE_NAME);
1617:            }
1618:
1619:            /**
1620:             * @return <code>true</code> if the type of this field is a date, <code>false</code> otherwise
1621:             */
1622:            private boolean isValidatorDate() {
1623:                return this .getType() != null && this .getType().isDateType();
1624:            }
1625:
1626:            /**
1627:             * @return <code>true</code> if the type of this field is a time, <code>false</code> otherwise
1628:             */
1629:            private boolean isValidatorTime() {
1630:                return UMLMetafacadeUtils.isType(this .getType(),
1631:                        Bpm4StrutsProfile.TIME_TYPE_NAME);
1632:            }
1633:
1634:            /**
1635:             * @return <code>true</code> if the type of this field is a URL, <code>false</code> otherwise
1636:             */
1637:            private boolean isValidatorUrl() {
1638:                return UMLMetafacadeUtils.isType(this .getType(),
1639:                        Bpm4StrutsProfile.URL_TYPE_NAME);
1640:            }
1641:
1642:            /**
1643:             * @return <code>true</code> if the type of this field is a String, <code>false</code> otherwise
1644:             */
1645:            private boolean isValidatorString() {
1646:                return this .getType() != null && this .getType().isStringType();
1647:            }
1648:
1649:            /**
1650:             * @return <code>true</code> if this field is to be formatted as an email address, <code>false</code> otherwise
1651:             */
1652:            private boolean isEmailFormat(String format) {
1653:                return "email".equalsIgnoreCase(getToken(format, 0, 2));
1654:            }
1655:
1656:            /**
1657:             * @return <code>true</code> if this field is to be formatted as a credit card, <code>false</code> otherwise
1658:             */
1659:            private boolean isCreditCardFormat(String format) {
1660:                return "creditcard".equalsIgnoreCase(getToken(format, 0, 2));
1661:            }
1662:
1663:            /**
1664:             * @return <code>true</code> if this field's value needs to be in a specific range, <code>false</code> otherwise
1665:             */
1666:            private boolean isRangeFormat(String format) {
1667:                return "range".equalsIgnoreCase(getToken(format, 0, 2))
1668:                        && (isValidatorInteger() || isValidatorLong()
1669:                                || isValidatorShort() || isValidatorFloat() || isValidatorDouble());
1670:
1671:            }
1672:
1673:            /**
1674:             * @return <code>true</code> if this field's value needs to respect a certain pattern, <code>false</code> otherwise
1675:             */
1676:            private boolean isPatternFormat(String format) {
1677:                return "pattern".equalsIgnoreCase(getToken(format, 0, 2));
1678:            }
1679:
1680:            /**
1681:             * @return <code>true</code> if this field's value needs to conform to a strict date format, <code>false</code> otherwise
1682:             */
1683:            private boolean isStrictDateFormat(String format) {
1684:                return "strict".equalsIgnoreCase(getToken(format, 0, 2));
1685:            }
1686:
1687:            /**
1688:             * @return <code>true</code> if this field's value needs to consist of at least a certain number of characters, <code>false</code> otherwise
1689:             */
1690:            private boolean isMinLengthFormat(String format) {
1691:                return "minlength".equalsIgnoreCase(getToken(format, 0, 2));
1692:            }
1693:
1694:            /**
1695:             * @return <code>true</code> if this field's value needs to consist of at maximum a certain number of characters, <code>false</code> otherwise
1696:             */
1697:            private boolean isMaxLengthFormat(String format) {
1698:                return "maxlength".equalsIgnoreCase(getToken(format, 0, 2));
1699:            }
1700:
1701:            /**
1702:             * @return the lower limit for this field's value's range
1703:             */
1704:            private String getRangeStart(String format) {
1705:                return getToken(format, 1, 3);
1706:            }
1707:
1708:            /**
1709:             * @return the upper limit for this field's value's range
1710:             */
1711:            private String getRangeEnd(String format) {
1712:                return getToken(format, 2, 3);
1713:            }
1714:
1715:            /**
1716:             * @return this field's date format
1717:             */
1718:            private String getDateFormat(String format) {
1719:                return (isStrictDateFormat(format)) ? getToken(format, 1, 2)
1720:                        : getToken(format, 0, 1);
1721:            }
1722:
1723:            /**
1724:             * @return the minimum number of characters this field's value must consist of
1725:             */
1726:            private String getMinLengthValue(String format) {
1727:                return getToken(format, 1, 2);
1728:            }
1729:
1730:            /**
1731:             * @return the maximum number of characters this field's value must consist of
1732:             */
1733:            private String getMaxLengthValue(String format) {
1734:                return getToken(format, 1, 2);
1735:            }
1736:
1737:            /**
1738:             * @return the pattern this field's value must respect
1739:             */
1740:            private String getPatternValue(String format) {
1741:                return '^' + getToken(format, 1, 2) + '$';
1742:            }
1743:
1744:            /**
1745:             * @return the i-th space delimited token read from the argument String, where i does not exceed the specified limit
1746:             */
1747:            private String getToken(String string, int index, int limit) {
1748:                if (string == null)
1749:                    return null;
1750:
1751:                final String[] tokens = string.split("[\\s]+", limit);
1752:                return (index >= tokens.length) ? null : tokens[index];
1753:            }
1754:
1755:            public Object getValidationOwner() {
1756:                return (this .isTable() && this .getJsp() != null) ? this 
1757:                        .getJsp() : super .getValidationOwner();
1758:            }
1759:
1760:            protected boolean handleIsSortableBy() {
1761:                boolean sortableBy = true;
1762:
1763:                final Object value = this 
1764:                        .findTaggedValue(Bpm4StrutsProfile.TAGGEDVALUE_INPUT_TYPE);
1765:                if (value != null) {
1766:                    final String fieldType = value.toString();
1767:                    sortableBy = !(Bpm4StrutsProfile.TAGGEDVALUE_INPUT_TYPE_PASSWORD
1768:                            .equalsIgnoreCase(fieldType)
1769:                            || Bpm4StrutsProfile.TAGGEDVALUE_INPUT_TYPE_HIDDEN
1770:                                    .equalsIgnoreCase(fieldType)
1771:                            || Bpm4StrutsProfile.TAGGEDVALUE_INPUT_TYPE_RADIO
1772:                                    .equalsIgnoreCase(fieldType)
1773:                            || Bpm4StrutsProfile.TAGGEDVALUE_INPUT_TYPE_CHECKBOX
1774:                                    .equalsIgnoreCase(fieldType) || Bpm4StrutsProfile.TAGGEDVALUE_INPUT_TYPE_MULTIBOX
1775:                            .equalsIgnoreCase(fieldType));
1776:                }
1777:
1778:                return sortableBy;
1779:            }
1780:
1781:            private boolean normalizeMessages() {
1782:                final String normalizeMessages = (String) getConfiguredProperty(Bpm4StrutsGlobals.PROPERTY_NORMALIZE_MESSAGES);
1783:                return Boolean.valueOf(normalizeMessages).booleanValue();
1784:            }
1785:
1786:            /**
1787:             * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsParameterLogic#handleIsTime()
1788:             */
1789:            protected boolean handleIsTime() {
1790:                return this .isValidatorTime();
1791:            }
1792:
1793:            protected Integer handleGetFieldColumnCount() {
1794:                Integer columnCount = null;
1795:
1796:                Object columnCountObject = this 
1797:                        .findTaggedValue(Bpm4StrutsProfile.TAGGEDVALUE_INPUT_COLUMN_COUNT);
1798:                if (columnCountObject == null) {
1799:                    columnCountObject = this 
1800:                            .getConfiguredProperty(Bpm4StrutsGlobals.PROPERTY_DEFAULT_INPUT_COLUMN_COUNT);
1801:                }
1802:
1803:                if (columnCountObject != null) {
1804:                    try {
1805:                        columnCount = Integer.valueOf(columnCountObject
1806:                                .toString());
1807:                    } catch (NumberFormatException e) {
1808:                        // do nothing, we want columnCount to be null in case of an invalid value
1809:                    }
1810:                }
1811:
1812:                return columnCount;
1813:            }
1814:
1815:            protected Integer handleGetFieldRowCount() {
1816:                Integer rowCount = null;
1817:
1818:                Object rowCountObject = this 
1819:                        .findTaggedValue(Bpm4StrutsProfile.TAGGEDVALUE_INPUT_ROW_COUNT);
1820:                if (rowCountObject == null) {
1821:                    rowCountObject = this 
1822:                            .getConfiguredProperty(Bpm4StrutsGlobals.PROPERTY_DEFAULT_INPUT_ROW_COUNT);
1823:                }
1824:
1825:                if (rowCountObject != null) {
1826:                    try {
1827:                        rowCount = Integer.valueOf(rowCountObject.toString());
1828:                    } catch (NumberFormatException e) {
1829:                        // do nothing, we want rowCount to be null in case of an invalid value
1830:                    }
1831:                }
1832:
1833:                return rowCount;
1834:            }
1835:
1836:            protected boolean handleIsSafeNamePresent() {
1837:                return Bpm4StrutsUtils.isSafeName(this.getName());
1838:            }
1839:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.