Source Code Cross Referenced for ModelRepositoryUtils.java in  » UML » MetaBoss » com » metaboss » sdlctools » models » 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 
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;
016:
017:        import java.util.ArrayList;
018:        import java.util.Arrays;
019:        import java.util.Collection;
020:        import java.util.Collections;
021:        import java.util.HashSet;
022:        import java.util.Iterator;
023:        import java.util.List;
024:        import java.util.Set;
025:
026:        import javax.jmi.model.AssociationEnd;
027:        import javax.jmi.model.Reference;
028:        import javax.jmi.reflect.RefBaseObject;
029:        import javax.jmi.reflect.RefClass;
030:        import javax.jmi.reflect.RefObject;
031:        import javax.jmi.reflect.RefPackage;
032:
033:        import com.metaboss.sdlctools.models.impl.MOFUtils;
034:
035:        /** Contains some useful utilities. */
036:        public class ModelRepositoryUtils {
037:            /** This method navigates the package hierarchy for the given object and returns it in form of array 'path' of packages.  
038:             * @return RefPackage[] hierarchy of packages for the object. Outermost package occupying zero element of the returned array */
039:            public static RefPackage[] getPackageHierarchy(RefBaseObject pObject) {
040:                RefPackage lOutermostPackage = pObject.refOutermostPackage();
041:                if (lOutermostPackage.equals(pObject))
042:                    return new RefPackage[0]; // Looks like we have been passed an outermost package
043:                RefPackage lImmediatePackage = pObject.refImmediatePackage();
044:                List lPackageHierarchy = new ArrayList();
045:                lPackageHierarchy.addAll(Arrays
046:                        .asList(getPackageHierarchy(lImmediatePackage)));
047:                lPackageHierarchy.add(lImmediatePackage);
048:                return (RefPackage[]) lPackageHierarchy
049:                        .toArray(new RefPackage[lPackageHierarchy.size()]);
050:            }
051:
052:            /** This method returns all instances of all objects in the given package and all subpackages
053:             * @return RefObject[] aray of all instance objects in the given package and all subpackages */
054:            public static RefObject[] getAllInstancesInPackage(
055:                    RefPackage pPackage) {
056:                Set lAllInstances = new HashSet();
057:                RefPackage lPackageOwner = pPackage.refOutermostPackage();
058:                // Find all instances of all classes in this package
059:                for (Iterator lAllClassesIter = pPackage.refAllClasses()
060:                        .iterator(); lAllClassesIter.hasNext();) {
061:                    RefClass lClass = (RefClass) lAllClassesIter.next();
062:                    for (Iterator lInstancesIterator = lClass.refAllOfClass()
063:                            .iterator(); lInstancesIterator.hasNext();) {
064:                        RefObject lInstance = (RefObject) lInstancesIterator
065:                                .next();
066:                        if (lInstance.refOutermostPackage().equals(
067:                                lPackageOwner))
068:                            lAllInstances.add(lInstance);
069:                    }
070:                }
071:                // Find all subpackages and call this method recursively
072:                for (Iterator lAllPackagesIter = pPackage.refAllPackages()
073:                        .iterator(); lAllPackagesIter.hasNext();) {
074:                    RefPackage lSubPackage = (RefPackage) lAllPackagesIter
075:                            .next();
076:                    lAllInstances.addAll(Arrays
077:                            .asList(getAllInstancesInPackage(lSubPackage)));
078:                }
079:                return (RefObject[]) lAllInstances
080:                        .toArray(new RefObject[lAllInstances.size()]);
081:            }
082:
083:            /** @return Collection of RefObjects directly referenced by this element */
084:            public static Collection getReferencedElements(
085:                    RefObject pReferencingObject) {
086:                //		if (pReferencingObject instanceof ModelElement)
087:                //			return ((ModelElement)pReferencingObject).getReferencedElements();
088:                Collection lAllReferences = MOFUtils.getAllReferences(
089:                        pReferencingObject).values();
090:                if (lAllReferences.isEmpty())
091:                    return Collections.EMPTY_LIST;
092:                Set lAllReferencedObjects = new HashSet();
093:                for (Iterator lAllReferencesIterator = lAllReferences
094:                        .iterator(); lAllReferencesIterator.hasNext();) {
095:                    Reference lReference = (Reference) lAllReferencesIterator
096:                            .next();
097:                    AssociationEnd lReferencedEnd = lReference
098:                            .getReferencedEnd();
099:                    if (lReferencedEnd.getMultiplicity().getUpper() != 1) {
100:                        // This is the collection
101:                        Collection lReferencedObjectsCollection = (Collection) pReferencingObject
102:                                .refGetValue(lReference);
103:                        if (!lReferencedObjectsCollection.isEmpty())
104:                            lAllReferencedObjects
105:                                    .addAll(lReferencedObjectsCollection);
106:                    } else {
107:                        RefObject lReferencedObject = (RefObject) pReferencingObject
108:                                .refGetValue(lReference);
109:                        if (lReferencedObject != null)
110:                            lAllReferencedObjects.add(lReferencedObject);
111:                    }
112:                }
113:                return Collections
114:                        .unmodifiableCollection(lAllReferencedObjects);
115:            }
116:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.