Skip to content

Commit

Permalink
Stop using c.c.java in pprint examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chouser committed Feb 11, 2010
1 parent b1ef935 commit 5d30e63
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/examples/clojure/clojure/contrib/pprint/examples/json.clj
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
This is an example of using a pretty printer dispatch function to generate JSON output",
:see-also [["http://json.org/", "JSON Home Page"]]}
clojure.contrib.pprint.examples.json
(:require [clojure.contrib.java :as j])
(:use [clojure.test :only (deftest- is)]
[clojure.contrib.string :only (as-str)]
[clojure.contrib.pprint :only (write formatter-out)]))


Expand Down Expand Up @@ -62,7 +62,7 @@ This is an example of using a pretty printer dispatch function to generate JSON

(defmethod dispatch-json ::object [m]
((formatter-out "~<{~;~@{~<~w:~_~w~:>~^, ~_~}~;}~:>")
(for [[k v] m] [(j/as-str k) v])))
(for [[k v] m] [(as-str k) v])))

(defmethod dispatch-json java.lang.CharSequence [s]
(print \")
Expand Down
10 changes: 7 additions & 3 deletions src/examples/clojure/clojure/contrib/pprint/examples/xml.clj
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
#^{:author "Tom Faulhaber, based on the original by Stuart Sierra",
:doc "A version of prxml that uses a pretty print dispatch function."}
clojure.contrib.pprint.examples.xml
(:use [clojure.contrib.lazy-xml :only (escape-xml)]
[clojure.contrib.java :only (as-str)]
(:use [clojure.contrib.string :only (as-str escape)]
[clojure.contrib.pprint :only (formatter-out write)]
[clojure.contrib.pprint.utilities :only (prlabel)]))

Expand Down Expand Up @@ -80,8 +79,13 @@
(defmethod xml-dispatch clojure.lang.Keyword [x]
(print-xml-tag x {} nil))


(defmethod xml-dispatch String [x]
(print (escape-xml x)))
(print (escape {\< "&lt;"
\> "&gt;"
\& "&amp;"
\' "&apos;"
\" "&quot;"} x)))

(defmethod xml-dispatch nil [x])

Expand Down

0 comments on commit 5d30e63

Please sign in to comment.