diff options
author | Stuart Sierra <mail@stuartsierra.com> | 2009-06-08 14:08:23 +0000 |
---|---|---|
committer | Stuart Sierra <mail@stuartsierra.com> | 2009-06-08 14:08:23 +0000 |
commit | 4f2bc54dbb3a479deeeded8ddfa09f9968bd4ad1 (patch) | |
tree | 8cc9f562430745a95929930ffd238bca9043466c /src | |
parent | 2c75edd4a1764b9453107e50feceb0fc185faae2 (diff) |
java_utils.clj: added as-url multimethod
Diffstat (limited to 'src')
-rw-r--r-- | src/clojure/contrib/java_utils.clj | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/clojure/contrib/java_utils.clj b/src/clojure/contrib/java_utils.clj index 0f7221e4..ea6ab90a 100644 --- a/src/clojure/contrib/java_utils.clj +++ b/src/clojure/contrib/java_utils.clj @@ -30,9 +30,10 @@ ; Stephen C. Gilardi ; Shawn Hoover ; Perry Trolard +; Stuart Sierra (ns - #^{:author "Stuart Halloway, Stephen C. Gilardi, Shawn Hoover, Perry Trolard", + #^{:author "Stuart Halloway, Stephen C. Gilardi, Shawn Hoover, Perry Trolard, Stuart Sierra", :doc "A set of utilties for dealing with Java stuff like files and properties. Design goals: @@ -55,7 +56,8 @@ "} clojure.contrib.java-utils (:import [java.io File] - [java.util Properties])) + [java.util Properties] + [java.net URI URL])) (defmulti relative-path-string "Interpret a String or java.io.File as a relative path string. @@ -155,6 +157,14 @@ (doto (as-properties m) (.store f comments))))) +(defmulti + #^{:doc "Coerces argument (URL, URI, or String) to a java.net.URL." + :arglists '([arg])} + as-url type) + +(defmethod as-url URL [x] x) + +(defmethod as-url URI [#^URI x] (.toURL x)) + +(defmethod as-url String [#^String x] (URL. x)) - - |