forked from stuarthalloway/programming-clojure
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2669ac6
commit a3c829f
Showing
5 changed files
with
32 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
java -cp classes;lib/clojure.jar;lib/clojure-contrib.jar reader.tasklist %1 %2 %3 %4 %5 %6 %7 %8 %9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
java -cp classes:lib/clojure.jar:lib/clojure-contrib.jar reader.tasklist $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,37 @@ | ||
(ns examples.tasklist | ||
(:gen-class | ||
:extends org.xml.sax.helpers.DefaultHandler | ||
:init init | ||
:state state) | ||
(:use [clojure.contrib.duck-streams :only (reader)]) | ||
(:import [java.io File] | ||
[org.xml.sax InputSource] | ||
[org.xml.sax.helpers DefaultHandler] | ||
[javax.xml.parsers SAXParserFactory]) | ||
(:gen-class | ||
:extends org.xml.sax.helpers.DefaultHandler | ||
:init init | ||
:state state)) | ||
[javax.xml.parsers SAXParserFactory])) | ||
|
||
; START: task-list | ||
(defn task-list [arg] | ||
(let [handler (new examples.tasklist)] | ||
(let [handler (new examples.tasklist)] ; <label id="code.tasklist.classname"/> | ||
(.. SAXParserFactory newInstance newSAXParser | ||
(parse (InputSource. (reader (File. arg))) | ||
handler)) | ||
@(.state handler))) | ||
@(.state handler))) ; <label id="code.tasklist.statename"/> | ||
; END: task-list | ||
|
||
; START: init | ||
(defn -init [] | ||
[[] (atom [])]) | ||
; END: init | ||
|
||
; START: startElement | ||
(defn -startElement | ||
[this uri local qname atts] | ||
(when (= qname "target") | ||
(swap! (.state this) conj (.getValue atts "name")))) | ||
(swap! (.state this) conj (.getValue atts "name")))) ; <label id="code.tasklist.update"/> | ||
; END: startElement | ||
|
||
; START: main | ||
(defn -main [& args] | ||
(doseq [arg args] | ||
(println (task-list arg)))) | ||
(println (task-list arg)))) | ||
; END: main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
(ns reader.tasklist | ||
(:gen-class ; <label id="code.tasklist.genclass"/> | ||
:extends org.xml.sax.helpers.DefaultHandler ; <label id="code.tasklist.extends"/> | ||
:state state ; <label id="code.tasklist.state"/> | ||
:init init) ; <label id="code.tasklist.init"/> | ||
(:use [clojure.contrib.duck-streams :only (reader)]) | ||
(:import [java.io File] | ||
[org.xml.sax InputSource] | ||
[org.xml.sax.helpers DefaultHandler] | ||
[javax.xml.parsers SAXParserFactory])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters