diff options
author | Ben Smith-Mannschott <bsmith.occs@gmail.com> | 2010-10-02 21:57:40 +0200 |
---|---|---|
committer | Stuart Sierra <mail@stuartsierra.com> | 2010-10-02 18:46:12 -0400 |
commit | 456fbaa7b926de77a9d829b4f3664c6fbed8361e (patch) | |
tree | e769646cb158524107d83d94adb29b98f2b30b60 | |
parent | c115db1caa3c18bc1648616ef47a13a9b912c3f4 (diff) |
t100: removed deprecated functions form c.c.java-utils
removed: relative-path-string, as-file, file, as-str, delete-file,
delete-file-recursively, as-url, wall-hack-method,
wall-hack-field
use instead: clojure.java.io and clojure.contrib.reflections
Signed-off-by: Stuart Sierra <mail@stuartsierra.com>
-rw-r--r-- | modules/java-utils/src/main/clojure/clojure/contrib/java_utils.clj | 115 |
1 files changed, 2 insertions, 113 deletions
diff --git a/modules/java-utils/src/main/clojure/clojure/contrib/java_utils.clj b/modules/java-utils/src/main/clojure/clojure/contrib/java_utils.clj index 65e84eda..397a4a7b 100644 --- a/modules/java-utils/src/main/clojure/clojure/contrib/java_utils.clj +++ b/modules/java-utils/src/main/clojure/clojure/contrib/java_utils.clj @@ -9,8 +9,8 @@ ;; ;; CHANGELOG ;; -;; Most functions deprecated in 1.2. Some already exist in c.c.io, and -;; some replaced by c.c.reflections +;; Functions deprecated in 1.2, have been removed. +;; Some have migrated to clojure.java.io and others to c.c.reflections. (ns ^{:author "Stuart Halloway, Stephen C. Gilardi, Shawn Hoover, Perry Trolard, Stuart Sierra", @@ -46,65 +46,6 @@ [java.util Properties] [java.net URI URL])) -(defmulti relative-path-string - "Interpret a String or java.io.File as a relative path string. - Building block for clojure.contrib.java-utils/file." - {:deprecated "1.2"} - class) - -(defmethod relative-path-string String [^String s] - (relative-path-string (File. s))) - -(defmethod relative-path-string File [^File f] - (if (.isAbsolute f) - (throw (IllegalArgumentException. (str f " is not a relative path"))) - (.getPath f))) - -(defmulti ^File as-file - "Interpret a String or a java.io.File as a File. Building block - for clojure.contrib.java-utils/file, which you should prefer - in most cases." - {:deprecated "1.2"} - class) -(defmethod as-file String [^String s] (File. s)) -(defmethod as-file File [f] f) - -(defn ^File file - "Returns a java.io.File from string or file args." - {:deprecated "1.2"} - ([arg] - (as-file arg)) - ([parent child] - (File. ^File (as-file parent) ^String (relative-path-string child))) - ([parent child & more] - (reduce file (file parent child) more))) - -(defn as-str - "Like clojure.core/str, but if an argument is a keyword or symbol, - its name will be used instead of its literal representation. - - Example: - (str :foo :bar) ;;=> \":foo:bar\" - (as-str :foo :bar) ;;=> \"foobar\" - - Note that this does not apply to keywords or symbols nested within - data structures; they will be rendered as with str. - - Example: - (str {:foo :bar}) ;;=> \"{:foo :bar}\" - (as-str {:foo :bar}) ;;=> \"{:foo :bar}\" " - {:deprecated "1.2"} - ([] "") - ([x] (if (instance? clojure.lang.Named x) - (name x) - (str x))) - ([x & ys] - ((fn [^StringBuilder sb more] - (if more - (recur (. sb (append (as-str (first more)))) (next more)) - (str sb))) - (new StringBuilder ^String (as-str x)) ys))) - (defn get-system-property "Get a system property." ([stringable] @@ -165,55 +106,3 @@ (with-open [^FileOutputStream f (FileOutputStream. (file file-able))] (doto (as-properties m) (.store f ^String comments))))) - -(defn delete-file - "Delete file f. Raise an exception if it fails unless silently is true." - {:deprecated "1.2"} - [f & [silently]] - (or (.delete (file f)) - silently - (throw (java.io.IOException. (str "Couldn't delete " f))))) - -(defn delete-file-recursively - "Delete file f. If it's a directory, recursively delete all its contents. -Raise an exception if any deletion fails unless silently is true." - {:deprecated "1.2"} - [f & [silently]] - (let [f (file f)] - (if (.isDirectory f) - (doseq [child (.listFiles f)] - (delete-file-recursively child silently))) - (delete-file f silently))) - -(defmulti - ^{:deprecated "1.2" - :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)) - -(defmethod as-url File [^File x] (.toURL x)) - -(defn wall-hack-method - "Calls a private or protected method. - params is a vector of class which correspond to the arguments to the method - obj is nil for static methods, the instance object otherwise - the method name is given as a symbol or a keyword (something Named)" - {:deprecated "1.2"} - [class-name method-name params obj & args] - (-> class-name (.getDeclaredMethod (name method-name) (into-array Class params)) - (doto (.setAccessible true)) - (.invoke obj (into-array Object args)))) - -(defn wall-hack-field - "Access to private or protected field." - {:deprecated "1.2"} - [class-name field-name obj] - (-> class-name (.getDeclaredField (name field-name)) - (doto (.setAccessible true)) - (.get obj))) |