1 package org.andromda.cartridges.ejb.metafacades;
2
3 import java.text.MessageFormat;
4 import java.util.StringTokenizer;
5 import org.andromda.cartridges.ejb.EJBProfile;
6 import org.andromda.metafacades.uml.GeneralizableElementFacade;
7 import org.apache.commons.lang.StringUtils;
8
9
10
11
12
13
14 public class ValueObjectFacadeLogicImpl
15 extends ValueObjectFacadeLogic
16 {
17 private static final long serialVersionUID = 34L;
18
19
20
21
22
23 public ValueObjectFacadeLogicImpl(
24 Object metaObject,
25 String context)
26 {
27 super(metaObject, context);
28 }
29
30
31
32
33
34
35
36 public String getPackageName()
37 {
38 final String packageName =
39 MessageFormat.format(
40 this.getConfiguredProperty("valueObjectPackage").toString(),
41 StringUtils.trimToEmpty(super.getPackageName()));
42 StringBuilder buffer = new StringBuilder();
43 for (final StringTokenizer tokenizer = new StringTokenizer(packageName, "."); tokenizer.hasMoreTokens();)
44 {
45 String token = tokenizer.nextToken();
46 if (token.indexOf('/') < 0)
47 {
48 buffer.append(token).append('.');
49 }
50 }
51 final String name = buffer.toString();
52 return name.endsWith(".") ? name.substring(0, name.length() - 1) : name;
53 }
54
55
56
57
58 public String getName()
59 {
60 return MessageFormat.format(
61 this.getConfiguredProperty("valueObjectName").toString(),
62 StringUtils.trimToEmpty(super.getName()));
63 }
64
65
66
67
68 public String getFullyQualifiedName()
69 {
70 final String name = this.getPackageName();
71 return name == null || "".equalsIgnoreCase(name) ? getName() : name + '.' + getName();
72 }
73
74
75
76
77
78
79 public GeneralizableElementFacade getGeneralization()
80 {
81 GeneralizableElementFacade generalization = super.getGeneralization();
82 return generalization == null || generalization.hasStereotype(EJBProfile.STEREOTYPE_ENTITY) ? null
83 : generalization;
84 }
85 }