Source Code Cross Referenced for MOFUtils.java in  » UML » MetaBoss » com » metaboss » sdlctools » models » impl » 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 » MetaBoss » com.metaboss.sdlctools.models.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
002:        // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
003:        // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
004:        // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
005:        // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
006:        // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
007:        // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
008:        // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
009:        // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
010:        // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
011:        // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
012:        // POSSIBILITY OF SUCH DAMAGE.
013:        //
014:        // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
015:        package com.metaboss.sdlctools.models.impl;
016:
017:        import java.util.ArrayList;
018:        import java.util.Collections;
019:        import java.util.HashMap;
020:        import java.util.Iterator;
021:        import java.util.List;
022:        import java.util.Map;
023:
024:        import javax.jmi.model.AggregationKindEnum;
025:        import javax.jmi.model.AssociationEnd;
026:        import javax.jmi.model.ModelElement;
027:        import javax.jmi.model.MofClass;
028:        import javax.jmi.model.Reference;
029:        import javax.jmi.reflect.RefObject;
030:
031:        import org.apache.commons.logging.Log;
032:        import org.apache.commons.logging.LogFactory;
033:
034:        /** The utilities related to MOF */
035:        public class MOFUtils {
036:            // Commons Logging instance.
037:            private static final Log sLogger = LogFactory
038:                    .getLog(MOFUtils.class);
039:
040:            /** This structure keeps additional type information */
041:            private static class TypeInformation {
042:                private String mTypeName;
043:                private List mParentReferences;// References to all possible containers
044:                private List mContainedCollectionsReferences; // References to all contained collections
045:                private List mContainedReferences; // References to all contained objects
046:                private Map mAllReferences; // All references mapped by name
047:            }
048:
049:            // Map of type information per MofObject 
050:            private static Map sTypeInfoMap = new HashMap();
051:
052:            // This is toolbox - we are not supposed to create instances of it
053:            private MOFUtils() {
054:            }
055:
056:            /** Returns map of all Reference objects describing possible references of the given object */
057:            public static Map getAllReferences(RefObject pModelElement) {
058:                TypeInformation lTypeInformation = getTypeInformation(pModelElement);
059:                return lTypeInformation.mAllReferences;
060:            }
061:
062:            // Helper. Returns cached type information     
063:            private static TypeInformation getTypeInformation(
064:                    RefObject pModelElement) {
065:                MofClass lMetaObject = (MofClass) pModelElement.refMetaObject();
066:                TypeInformation lTypeInformation = (TypeInformation) sTypeInfoMap
067:                        .get(lMetaObject);
068:                if (lTypeInformation == null) {
069:                    lTypeInformation = new TypeInformation();
070:                    lTypeInformation.mTypeName = (String) lMetaObject
071:                            .refGetValue("name");
072:                    lTypeInformation.mParentReferences = new ArrayList();
073:                    lTypeInformation.mContainedCollectionsReferences = new ArrayList();
074:                    lTypeInformation.mContainedReferences = new ArrayList();
075:                    Map lAllReferences = new HashMap();
076:                    // Find out the reference name in parent and multiplicity of the association if multiplicty is one - we do not need instance name
077:                    // Collect contents for the type and all supertypes
078:                    List lAllContents = new ArrayList();
079:                    lAllContents.addAll(lMetaObject.getContents());
080:                    for (Iterator lSupertypesIterator = lMetaObject
081:                            .allSupertypes().iterator(); lSupertypesIterator
082:                            .hasNext();)
083:                        lAllContents.addAll(((MofClass) lSupertypesIterator
084:                                .next()).getContents());
085:                    for (Iterator lAllContentsIterator = lAllContents
086:                            .iterator(); lAllContentsIterator.hasNext();) {
087:                        ModelElement lFeature = (ModelElement) lAllContentsIterator
088:                                .next();
089:                        if (lFeature instanceof  Reference) {
090:                            Reference lReference = (Reference) lFeature;
091:                            String lReferenceName = lReference.getName();
092:                            lAllReferences.put(lReferenceName, lReference);
093:                            AssociationEnd lReferencedEnd = lReference
094:                                    .getReferencedEnd();
095:                            if (lReferencedEnd.getAggregation().equals(
096:                                    AggregationKindEnum.COMPOSITE)) {
097:                                lTypeInformation.mParentReferences
098:                                        .add(lReference);
099:                            } else {
100:                                AssociationEnd lExposedEnd = lReference
101:                                        .getExposedEnd();
102:                                if (lExposedEnd.getAggregation().equals(
103:                                        AggregationKindEnum.COMPOSITE)) {
104:                                    lTypeInformation.mContainedReferences
105:                                            .add(lReference);
106:                                    if (lReferencedEnd.getMultiplicity()
107:                                            .getUpper() != 1)
108:                                        lTypeInformation.mContainedCollectionsReferences
109:                                                .add(lReference);
110:                                }
111:                            }
112:                        }
113:                    }
114:                    lTypeInformation.mAllReferences = Collections
115:                            .unmodifiableMap(lAllReferences);
116:                    sTypeInfoMap.put(lMetaObject, lTypeInformation);
117:                }
118:                return lTypeInformation;
119:            }
120:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.