View Javadoc

1   package org.andromda.cartridges.bpm4struts.metafacades;
2   
3   import org.andromda.cartridges.bpm4struts.Bpm4StrutsGlobals;
4   import org.andromda.cartridges.bpm4struts.Bpm4StrutsProfile;
5   import org.andromda.cartridges.bpm4struts.Bpm4StrutsUtils;
6   import org.andromda.metafacades.uml.ClassifierFacade;
7   
8   
9   /**
10   * MetafacadeLogic implementation for org.andromda.cartridges.bpm4struts.metafacades.StrutsAttribute.
11   *
12   * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsAttribute
13   */
14  public class StrutsAttributeLogicImpl
15      extends StrutsAttributeLogic
16  {
17  
18      public StrutsAttributeLogicImpl(Object metaObject,
19                                      String context)
20      {
21          super(metaObject, context);
22      }
23  
24      /**
25       * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsAttribute#getDateFormat()
26       */
27      protected java.lang.String handleGetDateFormat()
28      {
29          String dateFormat = null;
30  
31          if (this.getType() != null && this.getType().isDateType())
32          {
33              final Object taggedValueObject = this.findTaggedValue(Bpm4StrutsProfile.TAGGEDVALUE_INPUT_FORMAT);
34              if (taggedValueObject == null)
35              {
36                  dateFormat = (String)this.getConfiguredProperty(Bpm4StrutsGlobals.PROPERTY_DEFAULT_DATEFORMAT);
37              }
38              else
39              {
40                  dateFormat = taggedValueObject.toString();
41              }
42          }
43  
44          return dateFormat;
45      }
46  
47      protected String handleGetDummyValue(int seed)
48      {
49          String dummyValue;
50  
51          final ClassifierFacade type = this.getType();
52  
53          if (type == null)
54          {
55              dummyValue = "";
56          }
57          else if (type.isDateType())
58          {
59              dummyValue = "new java.util.Date()";
60          }
61          else if (type.isBooleanType())
62          {
63              dummyValue = String.valueOf(seed % 2 == 0);
64          }
65          else if (type.isPrimitive())
66          {
67              dummyValue = String.valueOf(seed);
68          }
69          else
70          {
71              dummyValue = "\"" + this.getName() + '-' + seed + "\"";
72          }
73  
74          return dummyValue;
75      }
76  
77      protected boolean handleIsSafeNamePresent()
78      {
79          return Bpm4StrutsUtils.isSafeName(this.getName());
80      }
81  }