Skip to content

Commit

Permalink
java_utils.clj: added as-url multimethod
Browse files Browse the repository at this point in the history
  • Loading branch information
Stuart Sierra committed Jun 8, 2009
1 parent 2c75edd commit 4f2bc54
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/clojure/contrib/java_utils.clj
Expand Up @@ -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:
Expand All @@ -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.
Expand Down Expand Up @@ -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))



0 comments on commit 4f2bc54

Please sign in to comment.