Revision: 7778
Author: victormote
Date: 2006-07-08 14:56:34 -0700 (Sat, 08 Jul 2006)
ViewCVS: http://svn.sourceforge.net/foray/?rev=7778&view=rev
Log Message:
-----------
Add method to return a registered Handler if possible.
Modified Paths:
--------------
trunk/foray/foray-common/src/java/org/foray/common/url/FactoryProtocolRegistration.java
trunk/foray/foray-common/src/java/org/foray/common/url/PropertyProtocolRegistration.java
trunk/foray/foray-common/src/java/org/foray/common/url/ProtocolRegistrationBroker.java
trunk/foray/foray-common/src/java/org/foray/common/url/ProtocolRegistrationStrategy.java
trunk/foray/foray-common/src/java/org/foray/common/url/UniversalProtocolRegistration.java
Modified: trunk/foray/foray-common/src/java/org/foray/common/url/FactoryProtocolRegistration.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/url/FactoryProtocolRegistration.java 2006-07-08 19:46:39 UTC (rev 7777)
+++ trunk/foray/foray-common/src/java/org/foray/common/url/FactoryProtocolRegistration.java 2006-07-08 21:56:34 UTC (rev 7778)
@@ -87,4 +87,13 @@
!= null;
}
+ /**
+ * {@inheritDoc}
+ */
+ public URLStreamHandler getURLStreamHandler(String protocol) {
+ URLStreamHandlerFactory factory =
+ FOrayURLStreamHandlerFactory.getURLStreamHandlerFactory();
+ return factory.createURLStreamHandler(protocol);
+ }
+
}
Modified: trunk/foray/foray-common/src/java/org/foray/common/url/PropertyProtocolRegistration.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/url/PropertyProtocolRegistration.java 2006-07-08 19:46:39 UTC (rev 7777)
+++ trunk/foray/foray-common/src/java/org/foray/common/url/PropertyProtocolRegistration.java 2006-07-08 21:56:34 UTC (rev 7778)
@@ -130,4 +130,11 @@
System.setProperty(javaProperty, searchPath);
}
+ /**
+ * {@inheritDoc}
+ */
+ public URLStreamHandler getURLStreamHandler(String protocol) {
+ return (URLStreamHandler) this.protocols.get(protocol);
+ }
+
}
Modified: trunk/foray/foray-common/src/java/org/foray/common/url/ProtocolRegistrationBroker.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/url/ProtocolRegistrationBroker.java 2006-07-08 19:46:39 UTC (rev 7777)
+++ trunk/foray/foray-common/src/java/org/foray/common/url/ProtocolRegistrationBroker.java 2006-07-08 21:56:34 UTC (rev 7778)
@@ -26,6 +26,7 @@
package org.foray.common.url;
+import java.net.URLStreamHandler;
import java.net.URLStreamHandlerFactory;
/**
@@ -137,4 +138,15 @@
return strategy;
}
+ /**
+ * Convenience method making registered protocol handler available in a
+ * static way.
+ * @param protocol The protocol for which a Handler is sought.
+ * @return The Handler for <code>protocol</code>, or null if it has not
+ * been registered.
+ */
+ public static URLStreamHandler getURLStreamHandler(String protocol) {
+ return strategy.getURLStreamHandler(protocol);
+ }
+
}
Modified: trunk/foray/foray-common/src/java/org/foray/common/url/ProtocolRegistrationStrategy.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/url/ProtocolRegistrationStrategy.java 2006-07-08 19:46:39 UTC (rev 7777)
+++ trunk/foray/foray-common/src/java/org/foray/common/url/ProtocolRegistrationStrategy.java 2006-07-08 21:56:34 UTC (rev 7778)
@@ -42,4 +42,13 @@
* used for URLs whose protocol is <code>protocol</code>.
*/
void registerProtocolHandler(String protocol, URLStreamHandler handler);
+
+ /**
+ * Finds the registered URLStreamHandler for a given protocol.
+ * @param protocol The protocol for which a URLStreamHandler is desired.
+ * @return The URLStreamHandler registered with this registration scheme,
+ * or null if the protocol has not been registered.
+ */
+ URLStreamHandler getURLStreamHandler(String protocol) ;
+
}
Modified: trunk/foray/foray-common/src/java/org/foray/common/url/UniversalProtocolRegistration.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/url/UniversalProtocolRegistration.java 2006-07-08 19:46:39 UTC (rev 7777)
+++ trunk/foray/foray-common/src/java/org/foray/common/url/UniversalProtocolRegistration.java 2006-07-08 21:56:34 UTC (rev 7778)
@@ -76,4 +76,11 @@
delegate.registerProtocolHandler(protocol, handler);
}
+ /**
+ * {@inheritDoc}
+ */
+ public URLStreamHandler getURLStreamHandler(String protocol) {
+ return delegate.getURLStreamHandler(protocol);
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|