Skip to content

Commit 89bfc8e

Browse files
committed
regenerate site
1 parent 5912b19 commit 89bfc8e

File tree

5 files changed

+91
-88
lines changed

5 files changed

+91
-88
lines changed

articles/cookbooks/parsing_xml_with_zippers/index.html

+6-6
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ <h2>Parsing XML in Clojure</h2>
7171
<p>This work is licensed under a <a rel="license" href="https://creativecommons.org/licenses/by/3.0/">Creative Commons
7272
Attribution 3.0 Unported License</a> (including images &amp;
7373
stylesheets). The source is available <a href="https://github.com/clojure-doc/clojure-doc.github.io">on
74-
Github</a>.</p><h2 id="what-version-of-clojure-does-this-guide-cover">What Version of Clojure Does This Guide Cover?</h2><p>This guide covers Clojure 1.11 and Leiningen 2.x.</p><h2 id="overview">Overview</h2><p>Try as you might, XML is difficult to avoid. This is particularly true
74+
Github</a>.</p><h2 id="what-version-of-clojure-does-this-guide-cover">What Version of Clojure Does This Guide Cover?</h2><p>This guide covers Clojure 1.12 and Leiningen 2.x.</p><h2 id="overview">Overview</h2><p>Try as you might, XML is difficult to avoid. This is particularly true
7575
in the Java ecosystem. This guide will show you how to parse XML with
7676
the minimum amount of pain using the excellent tools available in
7777
Clojure.</p><h2 id="parsing-nzb-files">Parsing NZB files</h2><p>For the purpose of the tutorial I have chosen a simple and fairly well
@@ -242,14 +242,14 @@ <h2>Parsing XML in Clojure</h2>
242242
<a href="https://clojure.github.io/clojure/clojure.java.io-api.html">clojure.java.io</a>
243243
docs for details.</p><p>Now let's fill in the <code>file-&gt;map</code> function:</p><pre><code class="clojure">(defn segment-&gt;map
244244
[seg]
245-
{:bytes (Long/valueOf (zip-xml/attr seg :bytes))
246-
:number (Integer/valueOf (zip-xml/attr seg :number))
245+
{:bytes (parse-long (zip-xml/attr seg :bytes))
246+
:number (parse-long (zip-xml/attr seg :number))
247247
:id (zip-xml/xml1-&gt; seg zip-xml/text)})
248248

249249
(defn file-&gt;map
250250
[file]
251251
{:poster (zip-xml/attr file :poster)
252-
:date (Long/valueOf (zip-xml/attr file :date))
252+
:date (parse-long (zip-xml/attr file :date))
253253
:subject (zip-xml/attr file :subject)
254254
:groups (vec (zip-xml/xml-&gt; file :groups :group zip-xml/text))
255255
:segments (mapv segment-&gt;map
@@ -338,11 +338,11 @@ <h2>Parsing XML in Clojure</h2>
338338
:file
339339
:segments
340340
:segment
341-
(attr-fn :number &gt; 75 #(Long/valueOf %))
341+
(attr-fn :number &gt; 75 parse-long)
342342
zip-xml/text)
343343
</code></pre><p>Let's provide a helper for this to make the syntax clearer:</p><pre><code class="clojure">(defn attr&gt;
344344
[attrname val]
345-
(attr-fn attrname &gt; val #(Long/valueOf %)))
345+
(attr-fn attrname &gt; val parse-long))
346346

347347
(zip-xml/xml-&gt; root
348348
:file

articles/language/interop/index.html

+6-3
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,10 @@ <h2>Language: Java Interop</h2>
116116
</code></pre><p>In Clojure 1.12, <code>SomeClass/new</code> is a "function value" and can be treated like
117117
a regular Clojure function:</p><pre><code class="clojure">(map (fn [f] (f "https://clojure.org")) [java.net.URI/new count clojure.string/upper-case])
118118
;;=&gt; (#object[java.net.URI 0x7ec25216 "https://clojure.org"] 19 "HTTPS://CLOJURE.ORG")
119-
</code></pre><h2 id="how-to-invoke-java-methods">How to Invoke Java Methods</h2><h3 id="instance-methods">Instance Methods</h3><p>Instance methods are invoked using the <code>.</code> special form:</p><pre><code class="clojure">(let [d (java.util.Date.)]
119+
</code></pre><h2 id="how-to-invoke-java-methods">How to Invoke Java Methods</h2><p>This guide does not cover type hints. See the official
120+
<a href="https://clojure.org/reference/java_interop#typehints">Java interop type hints</a>
121+
and <a href="https://clojure.org/reference/java_interop#paramtags">param-tags reference</a>
122+
documentation for more details (since this area changed significantly in Clojure 1.12).</p><h3 id="instance-methods">Instance Methods</h3><p>Instance methods are invoked using the <code>.</code> special form:</p><pre><code class="clojure">(let [d (java.util.Date.)]
120123
(. d getTime)) ; ⇒ 1349819873183
121124
</code></pre><p>Just like with object instantiation, it is much more common to see an alternative version:</p><pre><code class="clojure">(let [d (java.util.Date.)]
122125
(.getTime d)) ; ⇒ 1349819873183
@@ -132,7 +135,7 @@ <h2>Language: Java Interop</h2>
132135
</code></pre><p>In Clojure 1.12, <code>SomeClass/.methodName</code> is a "function value" and can be treated like
133136
a regular Clojure function:</p><pre><code class="clojure">(map Boolean/valueOf ["true" "false" "what?"])
134137
;;⇒ (true false false)
135-
</code></pre><h3 id="chained-calls-with-the-double-dot-form">Chained Calls With The Double Dot Form</h3><p>It is possible to chain method calls using the <code>..</code> special form:</p><pre><code class="clojure">(.. (java.util.Date.) getTime toString) ; ⇒ "1693344712616"
138+
</code></pre><blockquote><p>Note: Clojure 1.11 introduced <code>parse-boolean</code> but it is somewhat stricter than <code>Boolean/valueOf</code> and will return <code>nil</code> for strings it does not recognize, including <code>"TRUE"</code> and <code>"FALSE"</code> (which <code>Boolean/valueOf</code> does recognize).</p></blockquote><h3 id="chained-calls-with-the-double-dot-form">Chained Calls With The Double Dot Form</h3><p>It is possible to chain method calls using the <code>..</code> special form:</p><pre><code class="clojure">(.. (java.util.Date.) getTime toString) ; ⇒ "1693344712616"
136139
</code></pre><h3 id="multiple-calls-on-the-same-object">Multiple Calls On the Same Object</h3><p>If you need to call several methods on the same (mutable) object, you
137140
can use the <code>doto</code> macro:</p><pre><code class="clojure">(doto (java.util.Stack.)
138141
(.push 42)
@@ -203,7 +206,7 @@ <h2>Language: Java Interop</h2>
203206
;; but in earlier versions of Clojure:
204207
;;⇒ [Ljava.lang.String;
205208
</code></pre><p>In Clojure 1.12, you can <code>SomeClass/N</code> to get a class reference to an N-dimensional array of the class,
206-
but prior to 1.12, you had to use <code>Class/forName</code> and the internal name of the array type:</p><table class="table-striped table-bordered table"><thead><tr><th>Internal JVM class name</th><th>Array of ? (type)</th><th>Clojure 1.12 type</th></tr></thead><tbody><tr><td><pre>"[S"</pre></td><td>short</td><td>short/1</td></tr><tr><td><pre>"[I"</pre></td><td>integer</td><td>integer/1</td></tr><tr><td><pre>"[J"</pre></td><td>long</td><td>long/1</td></tr><tr><td><pre>"[F"</pre></td><td>float</td><td>float/1</td></tr><tr><td><pre>"[D"</pre></td><td>double</td><td>double/1</td></tr><tr><td><pre>"[B"</pre></td><td>byte</td><td>byte/1</td></tr><tr><td><pre>"[C"</pre></td><td>char</td><td>char/1</td></tr><tr><td><pre>"[Z"</pre></td><td>boolean/1</td></tr></tbody></table><p>For convenience, Clojure has <code>*-array</code> functions for each of the above
209+
but prior to 1.12, you had to use <code>Class/forName</code> and the internal name of the array type:</p><table class="table-striped table-bordered table"><thead><tr><th>Internal JVM class name</th><th>Array of ? (type)</th><th>Clojure 1.12 type</th></tr></thead><tbody><tr><td><pre>"[S"</pre></td><td>short</td><td>short/1</td></tr><tr><td><pre>"[I"</pre></td><td>integer</td><td>integer/1</td></tr><tr><td><pre>"[J"</pre></td><td>long</td><td>long/1</td></tr><tr><td><pre>"[F"</pre></td><td>float</td><td>float/1</td></tr><tr><td><pre>"[D"</pre></td><td>double</td><td>double/1</td></tr><tr><td><pre>"[B"</pre></td><td>byte</td><td>byte/1</td></tr><tr><td><pre>"[C"</pre></td><td>char</td><td>char/1</td></tr><tr><td><pre>"[Z"</pre></td><td>boolean</td><td>boolean/1</td></tr></tbody></table><p>For convenience, Clojure has <code>*-array</code> functions for each of the above
207210
types that help you create an array of primitive values:</p><pre><code class="clojure">user=&gt; (char-array [\h \e \l \l \o])
208211
#object["[C" 0x7df60067 "[C@7df60067"]
209212
user=&gt; (apply str *1)

cryogen.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><atom:link href="https://clojure-doc.org/" rel="self" type="application/rss+xml"/><title>Clojure Guides</title><link>https://clojure-doc.org/</link><description>Clojure Documentation</description><lastBuildDate>Mon, 30 Dec 2024 18:34:49 -0800</lastBuildDate><generator>clj-rss</generator></channel></rss>
1+
<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><atom:link href="https://clojure-doc.org/" rel="self" type="application/rss+xml"/><title>Clojure Guides</title><link>https://clojure-doc.org/</link><description>Clojure Documentation</description><lastBuildDate>Tue, 31 Dec 2024 10:59:40 -0800</lastBuildDate><generator>clj-rss</generator></channel></rss>

feed.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><atom:link href="https://clojure-doc.org/" rel="self" type="application/rss+xml"/><title>Clojure Guides</title><link>https://clojure-doc.org/</link><description>Clojure Documentation</description><lastBuildDate>Mon, 30 Dec 2024 18:34:49 -0800</lastBuildDate><generator>clj-rss</generator></channel></rss>
1+
<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><atom:link href="https://clojure-doc.org/" rel="self" type="application/rss+xml"/><title>Clojure Guides</title><link>https://clojure-doc.org/</link><description>Clojure Documentation</description><lastBuildDate>Tue, 31 Dec 2024 10:59:40 -0800</lastBuildDate><generator>clj-rss</generator></channel></rss>

0 commit comments

Comments
 (0)