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


001:        package org.andromda.cartridges.webservice;
002:
003:        import java.util.Collection;
004:        import java.util.LinkedHashSet;
005:
006:        import org.andromda.cartridges.webservice.metafacades.WSDLEnumerationType;
007:        import org.andromda.cartridges.webservice.metafacades.WSDLType;
008:        import org.andromda.metafacades.uml.ClassifierFacade;
009:        import org.andromda.metafacades.uml.Service;
010:        import org.andromda.metafacades.uml.TypeMappings;
011:        import org.apache.commons.collections.Closure;
012:        import org.apache.commons.collections.CollectionUtils;
013:        import org.apache.commons.lang.StringUtils;
014:
015:        /**
016:         * Contains utilities used within the WebService cartridge.
017:         *
018:         * @author Chad Brandon
019:         */
020:        public class WebServiceUtils {
021:            /**
022:             * Retrieves all roles from the given <code>services</code> collection.
023:             *
024:             * @param services the collection services.
025:             * @return all roles from the collection.
026:             */
027:            public Collection getAllRoles(Collection services) {
028:                final Collection allRoles = new LinkedHashSet();
029:                CollectionUtils.forAllDo(services, new Closure() {
030:                    public void execute(Object object) {
031:                        if (object != null
032:                                && Service.class.isAssignableFrom(object
033:                                        .getClass())) {
034:                            allRoles.addAll(((Service) object).getAllRoles());
035:                        }
036:                    }
037:                });
038:                return allRoles;
039:            }
040:
041:            /**
042:             * Reverses the <code>packageName</code>.
043:             *
044:             * @param packageName the package name to reverse.
045:             * @return the reversed package name.
046:             */
047:            public static String reversePackage(String packageName) {
048:                return StringUtils.reverseDelimited(packageName,
049:                        WebServiceGlobals.NAMESPACE_DELIMITER);
050:            }
051:
052:            /**
053:             * <p/> Creates and returns the schema type for the given <code>type</code>.
054:             * It finds the mapped schema type from the passed in
055:             * <code>schemaTypeMappings</code>.
056:             * </p>
057:             * 
058:             * @param type the ClassifierFacade instance
059:             * @param schemaTypeMappings contains the mappings from model datatypes to
060:             *        schema datatypes.
061:             * @param namespacePrefix the prefix given to the schema type if it's a
062:             *        custom type (non XSD type).
063:             * @param qName the qualifed name
064:             * @param wrappedArrayTypePrefix a prefix to give to wrapped array types.
065:             * @param withPrefix a flag indicating whether or not the type should have
066:             *        the prefix defined
067:             * @param preserveArray true/false, if true then if the schema type is an
068:             *        array we'll preserve the fact that its an array and return an
069:             *        array schema type name. If false we will return back the non array
070:             *        type even if its an array.
071:             * @return the schema type name.
072:             */
073:            public static java.lang.String getSchemaType(ClassifierFacade type,
074:                    TypeMappings schemaTypeMappings, String namespacePrefix,
075:                    String qName, String wrappedArrayTypePrefix,
076:                    boolean withPrefix, boolean preserveArray) {
077:                StringBuffer schemaType = new StringBuffer();
078:                String modelName = type.getFullyQualifiedName(true);
079:                if (schemaTypeMappings != null) {
080:                    namespacePrefix = namespacePrefix + ':';
081:                    String mappedValue = schemaTypeMappings.getTo(modelName);
082:                    if (!mappedValue.equals(modelName)) {
083:                        schemaType.append(mappedValue);
084:                    } else {
085:                        if (withPrefix) {
086:                            schemaType.append(namespacePrefix);
087:                        }
088:                        if (type.isArrayType()) {
089:                            ClassifierFacade nonArray = type.getNonArray();
090:                            if (nonArray != null) {
091:                                if (nonArray instanceof  WSDLType) {
092:                                    schemaType.append(((WSDLType) nonArray)
093:                                            .getQName());
094:                                } else if (nonArray instanceof  WSDLEnumerationType) {
095:                                    schemaType
096:                                            .append(((WSDLEnumerationType) nonArray)
097:                                                    .getQName());
098:                                }
099:                            }
100:                        } else {
101:                            schemaType.append(qName);
102:                        }
103:                    }
104:                    // remove any array '[]' suffix
105:                    schemaType = new StringBuffer(schemaType.toString()
106:                            .replaceAll("\\[\\]", ""));
107:                    if (preserveArray && type.isArrayType()) {
108:                        int insertIndex = namespacePrefix.length();
109:                        if (!schemaType.toString().startsWith(namespacePrefix)) {
110:                            if (withPrefix) {
111:                                // add the prefix for any normal XSD types
112:                                // that may not have been set above
113:                                schemaType.insert(0, namespacePrefix);
114:                            } else {
115:                                // since we aren't adding the prefix, set
116:                                // the correct insert index
117:                                insertIndex = 0;
118:                            }
119:                        }
120:                        schemaType.insert(insertIndex, wrappedArrayTypePrefix);
121:                    }
122:                    if (withPrefix
123:                            && !schemaType.toString().startsWith(
124:                                    namespacePrefix)) {
125:                        schemaType.insert(0,
126:                                WebServiceGlobals.XSD_NAMESPACE_PREFIX);
127:                    }
128:                }
129:                return schemaType.toString();
130:            }
131:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.