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


001:        package org.andromda.metafacades.uml14;
002:
003:        import java.util.Collection;
004:        import java.util.Iterator;
005:
006:        import org.andromda.metafacades.uml.ClassifierFacade;
007:        import org.andromda.metafacades.uml.EnumerationFacade;
008:        import org.andromda.metafacades.uml.NameMasker;
009:        import org.andromda.metafacades.uml.TypeMappings;
010:        import org.andromda.metafacades.uml.UMLMetafacadeProperties;
011:        import org.andromda.metafacades.uml.UMLMetafacadeUtils;
012:        import org.andromda.metafacades.uml.UMLProfile;
013:        import org.andromda.utils.StringUtilsHelper;
014:        import org.apache.commons.lang.BooleanUtils;
015:        import org.apache.commons.lang.ObjectUtils;
016:        import org.apache.commons.lang.StringUtils;
017:        import org.omg.uml.foundation.datatypes.ChangeableKindEnum;
018:        import org.omg.uml.foundation.datatypes.Multiplicity;
019:        import org.omg.uml.foundation.datatypes.MultiplicityRange;
020:        import org.omg.uml.foundation.datatypes.OrderingKind;
021:        import org.omg.uml.foundation.datatypes.OrderingKindEnum;
022:        import org.omg.uml.foundation.datatypes.ScopeKindEnum;
023:
024:        /**
025:         * Metaclass facade implementation.
026:         */
027:        public class AttributeFacadeLogicImpl extends AttributeFacadeLogic {
028:            public AttributeFacadeLogicImpl(
029:                    org.omg.uml.foundation.core.Attribute metaObject,
030:                    String context) {
031:                super (metaObject, context);
032:            }
033:
034:            /**
035:             * @see org.andromda.core.metafacade.MetafacadeBase#getValidationOwner()
036:             */
037:            public Object getValidationOwner() {
038:                return this .getOwner();
039:            }
040:
041:            /**
042:             * @see org.andromda.metafacades.uml.AttributeFacade#getGetterName()
043:             */
044:            public java.lang.String handleGetGetterName() {
045:                return UMLMetafacadeUtils.getGetterPrefix(this .getType())
046:                        + StringUtilsHelper.capitalize(this .getName());
047:            }
048:
049:            /**
050:             * @see org.andromda.metafacades.uml.AttributeFacade#getSetterName()
051:             */
052:            public java.lang.String handleGetSetterName() {
053:                return "set" + StringUtils.capitalize(this .getName());
054:            }
055:
056:            /**
057:             * @see org.andromda.metafacades.uml.AttributeFacade#getDefaultValue()
058:             */
059:            public String handleGetDefaultValue() {
060:                String defaultValue = null;
061:                if (this .metaObject.getInitialValue() != null) {
062:                    defaultValue = this .metaObject.getInitialValue().getBody();
063:                }
064:                return defaultValue;
065:            }
066:
067:            /**
068:             * @see org.andromda.metafacades.uml.AttributeFacade#isChangeable()
069:             */
070:            public boolean handleIsChangeable() {
071:                return ChangeableKindEnum.CK_CHANGEABLE.equals(metaObject
072:                        .getChangeability());
073:            }
074:
075:            /**
076:             * @see org.andromda.metafacades.uml.AttributeFacade#isAddOnly()
077:             */
078:            public boolean handleIsAddOnly() {
079:                return ChangeableKindEnum.CK_ADD_ONLY.equals(metaObject
080:                        .getChangeability());
081:            }
082:
083:            /**
084:             * @see org.andromda.metafacades.uml.AttributeFacade#getType()
085:             */
086:            protected Object handleGetType() {
087:                return metaObject.getType();
088:            }
089:
090:            /**
091:             * @see org.andromda.metafacades.uml.AttributeFacade#getOwner()
092:             */
093:            public Object handleGetOwner() {
094:                return this .metaObject.getOwner();
095:            }
096:
097:            /**
098:             * @see org.andromda.metafacades.uml.AttributeFacade#isReadOnly()
099:             */
100:            public boolean handleIsReadOnly() {
101:                return ChangeableKindEnum.CK_FROZEN.equals(metaObject
102:                        .getChangeability());
103:            }
104:
105:            /**
106:             * @see org.andromda.metafacades.uml.AttributeFacade#isStatic()
107:             */
108:            public boolean handleIsStatic() {
109:                return ScopeKindEnum.SK_CLASSIFIER.equals(this .metaObject
110:                        .getOwnerScope());
111:            }
112:
113:            /**
114:             * @see org.andromda.metafacades.uml.AttributeFacade#findTaggedValue(java.lang.String, boolean)
115:             */
116:            public Object handleFindTaggedValue(String name, boolean follow) {
117:                name = StringUtils.trimToEmpty(name);
118:                Object value = findTaggedValue(name);
119:                if (follow) {
120:                    ClassifierFacade type = this .getType();
121:                    while (value == null && type != null) {
122:                        value = type.findTaggedValue(name);
123:                        type = (ClassifierFacade) type.getGeneralization();
124:                    }
125:                }
126:                return value;
127:            }
128:
129:            /**
130:             * @see org.andromda.metafacades.uml.AttributeFacade#isRequired()
131:             */
132:            public boolean handleIsRequired() {
133:                int lower = this .getMultiplicityRangeLower();
134:                return lower >= 1;
135:            }
136:
137:            /**
138:             * @see org.andromda.metafacades.uml.AttributeFacade#isMany()
139:             */
140:            public boolean handleIsMany() {
141:                boolean isMany = false;
142:                final Multiplicity multiplicity = this .metaObject
143:                        .getMultiplicity();
144:
145:                // assume no multiplicity is 1
146:                if (multiplicity != null) {
147:                    final Collection ranges = multiplicity.getRange();
148:                    if (ranges != null && !ranges.isEmpty()) {
149:                        final Iterator rangeIt = ranges.iterator();
150:                        while (rangeIt.hasNext()) {
151:                            final MultiplicityRange multiplicityRange = (MultiplicityRange) rangeIt
152:                                    .next();
153:                            final int upper = multiplicityRange.getUpper();
154:                            isMany = upper > 1 || upper < 0;
155:                        }
156:                    }
157:                }
158:                return isMany;
159:            }
160:
161:            /**
162:             * Returns the lower range of the multiplicty for the passed in associationEnd
163:             *
164:             * @return int the lower range of the multiplicty or 1 if it isn't defined.
165:             */
166:            private int getMultiplicityRangeLower() {
167:                Integer lower = null;
168:                final Multiplicity multiplicity = metaObject.getMultiplicity();
169:                if (multiplicity != null) {
170:                    final Collection ranges = multiplicity.getRange();
171:                    if (ranges != null && !ranges.isEmpty()) {
172:                        final Iterator rangeIt = ranges.iterator();
173:                        while (rangeIt.hasNext()) {
174:                            final MultiplicityRange multiplicityRange = (MultiplicityRange) rangeIt
175:                                    .next();
176:                            lower = new Integer(multiplicityRange.getLower());
177:                        }
178:                    }
179:                }
180:                if (lower == null) {
181:                    final String defaultMultiplicity = this 
182:                            .getDefaultMultiplicity();
183:                    if (defaultMultiplicity.startsWith("0")) {
184:                        lower = new Integer(0);
185:                    } else {
186:                        lower = new Integer(1);
187:                    }
188:                }
189:                return lower.intValue();
190:            }
191:
192:            /**
193:             * Gets the default multiplicity for this attribute (the
194:             * multiplicity if none is defined).
195:             *
196:             * @return the defautl multiplicity as a String.
197:             */
198:            private String getDefaultMultiplicity() {
199:                return ObjectUtils
200:                        .toString(this 
201:                                .getConfiguredProperty(UMLMetafacadeProperties.DEFAULT_MULTIPLICITY));
202:            }
203:
204:            /**
205:             * @see org.andromda.metafacades.uml.AttributeFacade#getEnumeration()
206:             */
207:            protected Object handleGetEnumeration() {
208:                return this .isEnumerationLiteral() ? this .getOwner() : null;
209:            }
210:
211:            /**
212:             * @see org.andromda.metafacades.uml.AttributeFacade#isEnumerationLiteral()
213:             */
214:            protected boolean handleIsEnumerationLiteral() {
215:                final ClassifierFacade owner = this .getOwner();
216:                return (owner != null) && owner.isEnumeration();
217:            }
218:
219:            /**
220:             * @see org.andromda.metafacades.uml.AttributeFacade#getEnumerationValue()
221:             */
222:            protected String handleGetEnumerationValue() {
223:                String value = null;
224:                if (this .isEnumerationLiteral()) {
225:                    value = this .getDefaultValue();
226:                    value = (value == null) ? getName() : String.valueOf(value);
227:                }
228:                if (this .getType().isStringType()) {
229:                    value = "\"" + value + "\"";
230:                }
231:                return value;
232:            }
233:
234:            /**
235:             * @see org.andromda.metafacades.uml.AttributeFacade#handleIsEnumerationMember()
236:             */
237:            protected boolean handleIsEnumerationMember() {
238:                boolean isMemberVariable = false;
239:                final String isMemberVariableAsString = (String) this 
240:                        .findTaggedValue(UMLProfile.TAGGEDVALUE_PERSISTENCE_ENUMERATION_MEMBER_VARIABLE);
241:                if (StringUtils.isNotEmpty(isMemberVariableAsString)
242:                        && BooleanUtils.toBoolean(isMemberVariableAsString)) {
243:                    isMemberVariable = true;
244:                }
245:                return isMemberVariable;
246:            }
247:
248:            /**
249:             * @see org.andromda.metafacades.uml.AttributeFacade#handleGetEnumerationLiteralParameters()
250:             */
251:            protected String handleGetEnumerationLiteralParameters() {
252:                return (String) this 
253:                        .findTaggedValue(UMLProfile.TAGGEDVALUE_PERSISTENCE_ENUMERATION_LITERAL_PARAMETERS);
254:            }
255:
256:            /**
257:             * @see org.andromda.metafacades.uml.AttributeFacade#handleIsEnumerationLiteralParametersExist()
258:             */
259:            protected boolean handleIsEnumerationLiteralParametersExist() {
260:                boolean parametersExist = false;
261:                if (StringUtils.isNotBlank(this 
262:                        .getEnumerationLiteralParameters())) {
263:                    parametersExist = true;
264:                }
265:                return parametersExist;
266:            }
267:
268:            /**
269:             * @see org.andromda.metafacades.uml.AttributeFacade#isDefaultValuePresent()
270:             */
271:            public boolean handleIsDefaultValuePresent() {
272:                return StringUtils.isNotBlank(this .getDefaultValue());
273:            }
274:
275:            /**
276:             * Overridden to provide different handling of the name if this attribute represents a literal.
277:             *
278:             * @see org.andromda.metafacades.uml.ModelElementFacade#getName()
279:             */
280:            protected String handleGetName() {
281:                String name = null;
282:                if (this .isEnumerationMember()) {
283:                    name = super .handleGetName();
284:                } else {
285:                    final String mask = String
286:                            .valueOf(this 
287:                                    .getConfiguredProperty(this .getOwner() instanceof  EnumerationFacade ? UMLMetafacadeProperties.ENUMERATION_LITERAL_NAME_MASK
288:                                            : UMLMetafacadeProperties.CLASSIFIER_PROPERTY_NAME_MASK));
289:
290:                    name = NameMasker.mask(super .handleGetName(), mask);
291:                }
292:                return name;
293:            }
294:
295:            /**
296:             * @see org.andromda.metafacades.uml.AttributeFacade#isOrdered()
297:             */
298:            public boolean handleIsOrdered() {
299:                boolean ordered = false;
300:
301:                final OrderingKind ordering = metaObject.getOrdering();
302:
303:                // no ordering is 'unordered'
304:                if (ordering != null) {
305:                    ordered = ordering.equals(OrderingKindEnum.OK_ORDERED);
306:                }
307:
308:                return ordered;
309:            }
310:
311:            /**
312:             * @see org.andromda.metafacades.uml.AttributeFacade#getGetterSetterTypeName()
313:             */
314:            public String handleGetGetterSetterTypeName() {
315:                String name = null;
316:                if (this .isMany()) {
317:                    final TypeMappings mappings = this .getLanguageMappings();
318:                    name = isOrdered() ? mappings
319:                            .getTo(UMLProfile.LIST_TYPE_NAME) : mappings
320:                            .getTo(UMLProfile.COLLECTION_TYPE_NAME);
321:
322:                    // set this attribute's type as a template parameter if required
323:                    if (BooleanUtils
324:                            .toBoolean(ObjectUtils
325:                                    .toString(this 
326:                                            .getConfiguredProperty(UMLMetafacadeProperties.ENABLE_TEMPLATING)))) {
327:                        name = name + "<"
328:                                + this .getType().getFullyQualifiedName() + ">";
329:                    }
330:                }
331:                if (name == null && this .getType() != null) {
332:                    name = this .getType().getFullyQualifiedName();
333:                }
334:                return name;
335:            }
336:
337:            /**
338:             * Get the UML upper multiplicity
339:             * Not implemented for UML1.4
340:             */
341:            protected int handleGetUpper() {
342:                throw new java.lang.UnsupportedOperationException(
343:                        "'upper' is not a UML1.4 feature");
344:            }
345:
346:            /**
347:             * Get the UML lower multiplicity
348:             * Not implemented for UML1.4
349:             */
350:            protected int handleGetLower() {
351:                throw new java.lang.UnsupportedOperationException(
352:                        "'lower' is not a UML1.4 feature");
353:            }
354:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.