<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>The Coffee Machine</title>
	<atom:link href="http://thecoffeemachine.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://thecoffeemachine.wordpress.com</link>
	<description>Java &#38; Eclipse tips blog</description>
	<lastBuildDate>Sun, 27 Mar 2011 15:16:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='thecoffeemachine.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>The Coffee Machine</title>
		<link>http://thecoffeemachine.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://thecoffeemachine.wordpress.com/osd.xml" title="The Coffee Machine" />
	<atom:link rel='hub' href='http://thecoffeemachine.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Sort a list of elements with the Comparable interface</title>
		<link>http://thecoffeemachine.wordpress.com/2008/09/11/sort-a-list-of-elements-with-the-comparable-interface/</link>
		<comments>http://thecoffeemachine.wordpress.com/2008/09/11/sort-a-list-of-elements-with-the-comparable-interface/#comments</comments>
		<pubDate>Thu, 11 Sep 2008 08:00:29 +0000</pubDate>
		<dc:creator>ObLiB</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[ascending]]></category>
		<category><![CDATA[Collections]]></category>
		<category><![CDATA[Comparable]]></category>
		<category><![CDATA[compareTo]]></category>
		<category><![CDATA[descending]]></category>
		<category><![CDATA[List]]></category>
		<category><![CDATA[order]]></category>
		<category><![CDATA[sort]]></category>

		<guid isPermaLink="false">http://thecoffeemachine.wordpress.com/?p=446</guid>
		<description><![CDATA[Sometimes you’ve got to sort a list. Instead of doing our own sort method, you can use the Collections.sort(List list) method. To be sorted, your list elements must be “Comparable” (Like int, String, Date etc…). To do this, the only things to do are to implements the Comparable interface and define the public int compareTo(Object [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecoffeemachine.wordpress.com&amp;blog=4432299&amp;post=446&amp;subd=thecoffeemachine&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;"><img style="border:none;float:right;margin:0 0 0 8px;padding:0;" src="http://thecoffeemachine.files.wordpress.com/2008/08/java_icon_48x32.gif?w=48&#038;h=32" alt="Java" width="48" height="32" />Sometimes you’ve got to sort a list. Instead of doing our own sort method, you can use the <a href="http://java.sun.com/javase/6/docs/api/java/util/Collections.html">Collections.<em>sort</em>(List list)</a> method. To be sorted, your list elements must be “<a href="http://java.sun.com/javase/6/docs/api/java/lang/Comparable.html">Comparable</a>” (Like <em>int</em>, <em>String</em>, <em>Date</em> etc…). To do this, the only things to do are to implements the <a href="http://java.sun.com/javase/6/docs/api/java/lang/Comparable.html">Comparable</a> interface and define the <a href="http://java.sun.com/javase/6/docs/api/java/lang/Comparable.html">public int compareTo(Object object)</a> method in your element class.</p>
<p><span id="more-446"></span></p>
<p style="text-align:justify;">Let’s practice a while to see how it works. We will define a house with a surface and its construction’s year:</p>
<p style="border:1px solid #b0b0b0;background-color:#e8e9ea;font-size:10pt;font-family:'Courier New';padding:10px;"><span style="color:#7f0085;font-weight:bold;">public class</span> House <span style="color:#7f0085;font-weight:bold;">implements</span> Comparable&lt;House&gt; {<br />
<span style="color:#7f0085;font-weight:bold;padding-left:40px;">private int</span> <span style="color:#0000c0;">sqFt</span>;<br />
<span style="color:#7f0085;font-weight:bold;padding-left:40px;">private int</span> <span style="color:#0000c0;">constructionYear</span>;<br />
<br />
<span style="color:#7f0085;font-weight:bold;padding-left:40px;">public int</span> getSqFt() {<br />
<span style="color:#7f0085;font-weight:bold;padding-left:80px;">return</span> <span style="color:#0000c0;">sqFt</span>;<br />
<span style="padding-left:40px;">}</span><br />
<span style="color:#7f0085;font-weight:bold;padding-left:40px;">public void</span> setSqFt(<span>int</span> sqFt) {<br />
<span style="color:#7f0085;font-weight:bold;padding-left:80px;">this</span>.<span style="color:#0000c0;">sqFt</span> = sqFt;<br />
<span style="padding-left:40px;">}</span><br />
<br />
<span style="color:#7f0085;font-weight:bold;padding-left:40px;">public int</span> getContructionYear() {<br />
<span style="color:#7f0085;font-weight:bold;padding-left:80px;">return</span> <span style="color:#0000c0;">constructionYear</span>;<br />
<span style="padding-left:40px;">}</span><br />
<span style="color:#7f0085;font-weight:bold;padding-left:40px;">public void</span> setContructionYear(<span>int</span> constructionYear) {<br />
<span style="color:#7f0085;font-weight:bold;padding-left:80px;">this</span>.<span style="color:#0000c0;">constructionYear</span> = constructionYear;<br />
<span style="padding-left:40px;">}</span><br />
<br />
<span style="color:#7f0085;font-weight:bold;padding-left:40px;">public</span> House(<span>int</span> sqFt, <span>int</span> contructionYear) {<br />
<span style="padding-left:80px;">setSqFt(sqFt);</span><br />
<span style="padding-left:80px;">setContructionYear(contructionYear);</span><br />
<span style="padding-left:40px;">}</span><br />
<br />
<span style="color:#7f0085;font-weight:bold;padding-left:40px;">public int</span> compareTo(House house) {<br />
<span style="color:#7f0085;font-weight:bold;padding-left:80px;">final int</span> BEFORE = -1;<br />
<span style="color:#7f0085;font-weight:bold;padding-left:80px;">final int</span> EQUAL = 0;<br />
<span style="color:#7f0085;font-weight:bold;padding-left:80px;">final int</span> AFTER = 1;<br />
<br />
<span style="color:#7f0085;font-weight:bold;padding-left:80px;">if</span>(<span style="color:#7f0085;font-weight:bold;">this</span> == house) <span style="color:#7f0085;font-weight:bold;">return</span> EQUAL;<br />
<br />
<span style="color:#3f7f5f;padding-left:80px;">// bigger if surface is bigger</span><br />
<span style="color:#7f0085;font-weight:bold;padding-left:80px;">if</span>(getSqFt() &lt; house.getSqFt()) <span style="color:#7f0085;font-weight:bold;">return</span> BEFORE;<br />
<span style="color:#7f0085;font-weight:bold;padding-left:80px;">if</span>(getSqFt() &gt; house.getSqFt()) <span style="color:#7f0085;font-weight:bold;">return</span> AFTER;<br />
<br />
<span style="color:#3f7f5f;padding-left:80px;">// bigger if newer</span><br />
<span style="color:#7f0085;font-weight:bold;padding-left:80px;">if</span>(getContructionYear() &lt; house.getContructionYear()) <span style="color:#7f0085;font-weight:bold;">return</span> BEFORE;<br />
<span style="color:#7f0085;font-weight:bold;padding-left:80px;">if</span>(getContructionYear() &gt; house.getContructionYear()) <span style="color:#7f0085;font-weight:bold;">return</span> AFTER;<br />
<br />
<span style="color:#3f7f5f;padding-left:80px;">// else equal</span><br />
<span style="color:#7f0085;font-weight:bold;padding-left:80px;">return</span> EQUAL;<br />
<span style="padding-left:40px;">}</span><br />
<br />
<span style="color:#7f0085;font-weight:bold;padding-left:40px;">public</span> String toString() {<br />
<span style="color:#7f0085;font-weight:bold;padding-left:80px;">return</span> getSqFt()+<span style="color:#2a00ff;">&quot; sq ft, build in &quot;</span>+getContructionYear();<br />
<span style="padding-left:40px;">}</span><br />
}</p>
<p style="text-align:justify;">Our House class implements the <a href="http://java.sun.com/javase/6/docs/api/java/lang/Comparable.html">Comparable&lt;T&gt;</a> interface where <strong>T</strong> defines the type of Object which the House will be compare to. In our example we&#8217;ll compare a House to another, so it’s <strong>Comparable&lt;<em>House</em>&gt;</strong>.</p>
<p style="text-align:justify;">Next we have defined the <em><strong>compareTo(&lt;T&gt; object)</strong></em> <a href="http://java.sun.com/javase/6/docs/api/java/lang/Comparable.html">Comparable</a> method. This method will be used to sort our houses. We decide to order them in this way:</p>
<ul>
<li>by surface (if house A is smaller than house B, house A is less than house B)</li>
<li>by construction year (if two houses have the same surface, the newest is the biggest)</li>
</ul>
<p style="text-align:justify;">Now, we will define a list of houses and try to sort them in ascending order and in descending order:</p>
<p style="border:1px solid #b0b0b0;background-color:#e8e9ea;font-size:10pt;font-family:'Courier New';padding:10px;"><span style="color:#7f0085;font-weight:bold;">import</span> java.util.ArrayList;<br />
<span style="color:#7f0085;font-weight:bold;">import</span> java.util.Collections;<br />
<span style="color:#7f0085;font-weight:bold;">import</span> java.util.List;<br />
<br />
<span style="color:#7f0085;font-weight:bold;">public class</span> Test {<br />
<span style="color:#7f0085;font-weight:bold;padding-left:40px;">public static void</span> showHouseList(List&lt;House&gt; houseList) {<br />
<span style="color:#7f0085;font-weight:bold;padding-left:80px;">for</span>(House house : houseList)<br />
<span style="padding-left:80px;">System.</span><span style="color:#0000c0;font-style:italic;">out</span>.println(house);<br />
<span style="padding-left:40px;">}</span><br />
<br />
<span style="color:#7f0085;font-weight:bold;padding-left:40px;">public static void</span> main(String[] args) {<br />
<span style="padding-left:80px;">List&lt;House&gt; houseList = </span><span style="color:#7f0085;font-weight:bold;">new</span> ArrayList&lt;House&gt;();<br />
<br />
<span style="padding-left:80px;">houseList.add(</span><span style="color:#7f0085;font-weight:bold;">new</span> House(2000, 1976));<br />
<span style="padding-left:80px;">houseList.add(</span><span style="color:#7f0085;font-weight:bold;">new</span> House(20000, 1999));<br />
<span style="padding-left:80px;">houseList.add(</span><span style="color:#7f0085;font-weight:bold;">new</span> House(5000, 1990));<br />
<span style="padding-left:80px;">houseList.add(</span><span style="color:#7f0085;font-weight:bold;">new</span> House(2900, 1982));<br />
<span style="padding-left:80px;">houseList.add(</span><span style="color:#7f0085;font-weight:bold;">new</span> House(20000, 1998));<br />
<span style="padding-left:80px;">houseList.add(</span><span style="color:#7f0085;font-weight:bold;">new</span> House(10000, 1979));<br />
<span style="padding-left:80px;">houseList.add(</span><span style="color:#7f0085;font-weight:bold;">new</span> House(10000, 2005));<br />
<span style="padding-left:80px;">houseList.add(</span><span style="color:#7f0085;font-weight:bold;">new</span> House(15000, 1995));<br />
<span style="padding-left:80px;">houseList.add(</span><span style="color:#7f0085;font-weight:bold;">new</span> House(3000, 1980));<br />
<span style="padding-left:80px;">houseList.add(</span><span style="color:#7f0085;font-weight:bold;">new</span> House(5000, 1999));<br />
<span style="padding-left:80px;">houseList.add(</span><span style="color:#7f0085;font-weight:bold;">new</span> House(6000, 1968));<br />
<br />
<span style="padding-left:80px;">System.</span><span style="color:#0000c0;font-style:italic;">out</span>.println(<span style="color:#2a00ff;">&quot;- Mixing the list.<span>..</span>&quot;</span>);<br />
<span style="color:#3f7f5f;padding-left:80px;">// Mixing the house list</span><br />
<span style="padding-left:80px;">Collections.</span><em>shuffle</em>(houseList);<br />
<span style="color:#3f7f5f;padding-left:80px;">// Checking the state of our list</span><br />
<span style="padding-left:80px;"><em>showHouseList</em>(houseList);</span><br />
<br />
<span style="padding-left:80px;">System.</span><span style="color:#0000c0;font-style:italic;">out</span>.println(<span style="color:#2a00ff;">&quot;\n- After sorting in ascending order.<span>..</span>&quot;</span>);<br />
<span style="color:#3f7f5f;padding-left:80px;">// Sorting our house in ascending order</span><br />
<span style="padding-left:80px;">Collections.</span><em>sort</em>(houseList);<br />
<span style="color:#3f7f5f;padding-left:80px;">// Checking that the sort action works</span><br />
<span style="padding-left:80px;"><em>showHouseList</em>(houseList);</span><br />
<br />
<span style="padding-left:80px;">System.</span><span style="color:#0000c0;font-style:italic;">out</span>.println(<span style="color:#2a00ff;">&quot;\n- Re mixing the list.<span>..</span>&quot;</span>);<br />
<span style="color:#3f7f5f;padding-left:80px;">// Re-Mixing the house list</span><br />
<span style="padding-left:80px;">Collections.</span><em>shuffle</em>(houseList);<br />
<span style="color:#3f7f5f;padding-left:80px;">// Checking the state of our list</span><br />
<span style="padding-left:80px;"><em>showHouseList</em>(houseList);</span><br />
<br />
<span style="padding-left:80px;">System.</span><span style="color:#0000c0;font-style:italic;">out</span>.println(<span style="color:#2a00ff;">&quot;\n- After sorting in descending order.<span>..</span>&quot;</span>);<br />
<span style="color:#3f7f5f;padding-left:80px;">// Sorting our house in descending order</span><br />
<span style="padding-left:80px;">Collections.</span><em>sort</em>(houseList, Collections.<em>reverseOrder</em>());<br />
<span style="color:#3f7f5f;padding-left:80px;">// Checking that the sort action works</span><br />
<span style="padding-left:80px;"><em>showHouseList</em>(houseList);</span><br />
<span style="padding-left:40px;">}</span><br />
}</p>
<p style="text-align:justify;">Here is the output:</p>
<p style="border:1px solid black;background-color:#ffffff;font-size:10pt;font-family:'Courier New';padding:10px;">
- Mixing the list.<span>..</span><br />
15000 sq ft, build in 1995<br />
2900 sq ft, build in 1982<br />
5000 sq ft, build in 1999<br />
6000 sq ft, build in 1968<br />
10000 sq ft, build in 2005<br />
10000 sq ft, build in 1979<br />
20000 sq ft, build in 1999<br />
2000 sq ft, build in 1976<br />
20000 sq ft, build in 1998<br />
5000 sq ft, build in 1990<br />
3000 sq ft, build in 1980<br />
<br />
- After sorting in ascending order.<span>..</span><br />
2000 sq ft, build in 1976<br />
2900 sq ft, build in 1982<br />
3000 sq ft, build in 1980<br />
5000 sq ft, build in 1990<br />
5000 sq ft, build in 1999<br />
6000 sq ft, build in 1968<br />
10000 sq ft, build in 1979<br />
10000 sq ft, build in 2005<br />
15000 sq ft, build in 1995<br />
20000 sq ft, build in 1998<br />
20000 sq ft, build in 1999<br />
<br />
- Re mixing the list.<span>..</span><br />
3000 sq ft, build in 1980<br />
15000 sq ft, build in 1995<br />
10000 sq ft, build in 2005<br />
5000 sq ft, build in 1990<br />
2900 sq ft, build in 1982<br />
2000 sq ft, build in 1976<br />
20000 sq ft, build in 1998<br />
10000 sq ft, build in 1979<br />
6000 sq ft, build in 1968</p>
<p>5000 sq ft, build in 1999<br />
20000 sq ft, build in 1999<br />
<br />
- After sorting in descending order.<span>..</span><br />
20000 sq ft, build in 1999<br />
20000 sq ft, build in 1998<br />
15000 sq ft, build in 1995<br />
10000 sq ft, build in 2005<br />
10000 sq ft, build in 1979<br />
6000 sq ft, build in 1968<br />
5000 sq ft, build in 1999<br />
5000 sq ft, build in 1990<br />
3000 sq ft, build in 1980<br />
2900 sq ft, build in 1982<br />
2000 sq ft, build in 1976</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/thecoffeemachine.wordpress.com/446/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/thecoffeemachine.wordpress.com/446/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecoffeemachine.wordpress.com/446/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecoffeemachine.wordpress.com/446/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecoffeemachine.wordpress.com/446/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecoffeemachine.wordpress.com/446/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thecoffeemachine.wordpress.com/446/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thecoffeemachine.wordpress.com/446/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thecoffeemachine.wordpress.com/446/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thecoffeemachine.wordpress.com/446/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecoffeemachine.wordpress.com/446/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecoffeemachine.wordpress.com/446/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecoffeemachine.wordpress.com/446/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecoffeemachine.wordpress.com/446/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecoffeemachine.wordpress.com/446/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecoffeemachine.wordpress.com/446/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecoffeemachine.wordpress.com&amp;blog=4432299&amp;post=446&amp;subd=thecoffeemachine&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thecoffeemachine.wordpress.com/2008/09/11/sort-a-list-of-elements-with-the-comparable-interface/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e4336f1b0407e42867480795df950a6c?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">ObLiB</media:title>
		</media:content>

		<media:content url="http://thecoffeemachine.files.wordpress.com/2008/08/java_icon_48x32.gif" medium="image">
			<media:title type="html">Java</media:title>
		</media:content>
	</item>
		<item>
		<title>Eclipse 3.4 Ganymede on Ubuntu 8.04 Hardy Heron</title>
		<link>http://thecoffeemachine.wordpress.com/2008/09/09/eclipse-34-ganymede-on-ubuntu-804-hardy-heron/</link>
		<comments>http://thecoffeemachine.wordpress.com/2008/09/09/eclipse-34-ganymede-on-ubuntu-804-hardy-heron/#comments</comments>
		<pubDate>Tue, 09 Sep 2008 08:52:28 +0000</pubDate>
		<dc:creator>ObLiB</dc:creator>
				<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Ganymede]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[depots]]></category>
		<category><![CDATA[hardy]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[package]]></category>

		<guid isPermaLink="false">http://thecoffeemachine.wordpress.com/?p=375</guid>
		<description><![CDATA[Ubuntu Hardy Heron does not have Eclipse 3.4 Ganymede in its deposits. Indeed the Aptitude eclipse installation will install Eclipse 3.2 on your system. To install Eclipse Ganymede, it must be done manually. Java installation By default, Ubuntu comes with a free Java interpreter: gij, so if you want to use the Sun Microsystems Java™ [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecoffeemachine.wordpress.com&amp;blog=4432299&amp;post=375&amp;subd=thecoffeemachine&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;"><img style="border:none;float:right;margin:0 0 0 8px;padding:0;" src="http://thecoffeemachine.files.wordpress.com/2008/09/ubuntu_48x32.png?w=48&#038;h=32" alt="Ubuntu" width="48" height="32" /><a href="http://releases.ubuntu.com/8.04/">Ubuntu Hardy Heron</a> does not have <a href="http://www.eclipse.org">Eclipse 3.4 Ganymede</a> in its deposits. Indeed the <a href="http://packages.ubuntu.com/fr/hardy/eclipse">Aptitude eclipse installation</a> will install <a href="http://www.eclipse.org">Eclipse 3.2</a> on your system.</p>
<p style="text-align:justify;">To install <a href="http://www.eclipse.org">Eclipse Ganymede</a>, it must be done manually.</p>
<p><span id="more-375"></span></p>
<h1 style="padding-top:15px;font-family:Verdana,Tahoma,Arial,sans-serif;font-size:12pt;font-weight:normal;"><img style="border:none;margin:0;padding:0 2px 0 0;" src="http://thecoffeemachine.files.wordpress.com/2008/09/java_22x19.png?w=22&#038;h=19" alt="Java" width="22" height="19" />Java installation</h1>
<p style="text-align:justify;">By default, <a href="http://www.ubuntu.com/">Ubuntu</a> comes with a free Java interpreter: <a href="http://en.wikipedia.org/wiki/GNU_Interpreter_for_Java">gij</a>, so if you want to use the <a href="http://sun.com">Sun Microsystems</a> <a href="http://java.sun.com/javase/downloads/index.jsp">Java™ Development Kit</a> (<a href="http://java.sun.com/javase/downloads/index.jsp">JDK</a>), you will need to install it.</p>
<p style="text-align:justify;"><a href="http://java.sun.com/">Java</a> is available in the depots. You have a choice between two versions: <a href="http://java.sun.com/javase/downloads/index_jdk5.jsp">Java5</a> and <a href="http://java.sun.com/javase/6/">Java6</a>.</p>
<ul>
<li><a href="http://java.sun.com/javase/downloads/index_jdk5.jsp">Java5</a> is available in <span style="text-decoration:underline;">multiverse</span> deposits for all versions of <a href="http://www.ubuntu.com">Ubuntu</a> currently supported.</li>
<li><a href="http://java.sun.com/javase/6/">Java6</a> is available in <span style="text-decoration:underline;">multiverse</span> deposits since <a href="http://releases.ubuntu.com/7.04/">Feisty</a>. For <a href="http://releases.ubuntu.com/6.10/">Edgy</a> and <a href="http://releases.ubuntu.com/6.06/">Dapper</a> you’ve gor to check the <span style="text-decoration:underline;">backports multiverse</span> deposits.</li>
</ul>
<p style="text-align:justify;">You can install the following packages according to your needs:</p>
<ul>
<li><a href="http://packages.ubuntu.com/fr/hardy/sun-java6-bin">sun-java6-bin</a>: Sun Java™ Runtime Environment (JRE) 6 (depending on the architecture)</li>
<li><a href="http://packages.ubuntu.com/fr/hardy/sun-java6-demo">sun-java6-demo</a>: Sun Java™ Development Kit (JDK) 6 (demos and examples)</li>
<li><a href="http://packages.ubuntu.com/fr/hardy/sun-java6-doc">sun-java6-doc</a>: JDK™ Documentation – integration installer</li>
<li><a href="http://packages.ubuntu.com/fr/hardy/sun-java6-fonts">sun-java6-fonts</a>: Lucida TrueType fonts.</li>
<li><a href="http://packages.ubuntu.com/fr/hardy/sun-java6-javadb">sun-java6-javadb</a>: Java™ DB, Apache Derby by Sun Microsystems</li>
<li><a href="http://packages.ubuntu.com/fr/hardy/sun-java6-jdk">sun-java6-jdk</a>: Java™ Development Kit (JDK) 6</li>
<li><a href="http://packages.ubuntu.com/fr/hardy/sun-java6-jre">sun-java6-jre</a>: Java™ Runtime Environment (JRE) 6 (independent from the architecture)</li>
<li><a href="http://packages.ubuntu.com/fr/hardy/sun-java6-plugin">sun-java6-plugin</a>: Web navigator Java™ Plugin.</li>
<li><a href="http://packages.ubuntu.com/fr/hardy/sun-java6-source">sun-java6-source</a>: JDK™ sources.</li>
</ul>
<p style="text-align:justify;">The above list is the list of available packages for <a href="http://java.sun.com/javase/6/">Java6</a>. For the <a href="http://java.sun.com/javase/downloads/index_jdk5.jsp">Java5</a> packages list, simply replace <em>&quot;java6&quot;</em> by <em>&quot;java5&quot;</em>.</p>
<p style="text-align:justify;">For example to install the <a href="http://java.sun.com/javase/6/">Java6</a> JRE execute the following commands:</p>
<p style="border:1px solid #b0b0b0;background-color:black;color:#ccc;font-weight:bold;font-family:monospace,'Courier New';font-size:10pt;margin:5px 15px 15px;padding:5px 10px;">sudo apt-get install sun-java6-jre sun-java6-plugin sun-java6-fonts</p>
<h1 style="padding-top:15px;font-family:Verdana,Tahoma,Arial,sans-serif;font-size:12pt;font-weight:normal;"><img style="border:none;margin:0;padding:0 5px 0 0;" src="http://thecoffeemachine.files.wordpress.com/2008/09/eclipse_20x20.png?w=20&#038;h=20" alt="Eclipse" width="20" height="20" />Eclipse 3.4 Ganymede installation</h1>
<p style="text-align:justify;">Download the version that suits you on the <a href="http://www.eclipse.org/downloads/">official website</a>.</p>
<p style="text-align:justify;">For example <strong>Eclipse IDE for Java Developers</strong> (<em>eclipse-java-ganymede-linux-gtk.tar.gz</em>):</p>
<p style="border:1px solid #b0b0b0;background-color:black;color:#ccc;font-weight:bold;font-family:monospace,'Courier New';font-size:10pt;margin:5px 15px 15px;padding:5px 10px;">wget http://download.eclipse.org/technology/epp/downloads/release/ganymede/R/eclipse-java-ganymede-linux-gtk.tar.gz<br />
tar xzvf eclipse-java-ganymede-linux-gtk.tar.gz<br />
mv eclipse eclipse3.4</p>
<p>You should be ready to launch</p>
<p style="border:1px solid #b0b0b0;background-color:black;color:#ccc;font-weight:bold;font-family:monospace,'Courier New';font-size:10pt;margin:5px 15px 15px;padding:5px 10px;">eclipse3.4/eclipse</p>
<p>Wait for your <a href="http://www.eclipse.org">eclipse 3.4 Ganymede</a> to start, and go to <em>Windows</em> -&gt; <em>Preferences</em>. Find <em>Java</em> -&gt; <em>Installed JREs</em>. You should see the list of the JREs known by eclipse. If the <a href="http://sun.com">Sun Microsystems</a> JREs doesn&#8217;t appear, you&#8217;ll have to show it to <a href="http://www.eclipse.org">eclipse</a>. To do this, Click the &#8220;<strong>Search</strong>&#8221; button and select the <strong>/usr/lib/jvm/</strong> path. Eclipse should find JREs intalled on your system and list them. Just select the one that you want to use, and you&#8217;re ready to program on your nice new <a href="http://www.eclipse.org">Eclipse 3.4 Ganymede</a> <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  </p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/thecoffeemachine.wordpress.com/375/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/thecoffeemachine.wordpress.com/375/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecoffeemachine.wordpress.com/375/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecoffeemachine.wordpress.com/375/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecoffeemachine.wordpress.com/375/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecoffeemachine.wordpress.com/375/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thecoffeemachine.wordpress.com/375/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thecoffeemachine.wordpress.com/375/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thecoffeemachine.wordpress.com/375/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thecoffeemachine.wordpress.com/375/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecoffeemachine.wordpress.com/375/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecoffeemachine.wordpress.com/375/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecoffeemachine.wordpress.com/375/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecoffeemachine.wordpress.com/375/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecoffeemachine.wordpress.com/375/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecoffeemachine.wordpress.com/375/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecoffeemachine.wordpress.com&amp;blog=4432299&amp;post=375&amp;subd=thecoffeemachine&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thecoffeemachine.wordpress.com/2008/09/09/eclipse-34-ganymede-on-ubuntu-804-hardy-heron/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e4336f1b0407e42867480795df950a6c?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">ObLiB</media:title>
		</media:content>

		<media:content url="http://thecoffeemachine.files.wordpress.com/2008/09/ubuntu_48x32.png" medium="image">
			<media:title type="html">Ubuntu</media:title>
		</media:content>

		<media:content url="http://thecoffeemachine.files.wordpress.com/2008/09/java_22x19.png" medium="image">
			<media:title type="html">Java</media:title>
		</media:content>

		<media:content url="http://thecoffeemachine.files.wordpress.com/2008/09/eclipse_20x20.png" medium="image">
			<media:title type="html">Eclipse</media:title>
		</media:content>
	</item>
		<item>
		<title>1,000 hits !</title>
		<link>http://thecoffeemachine.wordpress.com/2008/09/03/1000-hits/</link>
		<comments>http://thecoffeemachine.wordpress.com/2008/09/03/1000-hits/#comments</comments>
		<pubDate>Wed, 03 Sep 2008 16:18:06 +0000</pubDate>
		<dc:creator>ObLiB</dc:creator>
				<category><![CDATA[The Coffee Machine]]></category>
		<category><![CDATA[1000th]]></category>

		<guid isPermaLink="false">http://thecoffeemachine.wordpress.com/?p=345</guid>
		<description><![CDATA[Hi everyone, The symbolic 1,000th hit was achieved today! I&#8217;m happy to see that so much people visit my blog See you!<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecoffeemachine.wordpress.com&amp;blog=4432299&amp;post=345&amp;subd=thecoffeemachine&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div style="border:2px solid #6c0c91;background-color:#e2c9e9;color:#6c0c91;font-weight:bold;text-align:justify;-moz-border-radius:8px;margin:0 15px;"><img style="border:none;display:inline;float:right;margin:3px 0 0 8px;padding:0;" src="http://thecoffeemachine.files.wordpress.com/2008/09/thecoffeemachine_48x32.png?w=48&#038;h=32" alt="The Coffee Machine" width="48" height="32" />
<p style="text-align:justify;margin:15px;padding:0;">Hi everyone,<br />
<br />The symbolic 1,000th hit was achieved today!<br />
I&#8217;m happy to see that so much people visit my blog <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /><br />
<br />See you! <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
</div>
<p></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/thecoffeemachine.wordpress.com/345/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/thecoffeemachine.wordpress.com/345/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecoffeemachine.wordpress.com/345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecoffeemachine.wordpress.com/345/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecoffeemachine.wordpress.com/345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecoffeemachine.wordpress.com/345/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thecoffeemachine.wordpress.com/345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thecoffeemachine.wordpress.com/345/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thecoffeemachine.wordpress.com/345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thecoffeemachine.wordpress.com/345/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecoffeemachine.wordpress.com/345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecoffeemachine.wordpress.com/345/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecoffeemachine.wordpress.com/345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecoffeemachine.wordpress.com/345/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecoffeemachine.wordpress.com/345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecoffeemachine.wordpress.com/345/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecoffeemachine.wordpress.com&amp;blog=4432299&amp;post=345&amp;subd=thecoffeemachine&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thecoffeemachine.wordpress.com/2008/09/03/1000-hits/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e4336f1b0407e42867480795df950a6c?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">ObLiB</media:title>
		</media:content>

		<media:content url="http://thecoffeemachine.files.wordpress.com/2008/09/thecoffeemachine_48x32.png" medium="image">
			<media:title type="html">The Coffee Machine</media:title>
		</media:content>
	</item>
		<item>
		<title>XML with Java and JDOM</title>
		<link>http://thecoffeemachine.wordpress.com/2008/08/29/xml-with-java-and-jdom/</link>
		<comments>http://thecoffeemachine.wordpress.com/2008/08/29/xml-with-java-and-jdom/#comments</comments>
		<pubDate>Fri, 29 Aug 2008 13:28:16 +0000</pubDate>
		<dc:creator>ObLiB</dc:creator>
				<category><![CDATA[API]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[jdom]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://thecoffeemachine.wordpress.com/?p=133</guid>
		<description><![CDATA[A few months ago, I worked on a java project which had to manage XML data. The XML data that I had to deal with weren’t very complex so I try to find the easiest way to manage XML data with Java and I found JDOM. We want to provide a solution for using XML [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecoffeemachine.wordpress.com&amp;blog=4432299&amp;post=133&amp;subd=thecoffeemachine&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;"><img style="border:none;float:right;margin:0 0 0 8px;padding:0;" src="http://thecoffeemachine.files.wordpress.com/2008/08/java_icon_48x32.gif?w=48&#038;h=32" alt="Java" width="48" height="32" />A few months ago, I worked on a java project which had to manage XML data. The XML data that I had to deal with weren’t very complex so I try to find the easiest way to manage XML data with Java and I found <a href="http://jdom.org/">JDOM</a>.</p>
<div style="background-color:#ebdcef;background-image:url(http://thecoffeemachine.files.wordpress.com/2008/08/quote18x16.png);background-position:10px 10px;background-repeat:no-repeat;-moz-border-radius:8px;margin:0 10px;padding:15px 15px 0 38px;">
<p style="text-align:justify;color:#77238f;font-family:Arial;font-size:10pt;"><strong>We want to provide a solution for using XML from Java that is as simple as Java itself. </strong><br />
There is no compelling reason for a Java API to manipulate XML to be complex, tricky, unintuitive, or a pain in the neck. JDOMTM is both Java-centric and Java-optimized. It behaves like Java, it uses Java collections, it is completely natural API for current Java developers, and it provides a low-cost entry point for using XML.<br />
While JDOM interoperates well with existing standards such as the Simple API for XML (SAX) and the Document Object Model (DOM), it is not an abstraction layer or enhancement to those APIs. Rather, it provides a robust, light-weight means of reading and writing XML data without the complex and memory-consumptive options that current API offerings provide.</p>
<p style="text-align:right;padding:0 20px 10px 0;"><a href="http://jdom.org"><em><span style="color:#807882;font-family:Arial;font-size:10pt;font-weight:bolder;">The JDOM team</span></em></a></p>
</div>
<p><span id="more-133"></span></p>
<p style="text-align:justify;"><a href="http://jdom.org">JDOM</a> is a Java API developed regardless of <a href="http://www.sun.com">Sun Microsystems</a>. It can handle XML data more simply than with conventional API. Its use is convenient for any Java developer and is based on <a href="https://jaxp.dev.java.net/">Sun’s XML API</a>.</p>
<p style="text-align:justify;">Let’s show you an example to see how it works.<span>..</span></p>
<p style="text-align:justify;">First of all you need to download and install <a href="http://jdom.org">JDOM</a>. Go to <a href="http://www.jdom.org/dist/binary/">http://www.jdom.org/dist/binary/</a> and download <strong>jdom-1.1</strong>. Then unzip it and make the <span style="background-color:#ebdcef;color:#77238f;">build/jdom.jar</span> file accessible trought to the classpath (if you are under Eclipse you simply have to configure the build path of your project with “Add External Archives.<span>..</span>&#8221; and select <span style="background-color:#ebdcef;color:#77238f;">jdom.jar</span>).</p>
<p style="text-align:justify;">Now we are ready to use <a href="http://jdom.org">JDOM</a>. We will create a XML file from scratch. You just have to build your XML tree by adding elements one to the other. A node is a <a href="http://www.jdom.org/docs/apidocs/org/jdom/Element.html">org.jdom.Element</a> instance.<br />
Let’s create a <strong>JDOMDVD</strong> class which will create the following XML tree:</p>
<p style="border:1px solid #909090;background-color:#fff;font-family:'Courier New';font-size:10pt;padding:10px;"><span style="color:#3f7f7f;">&lt;dvd_collection&gt;</span><br />
<span style="color:#3f7f7f;padding-left:30px;">&lt;dvd_list</span> <span style="color:#7f007f;">genre</span>=<span style="color:#2a00ff;font-style:italic;">&quot;action&quot;</span><span style="color:#3f7f7f;">&gt;</span><br />
<span style="color:#3f7f7f;padding-left:60px;">&lt;dvd&gt;</span><br />
<span style="color:#3f7f7f;padding-left:90px;">&lt;title&gt;</span>Die Hard<span style="color:#3f7f7f;">&lt;/title&gt;</span><br />
<span style="color:#3f7f7f;padding-left:90px;">&lt;year&gt;</span>1988<span style="color:#3f7f7f;">&lt;/year&gt;</span><br />
<span style="color:#3f7f7f;padding-left:60px;">&lt;/dvd&gt;</span><br />
<span style="color:#3f7f7f;padding-left:30px;">&lt;dvd_list&gt;</span><br />
<span style="color:#3f7f7f;">&lt;dvd_collection&gt;</span></p>
<p style="border:1px solid #b0b0b0;background-color:#e8e9ea;font-size:10pt;font-family:'Courier New';padding:10px;"><span style="color:#7f0085;font-weight:bold;">import</span> java.io.FileOutputStream;<br />
<br />
<span style="color:#7f0085;font-weight:bold;">import</span> org.jdom.Attribute;<br />
<span style="color:#7f0085;font-weight:bold;">import</span> org.jdom.Document;<br />
<span style="color:#7f0085;font-weight:bold;">import</span> org.jdom.Element;<br />
<span style="color:#7f0085;font-weight:bold;">import</span> org.jdom.output.Format;<br />
<span style="color:#7f0085;font-weight:bold;">import</span> org.jdom.output.XMLOutputter;<br />
<br />
<span style="color:#7f0085;font-weight:bold;">public class</span> JDOMDVD {<br />
<span style="color:#3f7f5f;padding-left:40px;">// Create the XML root Element</span><br />
<span style="color:#7f0085;font-weight:bold;padding-left:40px;">static</span> Element <span style="color:#0000c0;font-style:italic;">root</span> = <span style="color:#7f0085;">new</span> Element(<span style="color:#2a00ff;">&quot;dvd_collection&quot;</span>);<br />
<br />
<span style="color:#3f7f5f;padding-left:40px;">// Create a JDOM Document based on the root Element</span><br />
<span style="color:#7f0085;font-weight:bold;padding-left:40px;">static</span> Document <span style="color:#0000c0;font-style:italic;">document</span> = <span style="color:#7f0085;font-weight:bold;">new</span> Document(<span style="color:#0000c0;font-style:italic;">root</span>);<br />
<br />
<span style="color:#7f0085;font-weight:bold;padding-left:40px;">public static void</span> main(String[] args) {<br />
<span style="color:#3f7f5f;padding-left:80px;">// Create a new &quot;dvd_list&quot; Element</span><br />
<span style="color:#3f7f5f;padding-left:80px;">// that we will add to the root Element</span><br />
<span style="padding-left:80px;">Element actionDvdList = </span><span style="color:#7f0085;font-weight:bold;">new</span> Element(<span style="color:#2a00ff;">&quot;dvd_list&quot;</span>);<br />
<span style="padding-left:80px;color:#0000c0;">root</span>.addContent(actionDvdList);<br />
<br />
<span style="color:#3f7f5f;padding-left:80px;">// Create a new Attribute and add it</span><br />
<span style="color:#3f7f5f;padding-left:80px;">// to the actionDvdList Element</span><br />
<span style="padding-left:80px;">Attribute genre = </span><span style="color:#7f0085;font-weight:bold;">new</span> Attribute(<span style="color:#2a00ff;">&quot;genre&quot;</span>,<span style="color:#2a00ff;">&quot;action&quot;</span>);<br />
<span style="padding-left:80px;">actionDvdList.setAttribute(genre);</span><br />
<br />
<span style="color:#3f7f5f;padding-left:80px;">// Create a new &quot;dvd&quot; Element and add it</span><br />
<span style="color:#3f7f5f;padding-left:80px;">// to the actionDvdList Element</span><br />
<span style="padding-left:80px;">Element dvd = </span><span style="color:#7f0085;font-weight:bold;">new</span> Element(<span style="color:#2a00ff;">&quot;dvd&quot;</span>);<br />
<span style="padding-left:80px;">actionDvdList.addContent(dvd);<br />
<br />
<span style="color:#3f7f5f;padding-left:80px;">// Create a new &quot;title&quot; Element, set its text,</span><br />
<span style="color:#3f7f5f;padding-left:80px;">// and add it to the dvd Element</span><br />
<span style="padding-left:80px;">Element dvdTitle = </span><span style="color:#7f0085;font-weight:bold;">new</span> Element(<span style="color:#2a00ff;">&quot;title&quot;</span>);<br />
<span style="padding-left:80px;">dvdTitle.setText(</span><span style="color:#2a00ff;">&quot;Die Hard&quot;</span>);<br />
<span style="padding-left:80px;">dvd.addContent(dvdTitle);</span><br />
<br />
<span style="color:#3f7f5f;padding-left:80px;">// Create a new &quot;year&quot; Element, set its text, </span><br />
<span style="color:#3f7f5f;padding-left:80px;">// and add it to the dvd Element</span><br />
<span style="padding-left:80px;">Element dvdReleaseYear = </span><span style="color:#7f0085;font-weight:bold;">new</span> Element(<span style="color:#2a00ff;">&quot;year&quot;</span>);<br />
<span style="padding-left:80px;">dvdReleaseYear.setText(</span><span style="color:#2a00ff;">&quot;1988&quot;</span>);<br />
<span style="padding-left:80px;">dvd.addContent(dvdReleaseYear);</span><br />
<br />
<span style="color:#3f7f5f;padding-left:80px;">// show the XML output</span><br />
<span style="color:#7f0085;font-weight:bold;padding-left:80px;">try</span> {<br />
<span style="color:#3f7f5f;padding-left:120px;">// We use classic output format with getPrettyFormat()</span><br />
<span style="padding-left:120px;">XMLOutputter xmlOutputter = </span><span style="color:#7f0085;font-weight:bold;">new</span> XMLOutputter(Format.getPrettyFormat());<br />
<span style="padding-left:120px;">xmlOutputter.output(<span style="color:#0000c0;font-style:italic;">document</span>, System.<span style="color:#0000c0;font-style:italic;">out</span>);<br />
<span style="padding-left:80px;">}</span><br />
<span style="color:#7f0085;font-weight:bold;padding-left:80px;">catch</span> (java.io.IOException e) {<br />
<span style="padding-left:120px;">e.printStackTrace();</span><br />
<span style="padding-left:80px;">}</span><br />
<br />
<span style="color:#3f7f5f;padding-left:80px;">// Save it to a &quot;dvd.xml&quot; file</span><br />
<span style="color:#7f0085;font-weight:bold;padding-left:80px;">try</span> {<br />
<span style="color:#3f7f5f;padding-left:120px;">// We use classic output format with getPrettyFormat()</span><br />
<span style="padding-left:120px;">XMLOutputter xmlOutputter = </span><span style="color:#7f0085;font-weight:bold;">new</span> XMLOutputter(Format.getPrettyFormat());<br />
<span style="padding-left:120px;">xmlOutputter.output(<span style="color:#0000c0;font-style:italic;">document</span>, <span style="color:#7f0085;font-weight:bold;">new</span> FileOutputStream(<span style="color:#2a00ff;">&quot;dvd.xml&quot;</span>));<br />
<span style="padding-left:80px;">}</span><br />
<span style="color:#7f0085;font-weight:bold;padding-left:80px;">catch</span> (java.io.IOException e) {<br />
<span style="padding-left:120px;">e.printStackTrace();</span><br />
<span style="padding-left:80px;">}</span><br />
<span style="padding-left:40px;">}</span><br />
}</p>
<p>The result:</p>
<p style="border:1px solid black;background-color:#ffffff;font-size:10pt;font-family:'Courier New';padding:10px;">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br />
&lt;dvd_collection&gt;<br />
<span style="padding-left:16px;">&lt;dvd_list genre=&quot;action&quot;&gt;</span><br />
<span style="padding-left:32px;">&lt;dvd&gt;</span><br />
<span style="padding-left:48px;">&lt;title&gt;Die Hard&lt;/title&gt;</span><br />
<span style="padding-left:48px;">&lt;year&gt;1988&lt;/year&gt;</span><br />
<span style="padding-left:32px;">&lt;/dvd&gt;</span><br />
<span style="padding-left:16px;">&lt;dvd_list&gt;</span><br />
&lt;dvd_collection&gt;</p>
<p>I said you that it was easy ! <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p style="text-align:justify;">Now let’s see how it works with exisiting XML files. We will parse a XML file to a JDOM tree. To do this, we’ll use the <a href="http://www.jdom.org/docs/apidocs/org/jdom/input/SAXBuilder.html">org.jdom.input.SAXBuilder</a> class, based on the <a href="http://www.saxproject.org/">SAX API</a>.<span>..</span><br />
First, create the following XML file in your JDOMDVD class directory. Let’s call it <strong>&#8220;dvd_collection.xml&#8221;</strong></p>
<p style="border:1px solid #909090;background-color:#fff;font-family:'Courier New';font-size:10pt;padding:10px;"><span style="color:#3f7f7f;">&lt;?xml</span> <span style="color:#7f007f;">version</span>=<span style="color:#2a00ff;font-style:italic;">&quot;1.0&quot;</span> <span style="color:#7f007f;">encoding</span>=<span style="color:#2a00ff;font-style:italic;">&quot;UTF-8&quot;</span><span style="color:#3f7f7f;">?&gt;</span><br />
<span style="color:#3f7f7f;">&lt;dvd_collection&gt;</span><br />
<span style="color:#3f7f7f;padding-left:30px;">&lt;dvd_list</span> <span style="color:#7f007f;">genre</span>=<span style="color:#2a00ff;font-style:italic;">&quot;action&quot;</span><span style="color:#3f7f7f;">&gt;</span><br />
<span style="color:#3f7f7f;padding-left:60px;">&lt;dvd&gt;</span><br />
<span style="color:#3f7f7f;padding-left:90px;">&lt;title&gt;</span>Die Hard<span style="color:#3f7f7f;">&lt;/title&gt;</span><br />
<span style="color:#3f7f7f;padding-left:90px;">&lt;year&gt;</span>1988<span style="color:#3f7f7f;">&lt;/year&gt;</span><br />
<span style="color:#3f7f7f;padding-left:60px;">&lt;/dvd&gt;</span><br />
<span style="color:#3f7f7f;padding-left:60px;">&lt;dvd&gt;</span><br />
<span style="color:#3f7f7f;padding-left:90px;">&lt;title&gt;</span>Die Hard 2<span style="color:#3f7f7f;">&lt;/title&gt;</span><br />
<span style="color:#3f7f7f;padding-left:90px;">&lt;year&gt;</span>1990<span style="color:#3f7f7f;">&lt;/year&gt;</span><br />
<span style="color:#3f7f7f;padding-left:60px;">&lt;/dvd&gt;</span><br />
<span style="color:#3f7f7f;padding-left:60px;">&lt;dvd&gt;</span><br />
<span style="color:#3f7f7f;padding-left:90px;">&lt;title&gt;</span>Die Hard with a Vengeance<span style="color:#3f7f7f;">&lt;/title&gt;</span><br />
<span style="color:#3f7f7f;padding-left:90px;">&lt;year&gt;</span>1995<span style="color:#3f7f7f;">&lt;/year&gt;</span><br />
<span style="color:#3f7f7f;padding-left:60px;">&lt;/dvd&gt;</span><br />
<span style="color:#3f7f7f;padding-left:60px;">&lt;dvd&gt;</span><br />
<span style="color:#3f7f7f;padding-left:90px;">&lt;title&gt;</span>Die Hard 4.0<span style="color:#3f7f7f;">&lt;/title&gt;</span><br />
<span style="color:#3f7f7f;padding-left:90px;">&lt;year&gt;</span>2007<span style="color:#3f7f7f;">&lt;/year&gt;</span><br />
<span style="color:#3f7f7f;padding-left:60px;">&lt;/dvd&gt;</span><br />
<span style="color:#3f7f7f;padding-left:30px;">&lt;/dvd_list&gt;</span><br />
<span style="color:#3f7f7f;padding-left:30px;">&lt;dvd_list</span> <span style="color:#7f007f;">genre</span>=<span style="color:#2a00ff;font-style:italic;">&quot;comedy&quot;</span><span style="color:#3f7f7f;">&gt;</span><br />
<span style="color:#3f7f7f;padding-left:60px;">&lt;dvd&gt;</span><br />
<span style="color:#3f7f7f;padding-left:90px;">&lt;title&gt;</span>There&#8217;s Something about Mary<span style="color:#3f7f7f;">&lt;/title&gt;</span><br />
<span style="color:#3f7f7f;padding-left:90px;">&lt;year&gt;</span>1998<span style="color:#3f7f7f;">&lt;/year&gt;</span><br />
<span style="color:#3f7f7f;padding-left:60px;">&lt;/dvd&gt;</span><br />
<span style="color:#3f7f7f;padding-left:60px;">&lt;dvd&gt;</span><br />
<span style="color:#3f7f7f;padding-left:90px;">&lt;title&gt;</span>Monty Python and the Holy Grail<span style="color:#3f7f7f;">&lt;/title&gt;</span><br />
<span style="color:#3f7f7f;padding-left:90px;">&lt;year&gt;</span>1975<span style="color:#3f7f7f;">&lt;/year&gt;</span><br />
<span style="color:#3f7f7f;padding-left:60px;">&lt;/dvd&gt;</span><br />
<span style="color:#3f7f7f;padding-left:30px;">&lt;/dvd_list&gt;</span><br />
<span style="color:#3f7f7f;">&lt;/dvd_collection&gt;</span></p>
<p style="text-align:justify;">We will try to show all the DVD titles from our DVD collection XML file.<span>..</span><br />
Let’s create the <strong>JDOMDVDTitles</strong> class:</p>
<p style="border:1px solid #b0b0b0;background-color:#e8e9ea;font-size:10pt;font-family:'Courier New';padding:10px;"><span style="color:#7f0085;font-weight:bold;">import</span> java.io.File;<br />
<br />
<span style="color:#7f0085;font-weight:bold;">import</span> javax.swing.JFileChooser;<br />
<br />
<span style="color:#7f0085;font-weight:bold;">import</span> org.jdom.Document;<br />
<span style="color:#7f0085;font-weight:bold;">import</span> org.jdom.Element;<br />
<span style="color:#7f0085;font-weight:bold;">import</span> org.jdom.input.SAXBuilder;<br />
<br />
<span style="color:#7f0085;font-weight:bold;">public class</span> JDOMDVDTitles {<br />
<span style="color:#7f0085;font-weight:bold;padding-left:40px;">static</span> Document <span style="color:#0000c0;font-style:italic;">document</span>;<br />
<span style="color:#7f0085;font-weight:bold;padding-left:40px;">static</span> Element <span style="color:#0000c0;font-style:italic;">root</span>;<br />
<br />
<span style="color:#7f0085;font-weight:bold;padding-left:40px;">public static void</span> main(String[] args) {<br />
<span style="color:#3f7f5f;padding-left:80px;">// Create a SAXBuilder instance</span><br />
<span style="padding-left:80px;">SAXBuilder sxb = </span><span style="color:#7f0085;font-weight:bold;">new</span> SAXBuilder();<br />
<br />
<span style="color:#3f7f5f;padding-left:80px;">// Dialog to choose the XML file to parse</span><br />
<span style="padding-left:80px;">JFileChooser jfc = </span><span style="color:#7f0085;font-weight:bold;">new</span> JFileChooser(<span style="color:#2a00ff;">&quot;.&quot;</span>);<br />
<span style="color:#7f0085;font-weight:bold;padding-left:80px;">int</span> result = jfc.showOpenDialog(<span style="color:#7f0085;font-weight:bold;">null</span>);<br />
<span style="color:#7f0085;font-weight:bold;padding-left:80px;">switch</span>(result) {<br />
<span style="color:#7f0085;font-weight:bold;padding-left:80px;">case</span> JFileChooser.<span style="color:#0000c0;font-style:italic;">APPROVE_OPTION</span>:<br />
<span style="color:#7f0085;font-weight:bold;padding-left:120px;">try</span> {<br />
<span style="color:#3f7f5f;padding-left:160px;">// Create a new JDOM document from a XML file</span><br />
<span style="padding-left:160px;">File file = jfc.getSelectedFile();</span><br />
<span style="padding-left:160px;">System.</span><span style="color:#0000c0;font-style:italic;">out</span>.println(<span style="color:#2a00ff;">&quot;Parsing &quot;</span>+file+<span style="color:#2a00ff;">&quot;.<span>..</span>&quot;</span>);<br />
<span style="color:#0000c0;font-style:italic;padding-left:160px;">document</span> = sxb.build(file);<br />
<span style="color:#3f7f5f;padding-left:160px;">// Parsing done !</span><br />
<span style="padding-left:120px;">}</span><br />
<span style="color:#7f0085;font-weight:bold;padding-left:120px;">catch</span>(Exception e) {<br />
<span style="padding-left:160px;">e.printStackTrace();</span><br />
<span style="padding-left:120px;">}</span><br />
<span style="color:#7f0085;font-weight:bold;padding-left:120px;">break</span>;<br />
<span style="color:#7f0085;font-weight:bold;padding-left:80px;">case</span> JFileChooser.<span style="color:#0000c0;font-style:italic;">CANCEL_OPTION</span>:<br />
<span style="padding-left:120px;">System.</span><span style="color:#0000c0;font-style:italic;">out</span>.println(<span style="color:#2a00ff;">&quot;Operation canceled.<span>..</span>&quot;</span>);<br />
<span style="padding-left:120px;">System</span>.<em>exit</em>(0);<br />
<span style="color:#7f0085;font-weight:bold;padding-left:120px;">break</span>;<br />
<span style="color:#7f0085;font-weight:bold;padding-left:80px;">case</span> JFileChooser.<span style="color:#0000c0;font-style:italic;">ERROR_OPTION</span>:<br />
<span style="padding-left:120px;">System.</span><span style="color:#0000c0;font-style:italic;">out</span>.println(<span style="color:#2a00ff;">&quot;!! An error has occured !!&quot;</span>);<br />
<span style="padding-left:120px;">System</span>.<em>exit</em>(0);<br />
<span style="color:#7f0085;font-weight:bold;padding-left:120px;">break</span>;<br />
<span style="padding-left:80px;">}</span><br />
<br />
<span style="color:#3f7f5f;padding-left:80px;">// Initialize the root Element with the document root Element</span><br />
<span style="color:#7f0085;font-weight:bold;padding-left:80px;">try</span> {<br />
<span style="color:#0000c0;font-style:italic;padding-left:120px;">root</span> = <span style="color:#0000c0;font-style:italic;">document</span>.getRootElement();<br />
<span style="padding-left:80px;">}</span><br />
<span style="color:#7f0085;font-weight:bold;padding-left:80px;">catch</span>(NullPointerException e) {<br />
<span style="padding-left:120px;">e.printStackTrace();</span><br />
<span style="padding-left:80px;">}</span><br />
<br />
<span style="color:#3f7f5f;padding-left:80px;">// Browse the XML tree to retrieve dvd titles</span><br />
<span style="color:#7f0085;font-weight:bold;padding-left:80px;">for</span>(Object dvd_list : root.getChildren(<span style="color:#2a00ff;">&quot;dvd_list&quot;</span>)) {<br />
<span style="padding-left:120px;">Element courant = (Element) dvd_list;</span><br />
<span style="color:#7f0085;font-weight:bold;padding-left:120px;">for</span>(Object dvd : courant.getChildren(<span style="color:#2a00ff;">&quot;dvd&quot;</span>)) {<br />
<span style="padding-left:160px;">Element dvdElt = (Element) dvd;<br />
<span style="padding-left:160px;">System.</span><span style="color:#0000c0;font-style:italic;">out</span>.println(dvdElt.getChild(<span style="color:#2a00ff;">&quot;title&quot;</span>).getText());<br />
<span style="padding-left:120px;">}</span><br />
<span style="padding-left:80px;">}</span><br />
<span style="padding-left:40px;">}</span><br />
}</p>
<p style="text-align:justify;">Here is the output:</p>
<p style="border:1px solid black;background-color:#ffffff;font-size:10pt;font-family:'Courier New';padding:10px;">Parsing D:\eclipse3.4\workspace\JDOM\dvd_collection.xml .<span>..</span><br />
Die Hard<br />
Die Hard 2<br />
Die Hard with a Vengeance<br />
Die Hard 4.0<br />
There&#8217;s Something about Mary<br />
Monty Python and the Holy Grail</p>
<p style="text-align:justify;">As easy as our first example ! Now let&#8217;s do something a little more complex.<span>..</span><br />
We will try to make a filtered search on our DVD collection: Let’s find the “action” movies from 1995 and more. To do this, we will use the <a href="http://www.jdom.org/docs/apidocs/org/jdom/filter/Filter.html">org.jdom.filter.Filter</a> interface <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p style="border:1px solid #b0b0b0;background-color:#e8e9ea;font-size:10pt;font-family:'Courier New';padding:10px;"><span style="color:#7f0085;font-weight:bold;">import</span> java.io.File;<br />
<br />
<span style="color:#7f0085;font-weight:bold;">import</span> javax.swing.JFileChooser;<br />
<br />
<span style="color:#7f0085;font-weight:bold;">import</span> org.jdom.Document;<br />
<span style="color:#7f0085;font-weight:bold;">import</span> org.jdom.Element;<br />
<span style="color:#7f0085;font-weight:bold;">import</span> org.jdom.filter.Filter;<br />
<span style="color:#7f0085;font-weight:bold;">import</span> org.jdom.input.SAXBuilder;<br />
<br />
<span style="color:#7f0085;font-weight:bold;">public class</span> JDOMDVDFilter {<br />
<span style="color:#7f0085;font-weight:bold;padding-left:40px;">static</span> Document <span style="color:#0000c0;font-style:italic;">document</span>;<br />
<span style="color:#7f0085;font-weight:bold;padding-left:40px;">static</span> Element <span style="color:#0000c0;font-style:italic;">root</span>;<br />
<br />
<span style="color:#7f0085;font-weight:bold;padding-left:40px;">public static void</span> main(String[] args) {<br />
<span style="color:#3f7f5f;padding-left:80px;">// Create a SAXBuilder instance</span><br />
<span style="padding-left:80px;">SAXBuilder sxb = </span><span style="color:#7f0085;font-weight:bold;">new</span> SAXBuilder();<br />
<br />
<span style="color:#3f7f5f;padding-left:80px;">// Dialog to choose the XML file to parse</span><br />
<span style="padding-left:80px;">JFileChooser jfc = </span><span style="color:#7f0085;font-weight:bold;">new</span> JFileChooser(<span style="color:#2a00ff;">&quot;.&quot;</span>);<br />
<span style="color:#7f0085;font-weight:bold;padding-left:80px;">int</span> result = jfc.showOpenDialog(<span style="color:#7f0085;font-weight:bold;">null</span>);<br />
<span style="color:#7f0085;font-weight:bold;padding-left:80px;">switch</span>(result) {<br />
<span style="color:#7f0085;font-weight:bold;padding-left:80px;">case</span> JFileChooser.<span style="color:#0000c0;font-style:italic;">APPROVE_OPTION</span>:<br />
<span style="color:#7f0085;font-weight:bold;padding-left:120px;">try</span> {<br />
<span style="color:#3f7f5f;padding-left:160px;">// Create a new JDOM document from a XML file</span><br />
<span style="padding-left:160px;">File file = jfc.getSelectedFile();</span><br />
<span style="padding-left:160px;">System.</span><span style="color:#0000c0;font-style:italic;">out</span>.println(<span style="color:#2a00ff;">&quot;Parsing &quot;</span>+file+<span style="color:#2a00ff;">&quot;.<span>..</span>&quot;</span>);<br />
<span style="color:#0000c0;font-style:italic;padding-left:160px;">document</span> = sxb.build(file);<br />
<span style="color:#3f7f5f;padding-left:160px;">// Parsing done !</span><br />
<span style="padding-left:120px;">}</span><br />
<span style="color:#7f0085;font-weight:bold;padding-left:120px;">catch</span>(Exception e) {<br />
<span style="padding-left:160px;">e.printStackTrace();</span><br />
<span style="padding-left:120px;">}</span><br />
<span style="color:#7f0085;font-weight:bold;padding-left:120px;">break</span>;<br />
<span style="color:#7f0085;font-weight:bold;padding-left:80px;">case</span> JFileChooser.<span style="color:#0000c0;font-style:italic;">CANCEL_OPTION</span>:<br />
<span style="padding-left:120px;">System.</span><span style="color:#0000c0;font-style:italic;">out</span>.println(<span style="color:#2a00ff;">&quot;Operation canceled.<span>..</span>&quot;</span>);<br />
<span style="padding-left:120px;">System</span>.<em>exit</em>(0);<br />
<span style="color:#7f0085;font-weight:bold;padding-left:120px;">break</span>;<br />
<span style="color:#7f0085;font-weight:bold;padding-left:80px;">case</span> JFileChooser.<span style="color:#0000c0;font-style:italic;">ERROR_OPTION</span>:<br />
<span style="padding-left:120px;">System.</span><span style="color:#0000c0;font-style:italic;">out</span>.println(<span style="color:#2a00ff;">&quot;!! An error has occured !!&quot;</span>);<br />
<span style="padding-left:120px;">System</span>.<em>exit</em>(0);<br />
<span style="color:#7f0085;font-weight:bold;padding-left:120px;">break</span>;<br />
<span style="padding-left:80px;">}</span><br />
<br />
<span style="color:#3f7f5f;padding-left:80px;">// Initialize the root Element with the document root Element</span><br />
<span style="color:#7f0085;font-weight:bold;padding-left:80px;">try</span> {<br />
<span style="color:#0000c0;font-style:italic;padding-left:120px;">root</span> = <span style="color:#0000c0;font-style:italic;">document</span>.getRootElement();<br />
<span style="padding-left:80px;">}</span><br />
<span style="color:#7f0085;font-weight:bold;padding-left:80px;">catch</span>(NullPointerException e) {<br />
<span style="padding-left:120px;">e.printStackTrace();</span><br />
<span style="padding-left:80px;">}</span><br />
<br />
<span style="color:#3f7f5f;padding-left:80px;">// Create a new Filter</span><br />
<span style="padding-left:80px;">Filter myDvdFilter = </span><span style="color:#7f0085;font-weight:bold;">new</span> Filter() {<br />
<span style="color:#3f7f5f;padding-left:120px;">// Define filter properties with the &#8216;matches&#8217; method</span><br />
<span style="color:#7f0085;font-weight:bold;padding-left:120px;">public boolean</span> matches(Object ob) {<br />
<span style="color:#3f7f5f;padding-left:160px;">// Check ob is an Element</span><br />
<span style="color:#7f0085;font-weight:bold;padding-left:160px;">if</span>(!(ob <span style="color:#7f0085;font-weight:bold;">instanceof</span> Element)){<span style="color:#7f0085;font-weight:bold;">return false</span>;}<br />
<span style="padding-left:160px;">Element element = (Element) ob;</span><br />
<span style="color:#7f0085;font-weight:bold;padding-left:160px;">boolean</span> genreChecked = <span style="color:#7f0085;font-weight:bold;">false</span>;<br />
<span style="color:#7f0085;font-weight:bold;padding-left:160px;">boolean</span> yearChecked = <span style="color:#7f0085;font-weight:bold;">false</span>;<br />
<span style="color:#7f0085;font-weight:bold;padding-left:160px;">if</span>(element.getParentElement() != <span style="color:#7f0085;font-weight:bold;">null</span>) {<br />
<span style="color:#3f7f5f;padding-left:200px;">// Check genre = &quot;action&quot;</span><br />
<span style="padding-left:200px;">genreChecked = element.getParentElement().getAttributeValue(<span style="color:#2a00ff;">&quot;genre&quot;</span>).equals(<span style="color:#2a00ff;">&quot;action&quot;</span>);</span><br />
<span style="color:#3f7f5f;padding-left:200px;">// Check date &gt;= 1995</span><br />
<span style="padding-left:200px;">yearChecked = Integer.parseInt(element.getChild(<span style="color:#2a00ff;">&quot;year&quot;</span>).getText()) &gt;= 1995;</span><br />
<span style="padding-left:160px;">}</span><br />
<span style="color:#7f0085;font-weight:bold;padding-left:160px;">return</span> genreChecked &amp;&amp; yearChecked;<br />
<span style="padding-left:120px;">}</span><br />
<span style="padding-left:80px;">};</span><br />
<br />
<span style="color:#3f7f5f;padding-left:80px;">// Browse &quot;dvd&quot; item and do a Filtered search</span><br />
<span style="padding-left:80px;">System.</span><span style="color:#0000c0;font-style:italic;">out</span>.println(<span style="color:#2a00ff;">&quot;-<span>-</span>-<span>-</span>-<span>-</span>\nFiltered Search.<span>..</span>&quot;</span>);<br />
<span style="color:#7f0085;font-weight:bold;padding-left:80px;">for</span>(Object object : <span style="color:#0000c0;font-style:italic;">root</span>.getChildren(<span style="color:#2a00ff;">&quot;dvd_list&quot;</span>)) {<br />
<span style="padding-left:120px;">Element dvdList = (Element) object;</span><br />
<span style="color:#3f7f5f;padding-left:120px;">// Browse the list of &quot;dvd&quot; Element matching our Filter</span><br />
<span style="color:#7f0085;font-weight:bold;padding-left:120px;">for</span>(Object searchResultOb : dvdList.getContent(myDvdFilter)) {<br />
<span style="padding-left:160px;">Element dvd = (Element) searchResultOb;<br />
<span style="padding-left:160px;">System.</span><span style="color:#0000c0;font-style:italic;">out</span>.println(dvd.getChild(<span style="color:#2a00ff;">&quot;title&quot;</span>).getText());<br />
<span style="padding-left:120px;">}</span><br />
<span style="padding-left:80px;">}</span><br />
<span style="padding-left:40px;">}</span><br />
}</p>
<p style="text-align:justify;">Here is the result:</p>
<p style="border:1px solid black;background-color:#ffffff;font-size:10pt;font-family:'Courier New';padding:10px;">Parsing D:\eclipse3.4\workspace\JDOM\dvd_collection.xml .<span>..</span><br />
-<span>-</span>-<span>-</span>-<span>-</span><br />
Filtered Search.<span>..</span><br />
Die Hard with a Vengeance<br />
Die Hard 4.0</p>
<p style="text-align:justify;">I only show you the basics functionalities of <a href="http://jdom.org">JDOM</a>, just to show you its simplicity.<br />
I invite you to take a look to the <a href="http://www.jdom.org/docs/apidocs/">JDOM API Documentation</a> to learn more about it <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/thecoffeemachine.wordpress.com/133/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/thecoffeemachine.wordpress.com/133/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecoffeemachine.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecoffeemachine.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecoffeemachine.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecoffeemachine.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thecoffeemachine.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thecoffeemachine.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thecoffeemachine.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thecoffeemachine.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecoffeemachine.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecoffeemachine.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecoffeemachine.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecoffeemachine.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecoffeemachine.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecoffeemachine.wordpress.com/133/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecoffeemachine.wordpress.com&amp;blog=4432299&amp;post=133&amp;subd=thecoffeemachine&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thecoffeemachine.wordpress.com/2008/08/29/xml-with-java-and-jdom/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e4336f1b0407e42867480795df950a6c?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">ObLiB</media:title>
		</media:content>

		<media:content url="http://thecoffeemachine.files.wordpress.com/2008/08/java_icon_48x32.gif" medium="image">
			<media:title type="html">Java</media:title>
		</media:content>
	</item>
		<item>
		<title>The Visitor Pattern</title>
		<link>http://thecoffeemachine.wordpress.com/2008/08/25/the-visitor-pattern/</link>
		<comments>http://thecoffeemachine.wordpress.com/2008/08/25/the-visitor-pattern/#comments</comments>
		<pubDate>Mon, 25 Aug 2008 15:26:32 +0000</pubDate>
		<dc:creator>ObLiB</dc:creator>
				<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[visitor]]></category>

		<guid isPermaLink="false">http://thecoffeemachine.wordpress.com/?p=58</guid>
		<description><![CDATA[For my work I needed to browse a “tree” to retrieve some data and make operations with it. To manage this, I made some research and I found a design pattern that I didn’t know yet: The Visitor Pattern. To spread a hierarchy of classes, normally you simply add methods which provide desired behavior. It [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecoffeemachine.wordpress.com&amp;blog=4432299&amp;post=58&amp;subd=thecoffeemachine&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;"><img style="border:none;float:right;margin:0 0 0 8px;padding:0;" src="http://thecoffeemachine.files.wordpress.com/2008/09/uml_icon_35x48.png?w=48&#038;h=35" alt="Design Patterns" width="48" height="35" />For my work I needed to browse a “tree” to retrieve some data and make operations with it. To manage this, I made some research and I found a design pattern that I didn’t know yet: <a href="http://thecoffeemachine.wordpress.com/2008/08/25/the-visitor-pattern/">The Visitor Pattern</a>.</p>
<p style="text-align:justify;">To spread a hierarchy of classes, normally you simply add methods which provide desired behavior. It can happen however that this behavior is not consistent with the logic of the existent object model. It is also possible that you do not have access to existent code. In such situations, it can be impossible to spread the behavior of hierarchy without changing his classes. <a href="http://thecoffeemachine.wordpress.com/2008/08/25/the-visitor-pattern/">The Visitor Pattern</a> precisely allows the developer of a hierarchy to insert a support for cases where other developers would like to spread his behavior.</p>
<p><span id="more-58"></span></p>
<p style="text-align:justify;">This design pattern allows an external class to reach the internal variables of other classes (going contrary to concepts of POO). This model is useful when they have a reasonable number of instances of a small number of classes and that we want to perform operations which implicate them all (or many of them).</p>
<p style="text-align:justify;">If deporting operations contained in a class towards another one can seem bad for POO, there are good reasons to make it. Indeed, if these operations are identical for every class instead of duplicating this method it is preferable to put these operations in a visitor (operation centralization). The visitor will use then the internal data of every object to perform asked operation.</p>
<p style="text-align:justify;">In practice, <a href="http://thecoffeemachine.wordpress.com/2008/08/25/the-visitor-pattern/">the Visitor Pattern</a> is realized in the following way: every class that can be &#8220;visited&#8221; must make available a public method « accept » taking as argument an object of type &#8220;visitor&#8221;. The « accept » method will call the « visit » method of the visitor object with the visited object as argument. In that way, a visitor object will be able to know the reference of the visited object and call his public methods to acquire data necessary for the treatment to perform (counting, generation of report, etc).</p>
<p align="center"><a href="http://thecoffeemachine.files.wordpress.com/2008/08/visitorpatternuml.png"><img src="http://thecoffeemachine.files.wordpress.com/2008/08/visitorpatternuml.png?w=300&#038;h=424" alt="Visitor Pattern - UML" width="300" height="424" /></a></p>
<p style="text-align:justify;">Here is an example to make the whole thing much more understandable <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p style="text-align:justify;">Let’s create a hierarchy: We will define a house in which we will put a list of house elements (living room, bathroom, bedroom, garden, garage…) and implements <a href="http://thecoffeemachine.wordpress.com/2008/08/25/the-visitor-pattern/">the visitor pattern</a> in this hierarchy…</p>
<p style="text-align:justify;">First, let’s define the visit able interface to make our house elements able to accept the visitor:</p>
<p style="border:1px solid #b0b0b0;background-color:#e8e9ea;font-size:10pt;font-family:'Courier New';padding:10px;"><strong><span style="color:#7f0055;">public interface</span></strong> IHouseElement {<br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public void</span></strong> accept(IVisitor visitor);</span><br />
}</p>
<p style="text-align:justify;">Then, let’s define the house and its elements:</p>
<p style="border:1px solid #b0b0b0;background-color:#e8e9ea;font-size:10pt;font-family:'Courier New';padding:10px;"><strong><span style="color:#7f0055;">public class</span></strong> Garden <strong><span style="color:#7f0055;">implements</span></strong> IHouseElement {<br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">private int</span></strong></span> <span style="color:#0000c0;">sq_ft</span>;<br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">private boolean</span></strong></span> <span style="color:#0000c0;">swimmingPool</span>;<br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public int</span></strong></span> getSq_ft() {<br />
<span style="padding-left:80px;"><strong><span style="color:#7f0055;">return</span></strong></span> <span style="color:#0000c0;">sq_ft</span>;<br />
<span style="padding-left:40px;">}</span><br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public boolean</span></strong></span> hasSwimmingPool() {<br />
<span style="padding-left:80px;"><strong><span style="color:#7f0055;">return</span></strong></span> <span style="color:#0000c0;">swimmingPool</span>;<br />
<span style="padding-left:40px;">}</span><br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public</span></strong></span> Garden(<strong><span style="color:#7f0055;">int</span></strong> sq_ft, <strong><span style="color:#7f0055;">boolean</span></strong> swimmingPool) {<br />
<span style="padding-left:80px;"><strong><span style="color:#7f0055;">this</span></strong></span>.<span style="color:#0000c0;">sq_ft</span> = sq_ft;<br />
<span style="padding-left:80px;"><strong><span style="color:#7f0055;">this</span></strong></span>.<span style="color:#0000c0;">swimmingPool</span> = swimmingPool;<br />
<span style="padding-left:40px;">}</span><br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public void</span></strong></span> accept(IVisitor visitor) {<br />
<span style="padding-left:80px;">visitor.visit(<strong><span style="color:#7f0055;">this</span></strong>);</span><br />
<span style="padding-left:40px;">}</span><br />
}</p>
<p style="border:1px solid #b0b0b0;background-color:#e8e9ea;font-size:10pt;font-family:'Courier New';padding:10px;"><strong><span style="color:#7f0055;">public class</span></strong> CarPark <strong><span style="color:#7f0055;">implements</span></strong> IHouseElement {<br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">private int</span></strong></span> <span style="color:#0000c0;">carNb</span>;<br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public int</span></strong></span> getCarNb() {<br />
<span style="padding-left:80px;"><strong><span style="color:#7f0055;">return</span></strong></span> <span style="color:#0000c0;">carNb</span>;<br />
<span style="padding-left:40px;">}</span><br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public</span></strong></span> CarPark(<strong><span style="color:#7f0055;">int</span></strong> carNb) {<br />
<span style="padding-left:80px;"><strong><span style="color:#7f0055;">this</span></strong></span>.<span style="color:#0000c0;">carNb</span> = carNb;<br />
<span style="padding-left:40px;">}</span><br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public void</span></strong></span> accept(IVisitor visitor) {<br />
<span style="padding-left:80px;">visitor.visit(<strong><span style="color:#7f0055;">this</span></strong>);</span><br />
<span style="padding-left:40px;">}</span><br />
}</p>
<p style="border:1px solid #b0b0b0;background-color:#e8e9ea;font-size:10pt;font-family:'Courier New';padding:10px;"><strong><span style="color:#7f0055;">public class</span></strong> Room <strong><span style="color:#7f0055;">implements</span></strong> IHouseElement {<br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">private </span></strong></span>String <span style="color:#0000c0;">name</span>;<br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">private int</span></strong></span> <span style="color:#0000c0;">sq_ft</span>;<br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public </span></strong></span>String getName() {<br />
<span style="padding-left:80px;"><strong><span style="color:#7f0055;">return</span></strong></span> <span style="color:#0000c0;">name</span>;<br />
<span style="padding-left:40px;">}</span><br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public int</span></strong></span> getSq_ft() {<br />
<span style="padding-left:80px;"><strong><span style="color:#7f0055;">return</span></strong></span> <span style="color:#0000c0;">sq_ft</span>;<br />
<span style="padding-left:40px;">}</span><br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public</span></strong></span> Room(String name, <strong><span style="color:#7f0055;">int</span></strong> sq_ft) {<br />
<span style="padding-left:80px;"><strong><span style="color:#7f0055;">this</span></strong></span>.<span style="color:#0000c0;">name</span> = name;<br />
<span style="padding-left:80px;"><strong><span style="color:#7f0055;">this</span></strong></span>.<span style="color:#0000c0;">sq_ft</span> = sq_ft;<br />
<span style="padding-left:40px;">}</span><br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public void</span></strong></span> accept(IVisitor visitor) {<br />
<span style="padding-left:80px;">visitor.visit(<strong><span style="color:#7f0055;">this</span></strong>);</span><br />
<span style="padding-left:40px;">}</span><br />
}</p>
<p style="border:1px solid #b0b0b0;background-color:#e8e9ea;font-size:10pt;font-family:'Courier New';padding:10px;"><strong><span style="color:#7f0055;">public class</span></strong> Bedroom <strong><span style="color:#7f0055;">extends</span></strong> Room {<br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">private int</span></strong></span> <span style="color:#0000c0;">bedNb</span>;<br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public int</span></strong></span> getBedNb() {<br />
<span style="padding-left:80px;"><strong><span style="color:#7f0055;">return</span></strong></span> <span style="color:#0000c0;">bedNb</span>;<br />
<span style="padding-left:40px;">}</span><br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public</span></strong></span> Bedroom(String name, <strong><span style="color:#7f0055;">int</span></strong> sq_ft, <strong><span style="color:#7f0055;">int</span></strong> bedNb) {<br />
<span style="padding-left:80px;"><strong><span style="color:#7f0055;">super</span></strong></span>(name, sq_ft);<br />
<span style="padding-left:80px;"><strong><span style="color:#7f0055;">this</span></strong></span>.<span style="color:#0000c0;">bedNb</span> = bedNb;<br />
<span style="padding-left:40px;">}</span><br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public void</span></strong></span> accept(IVisitor visitor) {<br />
<span style="padding-left:80px;">visitor.visit((Room) <strong><span style="color:#7f0055;">this</span></strong>);</span><br />
<span style="padding-left:80px;">visitor.visit(<strong><span style="color:#7f0055;">this</span></strong>);</span><br />
<span style="padding-left:40px;">}</span><br />
}</p>
<p style="border:1px solid #b0b0b0;background-color:#e8e9ea;font-size:10pt;font-family:'Courier New';padding:10px;"><strong><span style="color:#7f0055;">public class</span></strong> Bathroom <strong><span style="color:#7f0055;">extends</span></strong> Room {<br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">private int</span></strong></span> <span style="color:#0000c0;">showerNb</span>;<br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">private int</span></strong></span> <span style="color:#0000c0;">bathNb</span>;<br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public int</span></strong></span> getShowerNb() {<br />
<span style="padding-left:80px;"><strong><span style="color:#7f0055;">return</span></strong></span> <span style="color:#0000c0;">showerNb</span>;<br />
<span style="padding-left:40px;">}</span><br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public int</span></strong></span> getBathNb() {<br />
<span style="padding-left:80px;"><strong><span style="color:#7f0055;">return</span></strong></span> <span style="color:#0000c0;">bathNb</span>;<br />
<span style="padding-left:40px;">}</span><br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public</span></strong></span> Bathroom(String name, <strong><span style="color:#7f0055;">int</span></strong> sq_ft, <strong><span style="color:#7f0055;">int</span></strong> showerNb, <strong><span style="color:#7f0055;">int</span></strong> bathNb) {<br />
<span style="padding-left:80px;"><strong><span style="color:#7f0055;">super</span></strong></span>(name, sq_ft);<br />
<span style="padding-left:80px;"><strong><span style="color:#7f0055;">this</span></strong></span>.<span style="color:#0000c0;">showerNb</span> = showerNb;<br />
<span style="padding-left:80px;"><strong><span style="color:#7f0055;">this</span></strong></span>.<span style="color:#0000c0;">bathNb</span> = bathNb;<br />
<span style="padding-left:40px;">}</span><br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public void</span></strong></span> accept(IVisitor visitor) {<br />
<span style="padding-left:80px;">visitor.visit((Room) <strong><span style="color:#7f0055;">this</span></strong>);</span><br />
<span style="padding-left:80px;">visitor.visit(<strong><span style="color:#7f0055;">this</span></strong>);</span><br />
<span style="padding-left:40px;">}</span><br />
}</p>
<p style="border:1px solid #b0b0b0;background-color:#e8e9ea;font-size:10pt;font-family:'Courier New';padding:10px;"><strong><span style="color:#7f0055;">public class</span></strong> House {<br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">private </span></strong></span>String <span style="color:#0000c0;">name</span>;<br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">private </span></strong></span> IHouseElement[] <span style="color:#0000c0;">houseElements</span>;<br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public </span></strong></span> String getName() {<br />
<span style="padding-left:80px;"><strong><span style="color:#7f0055;">return</span></strong></span> <span style="color:#0000c0;">name</span>;<br />
<span style="padding-left:40px;">}</span><br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public </span></strong></span> IHouseElement[] getHouseElements() {<br />
<span style="padding-left:80px;"><strong><span style="color:#7f0055;">return</span></strong></span> <span style="color:#0000c0;">houseElements</span>;<br />
<span style="padding-left:40px;">}</span><br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public</span></strong></span> House() {<br />
<span style="padding-left:80px;"><strong><span style="color:#7f0055;">this</span></strong></span>.<span style="color:#0000c0;">name</span> = <span style="color:#2a00ff;">&quot;My house&quot;</span>;<br />
<span style="padding-left:80px;"><strong><span style="color:#7f0055;">this</span></strong></span>.<span style="color:#0000c0;">houseElements</span> = <strong><span style="color:#7f0055;">new </span></strong>IHouseElement[] {<br />
<span style="padding-left:120px;"><strong><span style="color:#7f0055;">new </span></strong></span>Room(<span style="color:#2a00ff;">&quot;Living room&quot;</span>, 600),<br />
<span style="padding-left:120px;"><strong><span style="color:#7f0055;">new </span></strong></span>Bedroom(<span style="color:#2a00ff;">&quot;first bedroom&quot;</span>, 300, 1),<br />
<span style="padding-left:120px;"><strong><span style="color:#7f0055;">new </span></strong></span>Bathroom(<span style="color:#2a00ff;">&quot;little bathroom&quot;</span>, 100, 1, 0),<br />
<span style="padding-left:120px;"><strong><span style="color:#7f0055;">new </span></strong></span>Bedroom(<span style="color:#2a00ff;">&quot;second bedroom&quot;</span>, 500, 1),</span><br />
<span style="padding-left:120px;"><strong><span style="color:#7f0055;">new </span></strong></span>Bathroom(<span style="color:#2a00ff;">&quot;big bathroom&quot;</span>, 400, 1, 1),<br />
<span style="padding-left:120px;"><strong><span style="color:#7f0055;">new </span></strong></span>Garden(1200, <strong><span style="color:#7f0055;">true</span></strong>),<br />
<span style="padding-left:120px;"><strong><span style="color:#7f0055;">new </span></strong>CarPark(1)};</span><br />
<span style="padding-left:40px;">}</span><br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public void</span></strong></span> accept(IVisitor visitor) {<br />
<span style="padding-left:80px;">visitor.visit(<strong><span style="color:#7f0055;">this</span></strong>);</span><br />
<span style="padding-left:40px;">}</span><br />
}</p>
<p style="text-align:justify;">Next we have to define the visitor interface and we’ll create two different possible visitor implementations.</p>
<p style="border:1px solid #b0b0b0;background-color:#e8e9ea;font-size:10pt;font-family:'Courier New';padding:10px;"><strong><span style="color:#7f0055;">public interface</span></strong> IVisitor {<br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public void</span></strong></span> visit(House house);</span><br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public void</span></strong></span> visit(Room room);</span><br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public void</span></strong></span> visit(Bathroom bathroom);</span><br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public void</span></strong></span> visit(Bedroom bedroom);</span><br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public void</span></strong></span> visit(Garden garden);</span><br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public void</span></strong></span> visit(CarPark carPark);</span><br />
}</p>
<p style="text-align:justify;">First implementation: Visit the house and list its elements</p>
<p style="border:1px solid #b0b0b0;background-color:#e8e9ea;font-size:10pt;font-family:'Courier New';padding:10px;"><strong><span style="color:#7f0055;">public class</span></strong> PrintVisitor <strong><span style="color:#7f0055;">implements</span></strong> IVisitor {<br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public void</span></strong></span> visit(House house) {</span><br />
<span style="padding-left:80px;">System.<em><span style="color:#0000c0;">out</span></em>.println(<span style="color:#2a00ff;">&quot;Visiting house: &quot;</span>+house.getName());</span><br />
<span style="padding-left:80px;"><strong><span style="color:#7f0055;">for</span></strong>(IHouseElement room : house.getHouseElements()) {</span><br />
<span style="padding-left:120px;">room.accept(<strong><span style="color:#7f0055;">this</strong></span>);</span><br />
<span style="padding-left:80px;">}</span><br />
<span style="padding-left:80px;">System.<em><span style="color:#0000c0;">out</span></em>.println(<span style="color:#2a00ff;">&quot;House visited.<span>..</span>\n&quot;</span>);</span><br />
<span style="padding-left:40px;">}</span><br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public void</span></strong></span> visit(Room room) {</span><br />
<span style="padding-left:80px;">System.<em><span style="color:#0000c0;">out</span></em>.println(<span style="color:#2a00ff;">&quot;Visiting room: &quot;</span>+room.getName()+<span style="color:#2a00ff;">&quot; (&quot;</span>+room.getSq_ft()+<span style="color:#2a00ff;">&quot; sq ft)&quot;</span>);</span><br />
<span style="padding-left:40px;">}</span><br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public void</span></strong></span> visit(Bathroom bathroom) {</span><br />
<span style="padding-left:80px;">System.<em><span style="color:#0000c0;">out</span></em>.println(<span style="color:#2a00ff;">&quot;&nbsp;&nbsp;- &quot;</span>+bathroom.getShowerNb()+<span style="color:#2a00ff;">&quot; shower(s)&quot;</span>);</span><br />
<span style="padding-left:80px;">System.<em><span style="color:#0000c0;">out</span></em>.println(<span style="color:#2a00ff;">&quot;&nbsp;&nbsp;- &quot;</span>+bathroom.getBathNb()+<span style="color:#2a00ff;">&quot; bath(s)&quot;</span>);</span><br />
<span style="padding-left:40px;">}</span><br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public void</span></strong></span> visit(Bedroom bedroom) {</span><br />
<span style="padding-left:80px;">System.<em><span style="color:#0000c0;">out</span></em>.println(<span style="color:#2a00ff;">&quot;&nbsp;&nbsp;- &quot;</span>+bedroom.getBedNb()+<span style="color:#2a00ff;">&quot; bed(s)&quot;</span>);</span><br />
<span style="padding-left:40px;">}</span><br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public void</span></strong></span> visit(Garden garden) {</span><br />
<span style="padding-left:80px;">System.<em><span style="color:#0000c0;">out</span></em>.println(<span style="color:#2a00ff;">&quot;Visiting Garden: &quot;</span>);</span><br />
<span style="padding-left:80px;"><strong><span style="color:#7f0055;">if</span></strong>(garden.hasSwimmingPool())</span><br />
<span style="padding-left:80px;"><span style="padding-left:80px;">System.<em><span style="color:#0000c0;">out</span></em>.println(<span style="color:#2a00ff;">&quot;&nbsp;&nbsp;- With a swimming pool&quot;</span>);</span><br />
<span style="padding-left:40px;">}</span><br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public void</span></strong></span> visit(CarPark carPark) {</span><br />
<span style="padding-left:80px;">System.<em><span style="color:#0000c0;">out</span></em>.println(<span style="color:#2a00ff;">&quot;Visiting CarPark: &quot;</span>);</span><br />
<span style="padding-left:80px;"><span style="padding-left:80px;">System.<em><span style="color:#0000c0;">out</span></em>.println(<span style="color:#2a00ff;">&quot;&nbsp;&nbsp;- &quot;</span>+carPark.getCarNb()+<span style="color:#2a00ff;">&quot; parking place(s)&quot;</span>);</span><br />
<span style="padding-left:40px;">}</span><br />
}</p>
<p style="text-align:justify;">Second implementation: Visit the house to get its total surface</p>
<p style="border:1px solid #b0b0b0;background-color:#e8e9ea;font-size:10pt;font-family:'Courier New';padding:10px;"><strong><span style="color:#7f0055;">public class</span></strong> SurfaceVisitor <strong><span style="color:#7f0055;">implements</span></strong> IVisitor {<br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">private int</span></strong></span><span style="color:#0000c0;"> totalSqFt</span>;</span><br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public</span></strong></span> SurfaceVisitor() {<br />
<span style="padding-left:80px;"><strong><span style="color:#7f0055;">this</span></strong>.<span style="color:#0000c0;">totalSqFt</span> = 0;</span><br />
<span style="padding-left:40px;">}</span><br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public void</span></strong></span> visit(House house) {</span><br />
<span style="padding-left:80px;">System.<em><span style="color:#0000c0;">out</span></em>.println(<span style="color:#2a00ff;">&quot;Visiting house: &quot;</span>+house.getName());</span><br />
<span style="padding-left:80px;"><strong><span style="color:#7f0055;">for</span></strong>(IHouseElement room : house.getHouseElements()) {</span><br />
<span style="padding-left:120px;">room.accept(<strong><span style="color:#7f0055;">this</strong></span>);</span><br />
<span style="padding-left:80px;">}</span><br />
<span style="padding-left:80px;">System.<em><span style="color:#0000c0;">out</span></em>.println(<span style="color:#2a00ff;">&quot;\nHouse total surface = &quot;</span>+totalSqFt+<span style="color:#2a00ff;">&quot; sq ft\n&quot;</span>);</span><br />
<span style="padding-left:40px;">}</span><br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public void</span></strong></span> visit(Room room) {</span><br />
<span style="padding-left:80px;">System.<em><span style="color:#0000c0;">out</span></em>.println(<span style="color:#2a00ff;">&quot;Visiting room: &quot;</span>+room.getName());</span><br />
<span style="padding-left:80px;">System.<em><span style="color:#0000c0;">out</span></em>.println(<span style="color:#2a00ff;">&quot; &#8211; &quot;</span>+room.getSq_ft()+<span style="color:#2a00ff;">&quot; = &quot;</span>+(<strong><span style="color:#7f0055;">this</span></strong>.<span style="color:#0000c0;">totalSqFt</span> += room.getSq_ft()));</span><br />
<span style="padding-left:40px;">}</span><br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public void</span></strong></span> visit(Bathroom bathroom) {</span><br />
<span style="padding-left:80px;"><span style="color:#3f7f5f;">// nothing to do</span></span><br />
<span style="padding-left:40px;">}</span><br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public void</span></strong></span> visit(Bedroom bedroom) {</span><br />
<span style="padding-left:80px;"><span style="color:#3f7f5f;">// nothing to do</span></span><br />
<span style="padding-left:40px;">}</span><br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public void</span></strong></span> visit(Garden garden) {</span><br />
<span style="padding-left:80px;">System.<em><span style="color:#0000c0;">out</span></em>.println(<span style="color:#2a00ff;">&quot;Visiting Garden: &quot;</span>);</span><br />
<span style="padding-left:80px;">System.<em><span style="color:#0000c0;">out</span></em>.println(<span style="color:#2a00ff;">&quot; &#8211; &quot;</span>+garden.getSq_ft()+<span style="color:#2a00ff;">&quot; = &quot;</span>+(<strong><span style="color:#7f0055;">this</span></strong>.<span style="color:#0000c0;">totalSqFt</span> += garden.getSq_ft()));</span><br />
<span style="padding-left:40px;">}</span><br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public void</span></strong></span> visit(CarPark carPark) {</span><br />
<span style="padding-left:80px;"><span style="color:#3f7f5f;">// nothing to do</span></span><br />
<span style="padding-left:40px;">}</span><br />
}</p>
<p style="text-align:justify;">Finally, run a little test:</p>
<p style="border:1px solid #b0b0b0;background-color:#e8e9ea;font-size:10pt;font-family:'Courier New';padding:10px;"><strong><span style="color:#7f0055;">public class</span></strong> Test {<br />
<span style="padding-left:40px;"><strong><span style="color:#7f0055;">public static void</span></strong> main(String[] args) {</span><br />
<span style="padding-left:80px;">House house = <strong><span style="color:#7f0055;">new </span></strong></span> House();</span><br />
<span style="padding-left:80px;">IVisitor printVisitor = <strong><span style="color:#7f0055;">new </span></strong> PrintVisitor();</span><br />
<span style="padding-left:80px;">IVisitor surfaceVisitor = <strong><span style="color:#7f0055;">new </span></strong> SurfaceVisitor();</span><br />
<span style="padding-left:80px;">house.accept(printVisitor);</span><br />
<span style="padding-left:80px;">System.<em><span style="color:#0000c0;">out</span></em>.println(<span style="color:#2a00ff;">&quot;-<span>-</span>-<span>-</span>-<span>-</span>-<span>-</span>&quot;</span>);</span><br />
<span style="padding-left:80px;">house.accept(surfaceVisitor);</span><br />
<span style="padding-left:40px;">}</span><br />
}</p>
<p style="text-align:justify;">Here is the output:</p>
<p style="border:1px solid black;background-color:#ffffff;font-size:10pt;font-family:'Courier New';padding:10px;">
Visiting House: My house<br />
Visiting Room: Living room (600 sq ft)<br />
Visiting Room: first bedroom (300 sq ft)<br />
&nbsp;&nbsp;- 1 bed(s)<br />
Visiting Room: little bathroom (100 sq ft)<br />
&nbsp;&nbsp;- 1 shower(s)<br />
&nbsp;&nbsp;- 0 bath(s)<br />
Visiting Room: second bedroom (500 sq ft)<br />
&nbsp;&nbsp;- 1 bed(s)<br />
Visiting Room: big bathroom (400 sq ft)<br />
&nbsp;&nbsp;- 1 shower(s)<br />
&nbsp;&nbsp;- 1 bath(s)<br />
Visiting Garden<br />
&nbsp;&nbsp;- With a swimming pool<br />
Visiting CarPark<br />
&nbsp;&nbsp;- 1 parking place(s)<br />
House visited.<span>..</span><br />
<br />
-<span>-</span>-<span>-</span>-<span>-</span>-<span>-</span><br />
Visiting House: My house<br />
Visiting Room : Living room<br />
 &#8211; 0 + 600 = 600<br />
Visiting Room : first bedroom<br />
 &#8211; 600 + 300 = 900<br />
Visiting Room : little bathroom<br />
 &#8211; 900 + 100 = 1000<br />
Visiting Room : second bedroom<br />
 &#8211; 1000 + 500 = 1500<br />
Visiting Room : big bathroom<br />
 &#8211; 1500 + 400 = 1900<br />
Visiting Garden<br />
 &#8211; 1900 + 1200 = 3100<br />
<br />
House total surface = 3100 sq ft
</p>
<p style="text-align:justify;">This example show you the power and the interest of this pattern. But you’ve got to take care; Even if <a href="http://thecoffeemachine.wordpress.com/2008/08/25/the-visitor-pattern/">the visitor pattern</a> is great, he has some limits: He is very dependent of the data structure.</p>
<p style="text-align:justify;">Look at our house example: Let’s imagine that the Bedroom and Bathroom classes are not implemented in the IVisitor interface. The Bedroom and Bathroom instance would never been visited, so we wouldn’t be able to distinguish those two different type of Room. Of course you will say that to avoid this problem we just have to take care to include all the subclasses of our hierarchy in the visitor interface (like we do in the example). But if our data structure improves? For example if a new Room type is defined in the future, you won’t be able to visit it without redefining the IVisitor interface <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p style="text-align:justify;">Another problem is the risks present in the data structure itself. If you develop a visitor without knowing the code of the visited hierarchy, you can’t be aware of everything concerning the original behavior of this hierarchy and the way it’s coding, so you can get trapped.</p>
<div style="border:2px solid #6c0c91;background-color:#e2c9e9;color:#6c0c91;font-weight:bold;text-align:justify;margin:10px;padding:15px;">
So keep in mind that <a href="http://thecoffeemachine.wordpress.com/2008/08/25/the-visitor-pattern/">the Visitor Pattern</a> is much more powerful with the following conditions:
<ul>
<li>All the types of nodes are stable</li>
<li>A common change is the addition of new functions that apply to different nodes</li>
</ul>
</div>
<p></p>
<p style="text-align:justify;">I hope that now you are aware of what&#8217;s the Visitor Pattern <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/thecoffeemachine.wordpress.com/58/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/thecoffeemachine.wordpress.com/58/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecoffeemachine.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecoffeemachine.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecoffeemachine.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecoffeemachine.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thecoffeemachine.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thecoffeemachine.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thecoffeemachine.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thecoffeemachine.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecoffeemachine.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecoffeemachine.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecoffeemachine.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecoffeemachine.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecoffeemachine.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecoffeemachine.wordpress.com/58/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecoffeemachine.wordpress.com&amp;blog=4432299&amp;post=58&amp;subd=thecoffeemachine&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thecoffeemachine.wordpress.com/2008/08/25/the-visitor-pattern/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e4336f1b0407e42867480795df950a6c?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">ObLiB</media:title>
		</media:content>

		<media:content url="http://thecoffeemachine.files.wordpress.com/2008/09/uml_icon_35x48.png" medium="image">
			<media:title type="html">Design Patterns</media:title>
		</media:content>

		<media:content url="http://thecoffeemachine.files.wordpress.com/2008/08/visitorpatternuml.png?w=300" medium="image">
			<media:title type="html">Visitor Pattern - UML</media:title>
		</media:content>
	</item>
		<item>
		<title>Subversive in Eclipse Ganymede</title>
		<link>http://thecoffeemachine.wordpress.com/2008/08/20/subversive-in-eclipse-ganymede/</link>
		<comments>http://thecoffeemachine.wordpress.com/2008/08/20/subversive-in-eclipse-ganymede/#comments</comments>
		<pubDate>Wed, 20 Aug 2008 15:33:12 +0000</pubDate>
		<dc:creator>ObLiB</dc:creator>
				<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Ganymede]]></category>
		<category><![CDATA[3.4]]></category>
		<category><![CDATA[connector]]></category>
		<category><![CDATA[subversive]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://thecoffeemachine.wordpress.com/?p=6</guid>
		<description><![CDATA[While trying to install Subversive on Eclipse Ganymede I get this error : Cannot find a solution where both Match[requiredCapability: org.eclipse.equinox.p2.iu/org.eclipse.team.svn.feature.group/[0.7.1.I20080612-1500,0.7.1.I20080612-1500]] and Match[requiredCapability: org.eclipse.equinox.p2.iu/org.eclipse.team.svn.feature.group/[0.7.3.I20080814-1500,1.0.0)] can be satisfied. Unsatisfied dependency: [org.polarion.eclipse.team.svn.connector.svnkit.feature.group 2.0.3.I20080814-1500] requiredCapability: org.eclipse.equinox.p2.iu/org.eclipse.team.svn.feature.group/[0.7.3.I20080814-1500,1.0.0) Unsatisfied dependency: [org.polarion.eclipse.team.svn.connector.svnkit.feature.group 2.0.3.I20080814-1500] requiredCapability: org.eclipse.equinox.p2.iu/org.polarion.eclipse.team.svn.connector.feature.group/0.0.0 Unsatisfied dependency: [org.polarion.eclipse.team.svn.connector.svnkit15.feature.group 2.0.3.I20080814-1500] requiredCapability: org.eclipse.equinox.p2.iu/org.eclipse.team.svn.feature.group/[0.7.3.I20080814-1500,1.0.0) Unsatisfied dependency: [org.polarion.eclipse.team.svn.connector.svnkit15.feature.group 2.0.3.I20080814-1500] requiredCapability: org.eclipse.equinox.p2.iu/org.polarion.eclipse.team.svn.connector.feature.group/0.0.0 Unsatisfied dependency: [org.polarion.eclipse.team.svn.connector.feature.group 2.0.3.I20080814-1500] [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecoffeemachine.wordpress.com&amp;blog=4432299&amp;post=6&amp;subd=thecoffeemachine&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img style="border:none;float:right;margin:0 0 0 8px;padding:0;" src="http://thecoffeemachine.files.wordpress.com/2008/08/eclipse_48x32.jpg?w=48&#038;h=32" alt="Eclipse" width="48" height="32" />While trying to install Subversive on Eclipse Ganymede I get this error :</p>
<blockquote><p>Cannot find a solution where both Match[requiredCapability: org.eclipse.equinox.p2.iu/org.eclipse.team.svn.feature.group/[0.7.1.I20080612-1500,0.7.1.I20080612-1500]] and Match[requiredCapability: org.eclipse.equinox.p2.iu/org.eclipse.team.svn.feature.group/[0.7.3.I20080814-1500,1.0.0)] can be satisfied.<br />
Unsatisfied dependency: [org.polarion.eclipse.team.svn.connector.svnkit.feature.group 2.0.3.I20080814-1500] requiredCapability: org.eclipse.equinox.p2.iu/org.eclipse.team.svn.feature.group/[0.7.3.I20080814-1500,1.0.0)<br />
Unsatisfied dependency: [org.polarion.eclipse.team.svn.connector.svnkit.feature.group 2.0.3.I20080814-1500] requiredCapability: org.eclipse.equinox.p2.iu/org.polarion.eclipse.team.svn.connector.feature.group/0.0.0<br />
Unsatisfied dependency: [org.polarion.eclipse.team.svn.connector.svnkit15.feature.group 2.0.3.I20080814-1500] requiredCapability: org.eclipse.equinox.p2.iu/org.eclipse.team.svn.feature.group/[0.7.3.I20080814-1500,1.0.0)<br />
Unsatisfied dependency: [org.polarion.eclipse.team.svn.connector.svnkit15.feature.group 2.0.3.I20080814-1500] requiredCapability: org.eclipse.equinox.p2.iu/org.polarion.eclipse.team.svn.connector.feature.group/0.0.0<br />
Unsatisfied dependency: [org.polarion.eclipse.team.svn.connector.feature.group 2.0.3.I20080814-1500] requiredCapability: org.eclipse.equinox.p2.iu/org.eclipse.team.svn.feature.group/[0.7.3.I20080814-1500,1.0.0)</p></blockquote>
<p><span id="more-6"></span></p>
<p style="text-align:justify;">Just like everyone I add this url in p2 :<br />
<a href="http://www.polarion.org/projects/subversive/download/eclipse/2.0/update-site/">http://www.polarion.org/projects/subversive/download/eclipse/2.0/update-site/</a><br />
The error comes out when I tried to Install the followings:</p>
<p><img class="size-full wp-image-7" src="http://thecoffeemachine.files.wordpress.com/2008/08/p2_svn_071.jpg" alt="Ganymede SVN Provider" width="572" height="496" /></p>
<p style="text-align:justify;">So I tried again but this time I unchecked the SVN Connectors and kept the SVN Team Provider. This time the installation worked well and I restarted my Eclipse to finish it. Of course, even if the SVN Team Provider was installed, I can&#8217;t use it without a SVN Connector. So I retried to install the SVN Connector, but the error cames out again&#8230;</p>
<p style="text-align:justify;">On the <a href="http://www.polarion.org/index.php?page=download&amp;project=subversive">subversive website</a> they talk about the Subversive plug-in update site:<br />
<a href="http://download.eclipse.org/technology/subversive/0.7/update-site/">http://download.eclipse.org/technology/subversive/0.7/update-site/</a><br />
So I add it in p2 and I retried the install but it failed again&#8230;</p>
<p style="text-align:justify;">At this time I really don&#8217;t understand what was appening. But after some google search, I got the solution: The SVN Team Provider version in the Ganymede update site is not the latest version. To get it works with the Connectors you&#8217;ve got to update it to the latest version. Here are the steps to make it works :</p>
<ol style="text-align:justify;">
<li>Go to Help-&gt;Software Updates.</li>
<li>Click on the &#8220;Available Software&#8221; tab.</li>
<li>Unfold the Ganymede-&gt;Collaboration Tools node, and if your experience is like mine, you will see the &#8220;SVN Team Provider (Incubation)&#8221; item with this version identifier, &#8220;0.7.1.I20080612-1500&#8243;. What you really need (since the Subversive/Polarion team posted updates) is the version from 2008-08-01.</li>
<li>Click on &#8220;Manage Sites…&#8221;.</li>
<li>Uncheck the &#8220;Ganymede&#8221; checkbox (http://download.eclipse.org/releases/ganymede)</li>
<li>Scroll down to find &#8220;http://download.eclipse.org/technology/subversive/0.7/update-site/&#8221;, select it and click &#8220;OK&#8221;.</li>
<li>You should be back on the &#8220;Available Software&#8221; tab, with only the subversive items present. Unfold the &#8220;Subversive SVN Team Provider Plugin (Incubation)&#8221; item, and you will see the &#8220;SVN Team Provider (Incubation)&#8221; item. Note that the version identifier is &#8220;0.7.3.I20080814-1500&#8243;.</li>
<li>Check the box, and click&#8221;install&#8221;. The install will be change to an update. Restart Eclipse at the end of the install.</li>
<li>Go to &#8220;Help-&gt;Software Updates&#8221;.</li>
<li>Choose the &#8220;Available Software&#8221; tab.</li>
<li>Click the &#8220;Add Site&#8221; button, and add &#8220;http://www.polarion.org/projects/subversive/download/eclipse/2.0/update-site/&#8221;.</li>
<li>Check the SVNKit Connectors and click &#8220;Install&#8221;. Restart Eclipse at the end of the install.</li>
<li>Subversive should be working !</li>
</ol>
<p>Thanks to <a href="http://blog.punchbarrel.com/2008/06/30/using-the-new-subversion-integration-in-eclipse-ganymede/">Frank Carver and Graig Thomas</a></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/thecoffeemachine.wordpress.com/6/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/thecoffeemachine.wordpress.com/6/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecoffeemachine.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecoffeemachine.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecoffeemachine.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecoffeemachine.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thecoffeemachine.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thecoffeemachine.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thecoffeemachine.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thecoffeemachine.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecoffeemachine.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecoffeemachine.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecoffeemachine.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecoffeemachine.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecoffeemachine.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecoffeemachine.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecoffeemachine.wordpress.com&amp;blog=4432299&amp;post=6&amp;subd=thecoffeemachine&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thecoffeemachine.wordpress.com/2008/08/20/subversive-in-eclipse-ganymede/feed/</wfw:commentRss>
		<slash:comments>54</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e4336f1b0407e42867480795df950a6c?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">ObLiB</media:title>
		</media:content>

		<media:content url="http://thecoffeemachine.files.wordpress.com/2008/08/eclipse_48x32.jpg" medium="image">
			<media:title type="html">Eclipse</media:title>
		</media:content>

		<media:content url="http://thecoffeemachine.files.wordpress.com/2008/08/p2_svn_071.jpg" medium="image">
			<media:title type="html">Ganymede SVN Provider</media:title>
		</media:content>
	</item>
		<item>
		<title>Would you like to take a coffee ?</title>
		<link>http://thecoffeemachine.wordpress.com/2008/08/20/would-you-like-to-take-a-coffee/</link>
		<comments>http://thecoffeemachine.wordpress.com/2008/08/20/would-you-like-to-take-a-coffee/#comments</comments>
		<pubDate>Wed, 20 Aug 2008 14:17:41 +0000</pubDate>
		<dc:creator>ObLiB</dc:creator>
				<category><![CDATA[The Coffee Machine]]></category>
		<category><![CDATA[coffee]]></category>

		<guid isPermaLink="false">http://thecoffeemachine.wordpress.com/?p=4</guid>
		<description><![CDATA[Hi, I&#8217;m starting this blog just to share and do a backup of the interesting things I found about Java &#38; Eclipse. I will try to update the blog the most often I can. Enjoy.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecoffeemachine.wordpress.com&amp;blog=4432299&amp;post=4&amp;subd=thecoffeemachine&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-20" src="http://thecoffeemachine.files.wordpress.com/2008/08/java_logo.gif" alt="" width="70" height="131" /><img style="border:none;display:inline;float:right;margin:0 0 0 8px;padding:0;" src="http://thecoffeemachine.files.wordpress.com/2008/08/coffee-machine-48x48.png?w=48&#038;h=48" alt="Eclipse" width="48" height="48" />Hi,</p>
<p>I&#8217;m starting this blog just to share and do a backup of the interesting things I found about Java &amp; Eclipse.<br />
I will try to update the blog the most often I can.</p>
<p>Enjoy.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/thecoffeemachine.wordpress.com/4/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/thecoffeemachine.wordpress.com/4/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thecoffeemachine.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thecoffeemachine.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thecoffeemachine.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thecoffeemachine.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thecoffeemachine.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thecoffeemachine.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thecoffeemachine.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thecoffeemachine.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thecoffeemachine.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thecoffeemachine.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thecoffeemachine.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thecoffeemachine.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thecoffeemachine.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thecoffeemachine.wordpress.com/4/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thecoffeemachine.wordpress.com&amp;blog=4432299&amp;post=4&amp;subd=thecoffeemachine&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thecoffeemachine.wordpress.com/2008/08/20/would-you-like-to-take-a-coffee/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e4336f1b0407e42867480795df950a6c?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">ObLiB</media:title>
		</media:content>

		<media:content url="http://thecoffeemachine.files.wordpress.com/2008/08/java_logo.gif" medium="image" />

		<media:content url="http://thecoffeemachine.files.wordpress.com/2008/08/coffee-machine-48x48.png" medium="image">
			<media:title type="html">Eclipse</media:title>
		</media:content>
	</item>
	</channel>
</rss>
