Source Code Cross Referenced for AbstractUDIGConnectionFactory.java in  » GIS » udig-1.1 » net » refractions » udig » catalog » ui » 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 » GIS » udig 1.1 » net.refractions.udig.catalog.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* uDig - User Friendly Desktop Internet GIS client
002:         * http://udig.refractions.net
003:         * (C) 2004, Refractions Research Inc.
004:         *
005:         * This library is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU Lesser General Public
007:         * License as published by the Free Software Foundation;
008:         * version 2.1 of the License.
009:         *
010:         * This library is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013:         * Lesser General Public License for more details.
014:         */
015:        package net.refractions.udig.catalog.ui;
016:
017:        import java.io.Serializable;
018:        import java.net.MalformedURLException;
019:        import java.net.URL;
020:        import java.util.Map;
021:
022:        import net.refractions.udig.catalog.CatalogPlugin;
023:        import net.refractions.udig.catalog.ServiceExtension2;
024:
025:        /**
026:         * Adds some generic checks to attempt to process URLs and Map context objects.  Essentially queries
027:         * the ServiceExtension for the Service in order to determine whether it can handle the context objects.
028:         * 
029:         * <p> The context objects this will process are:
030:         * <ul>
031:         * <li>URLs</li>
032:         * <li>Map</li>
033:         * <li>String - it will try to convert the string to a URL if other processing needs to be done to a string then the subclass will have to do it</li>
034:         * 
035:         * @author Jesse
036:         * @since 1.1.0
037:         */
038:        public abstract class AbstractUDIGConnectionFactory extends
039:                UDIGConnectionFactory {
040:
041:            /**
042:             * Will use the service extension to try and determine if the context is useable.
043:             * 
044:             * <p> Will try to process URLs, Maps and Strings.  String processing is limited to trying
045:             * to create a URL from the string and then processing it with the ServiceExtension</p>
046:             * <p>{@link CatalogPlugin#locateURL(Object)} is used to attempt to create a URL from the context object
047:             * <p>{@link #doOtherChecks(Object)} will be called if the context is not a URL or a Map or if the String cannot be processed as a URL.
048:             * @param context The object to be "processed" or "adapted" into connection
049:             * information.
050:             * @return True if the info can be returned based on the conext, otherwise
051:             * false.
052:             */
053:            @SuppressWarnings("unchecked")
054:            @Override
055:            public final boolean canProcess(Object context) {
056:                ServiceExtension2 serviceExtension = getServiceExtension();
057:                if (context instanceof  URL) {
058:                    URL url = (URL) context;
059:                    return serviceExtension.reasonForFailure(url) == null;
060:                }
061:                if (context instanceof  String) {
062:
063:                    // if the string cannot be processed we want to fall through so
064:                    // that doOtherChecks() can be called.
065:                    String string = (String) context;
066:                    try {
067:                        URL url = new URL(string);
068:                        if (serviceExtension.reasonForFailure(url) == null)
069:                            return true;
070:                    } catch (MalformedURLException e) {
071:                        // continue.
072:                    }
073:                }
074:                if (context instanceof  Map) {
075:                    Map map = (Map) context;
076:                    return serviceExtension.reasonForFailure(map) == null;
077:                }
078:                if (CatalogPlugin.locateURL(context) != null) {
079:                    return serviceExtension.reasonForFailure(CatalogPlugin
080:                            .locateURL(context)) == null;
081:                }
082:                return doOtherChecks(context);
083:            }
084:
085:            /**
086:             * If contexts other than URLs, Maps, and Strings (or if Strings need to be otherwise processed) then subclass must
087:             * perform those checks here.
088:             *
089:             * @param context The object to be "processed" or "adapted" into connection
090:             * information.
091:             * @return True if the info can be returned based on the conext, otherwise
092:             * false.
093:             */
094:            protected abstract boolean doOtherChecks(Object context);
095:
096:            /**
097:             * Returns the Service extension for the extension in question.
098:             *
099:             * @return the Service extension for the extension in question.
100:             */
101:            protected abstract ServiceExtension2 getServiceExtension();
102:
103:            /**
104:             * Returns the parameters using the Service extension if the context is a URL or String (provided that Service extension 
105:             * claims to be able to process them).  If the context is a map it will be returned (again only if Service Extension claims to be
106:             * able to consume it).  Otherwise {@link #doCreateConnectionParameters(Object)} will be called.
107:             */
108:            @SuppressWarnings("unchecked")
109:            @Override
110:            public final Map<String, Serializable> createConnectionParameters(
111:                    Object context) {
112:                ServiceExtension2 serviceExtension = getServiceExtension();
113:                if (context instanceof  URL) {
114:                    URL url = (URL) context;
115:                    if (serviceExtension.reasonForFailure(url) == null)
116:                        return serviceExtension.createParams(url);
117:                }
118:                if (context instanceof  String) {
119:
120:                    // if the string cannot be processed we want to fall through so
121:                    // that doOtherChecks() can be called.
122:                    String string = (String) context;
123:                    try {
124:                        URL url = new URL(string);
125:                        if (serviceExtension.reasonForFailure(url) == null)
126:                            return serviceExtension.createParams(url);
127:                        ;
128:                    } catch (MalformedURLException e) {
129:                        // continue.
130:                    }
131:                }
132:
133:                if (context instanceof  Map) {
134:                    Map params = (Map) context;
135:                    if (serviceExtension.reasonForFailure(params) == null)
136:                        return params;
137:
138:                }
139:                URL locateURL = CatalogPlugin.locateURL(context);
140:                if (locateURL != null) {
141:                    if (serviceExtension.reasonForFailure(locateURL) == null)
142:                        return serviceExtension.createParams(locateURL);
143:                }
144:                return doCreateConnectionParameters(context);
145:            }
146:
147:            /**
148:             * Called if {@link #createConnectionParameters(Object)} fails to return a value
149:             */
150:            protected abstract Map<String, Serializable> doCreateConnectionParameters(
151:                    Object context);
152:
153:            /**
154:             * Returns the URL if the context is a URL or can be made a URL from a String(provided that Service extension 
155:             * claims to be able to process them).  If the context anything else then 
156:             * {@link #doCreateConnectionURL(Object)} will be called.
157:             */
158:            @Override
159:            public final URL createConnectionURL(Object context) {
160:                ServiceExtension2 serviceExtension = getServiceExtension();
161:                if (context instanceof  URL) {
162:                    URL url = (URL) context;
163:                    if (serviceExtension.reasonForFailure(url) == null)
164:                        return url;
165:                }
166:                if (context instanceof  String) {
167:
168:                    // if the string cannot be processed we want to fall through so
169:                    // that doOtherChecks() can be called.
170:                    String string = (String) context;
171:                    try {
172:                        URL url = new URL(string);
173:                        if (serviceExtension.reasonForFailure(url) == null)
174:                            return url;
175:                    } catch (MalformedURLException e) {
176:                        // continue.
177:                    }
178:                }
179:                URL locateURL = CatalogPlugin.locateURL(context);
180:                if (locateURL != null) {
181:                    if (serviceExtension.reasonForFailure(locateURL) == null)
182:                        return locateURL;
183:                }
184:                return doCreateConnectionURL(context);
185:            }
186:
187:            /**
188:             * Called if {@link #createConnectionURL(Object)} fails to return a value
189:             */
190:            protected abstract URL doCreateConnectionURL(Object context);
191:
192:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.