<?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/"
	>

<channel>
	<title>Ankit Jain &#187; java</title>
	<atom:link href="http://ankitjain.info/ankit/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://ankitjain.info/ankit</link>
	<description>» It’s all about Ankit and Web! «</description>
	<lastBuildDate>Thu, 02 Jun 2011 16:54:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Split Pascalcase String</title>
		<link>http://ankitjain.info/ankit/2009/09/11/spliting-camelcase-string/</link>
		<comments>http://ankitjain.info/ankit/2009/09/11/spliting-camelcase-string/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 18:32:12 +0000</pubDate>
		<dc:creator>Ankit</dc:creator>
				<category><![CDATA[Programming/Code]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[regexp]]></category>

		<guid isPermaLink="false">http://ankitjain.info/ankit/?p=344</guid>
		<description><![CDATA[Do you ever need to split a camel case or pascal case string to a set of words? This can be achieved simply by regular expressions in Java as well as C#. The following code is for Java: String camelCase = "StructuralDesignPattern"; StringBuffer label = new StringBuffer(camelCase + 10); java.util.regex.Pattern p = java.util.regex.Pattern.compile("[A-Z][a-z]+"); java.util.regex.Matcher m [...]]]></description>
			<content:encoded><![CDATA[<p>Do you ever need to split a camel case or pascal case string to a set of words? This can be achieved simply by regular expressions in Java as well as C#. The following code is for Java:<br />
<code><br />
		    String camelCase = "StructuralDesignPattern";<br />
		    StringBuffer label = new StringBuffer(camelCase + 10);<br />
		    java.util.regex.Pattern p = java.util.regex.Pattern.compile("[A-Z][a-z]+");<br />
		    java.util.regex.Matcher m = p.matcher(camelCase);<br />
		    while ( m.find() )<br />
		    {<br />
			label.append( m.group() + " ");<br />
		    }<br />
		    System.out.println(camelCase + " >> " + label.toString());<br />
</code></p>
<p>[ Note: this does not work for all test cases. You may also want to try regexp as <em>"[A-Z][a-z]+&#8221;</em>, for matching any continues uppercase letters too (e.g. AnkitJainFROMIndia >> Ankit Jain FROMIndia) ]</p>
<p>Jon Galloway <a target="_blank" href="http://weblogs.asp.net/jgalloway/archive/2005/09/27/426087.aspx">points out a tricky method</a> for C#.</p>
]]></content:encoded>
			<wfw:commentRss>http://ankitjain.info/ankit/2009/09/11/spliting-camelcase-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unreachable code Error or Warning?</title>
		<link>http://ankitjain.info/ankit/2009/07/08/java-unreachable-error-why/</link>
		<comments>http://ankitjain.info/ankit/2009/07/08/java-unreachable-error-why/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 04:14:13 +0000</pubDate>
		<dc:creator>Ankit</dc:creator>
				<category><![CDATA[Coding Guidelines]]></category>
		<category><![CDATA[Programming/Code]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://ankitjain.info/ankit/?p=330</guid>
		<description><![CDATA[In Java, unreachable code is treated as compilation error. What do you think? Isn&#8217;t making it warning would have made developers&#8217; life simpler? Of course you can write &#8211; if( true ) &#160;&#160;&#160;return; What if you could simply write return. This helps in testing a function quickly. As a good programming practice we always remove [...]]]></description>
			<content:encoded><![CDATA[<p>In Java, unreachable code is treated as compilation error. What do you think? Isn&#8217;t making it warning would have made developers&#8217; life simpler?</p>
<p>Of course you can write &#8211; </p>
<blockquote><p><code>if( true )<br />
&nbsp;&nbsp;&nbsp;return;<br />
</code> </p></blockquote>
<p>What if you could simply write return. This helps in testing a function quickly. As a good programming practice we always remove all warnings from code, and such unconditional return statements can be rectified later.</p>
]]></content:encoded>
			<wfw:commentRss>http://ankitjain.info/ankit/2009/07/08/java-unreachable-error-why/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Setting up SDB for MySQL</title>
		<link>http://ankitjain.info/ankit/2009/06/21/configure-jena-sdb-mysql-ubuntu/</link>
		<comments>http://ankitjain.info/ankit/2009/06/21/configure-jena-sdb-mysql-ubuntu/#comments</comments>
		<pubDate>Sun, 21 Jun 2009 15:33:05 +0000</pubDate>
		<dc:creator>Ankit</dc:creator>
				<category><![CDATA[Programming/Code]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://ankitjain.info/ankit/?p=327</guid>
		<description><![CDATA[Jena is a semantic web framework implemented in Java. It allows you to store/query/inference RDF/RDSF/OWL triples. In Jena a set of triples (in RDF) are called Model or stored within Model object. By default Jena creates in-memory models, but this is not suitable if you have pretty large set of triples to process. Here comes [...]]]></description>
			<content:encoded><![CDATA[<p>Jena is a semantic web framework implemented in Java. It allows you to store/query/inference RDF/RDSF/OWL triples. In Jena a set of triples (in RDF) are called Model or stored within Model object. By default Jena creates in-memory models, but this is not suitable if you have pretty large set of triples to process. Here comes SDB to rescue you. It&#8217;s a component of Jena that allows you to store these models in relational databases like MySQL, MSSQL, PostgreSQL, Oracle, etc; This post describes my experience while setting up SDB on Ubuntu.</p>
<ol>
<li><a href="http://jena.hpl.hp.com/wiki/SDB" target="_blank">Download SDB</a>. Extract it into some folder.</li>
<li>SDB works with SUN Java only. Ubuntu has GNU Java installed by default. You need to install SUN Java and <a href="http://ankitjain.info/ankit/2009/06/21/set-default-jvm-linux-sun-update/">set it as default</a>.<br />
<em>[Note: you know why this point is important? I wasted 1 hr when I did same setup second time. Later I realized I was using GNU libgcj (gij/gcj). For god's sake, someone please kill gcj... </em></li>
<li>Create a database for SDB in MySQL. I did using phpMyAdmin. Let&#8217;s call this database <em>SDB2</em>.</li>
<li>Prepare a store description file. It serves as config for SDB and contains information like where to connect. You will find one such example file in the SDB directory. Here is an example for the description file I have used:<br />
<code>@prefix sdb:     &lt;http://jena.hpl.hp.com/2007/sdb#&gt; .<br />
@prefix rdfs:	 &lt;http://www.w3.org/2000/01/rdf-schema#&gt; .<br />
@prefix rdf:     &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt; .<br />
@prefix ja:      &lt;http://jena.hpl.hp.com/2005/11/Assembler#&gt; .<br />
# MySQL - InnoDB<br />
&lt;#store&gt; rdf:type sdb:Store ;<br />
    sdb:layout     "layout2" ;<br />
    sdb:connection &lt;#conn&gt; ;<br />
    sdb:engine     "InnoDB" ;      # MySQL specific<br />
.<br />
&lt;#conn&gt; rdf:type sdb:SDBConnection ;<br />
    sdb:sdbType       "MySQL" ;     # Needed for JDBC URL<br />
    sdb:sdbHost       "localhost" ; #  or the IP address of the database server<br />
    sdb:sdbName       "SDB2" ;    # MySQL database name<br />
    sdb:sdbUser       "username";<br />
    sdb:sdbPassword   "password";<br />
    sdb:driver        "com.mysql.jdbc.Driver" ;<br />
    .<br />
</code>
</li>
<li>Set environment variables:
<p>SDB installation directory &#8211;<br />
<code>export SDBROOT="/home/ankit/tmp/SDB"</code></p>
<p>Path to MySQL JDBC commector jar which contains <code>com.mysql.jdbc.Driver</code> class.<br />
<code>export SDB_JDBC="/home/ankit/tmp/SDB/mysql-connector-java-5.1.7-bin.jar"</code></li>
<li>Required tables must be created in database before we can use it. Run following to initialize <code>SDB2</code> database. This creates 4 tables inside <code>SDB2</code>.<br />
<code> bin/sdbconfig --sdb=sdb.ttl --create</code><br />
If this fails, somthing went wrong with settings. Check them again.</li>
<li>Next you can run test suit to ensure everything is working fine.<br />
<code>bin/sdbtest --sdb=sdb.ttl testing/manifest-sdb.ttl</code></p>
<p>In my case one testcase failed stating -</p>
<blockquote><p><code>Failure:  Unicode-5(com.hp.hpl.jena.sdb.test.junit.QueryTestSDB): Results sets not the same</code></p></blockquote>
</li>
</ol>
<p>I decided to write this as the SDB wiki does now contains clear steps to follow. Hope your semantic (web) application ROCKS !</p>
<p>- ankit</p>
]]></content:encoded>
			<wfw:commentRss>http://ankitjain.info/ankit/2009/06/21/configure-jena-sdb-mysql-ubuntu/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Setting Default JVM on Ubuntu</title>
		<link>http://ankitjain.info/ankit/2009/06/21/set-default-jvm-linux-sun-update/</link>
		<comments>http://ankitjain.info/ankit/2009/06/21/set-default-jvm-linux-sun-update/#comments</comments>
		<pubDate>Sat, 20 Jun 2009 19:46:02 +0000</pubDate>
		<dc:creator>Ankit</dc:creator>
				<category><![CDATA[Quick Tricks]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://ankitjain.info/ankit/?p=324</guid>
		<description><![CDATA[Heard of &#8216;update-alternatives&#8217; on Linux? It&#8217;s a smart utility to find various versions of one software and set default. For example, you may have GNU Java as well as Sun Java. (frankly saying, I hate GNU Java, aka gcj) sudo update-alternatives --config java [ Where can I see all installed JVM? On Ubuntu, Java Virtual [...]]]></description>
			<content:encoded><![CDATA[<p>Heard of &#8216;update-alternatives&#8217; on Linux? It&#8217;s a smart utility to find various versions of one software and set default.</p>
<p>For example, you may have GNU Java as well as Sun Java. (frankly saying,  <a target="_blank" href="http://www.google.com/search?q=gcj+(UTF-8+or+mysql)+encoding+issues">I hate GNU Java, aka gcj</a>)</p>
<blockquote><p>
<code>sudo update-alternatives --config java</code></p></blockquote>
<p>[ <strong>Where can I see all installed JVM?</strong><br />
On Ubuntu, Java Virtual Machines are installed in <code>/usr/lib/jvm</code>. You can see <em>java-gcj</em> here which comes by default with Ubuntu.<br />
]<br />
- ankit</p>
]]></content:encoded>
			<wfw:commentRss>http://ankitjain.info/ankit/2009/06/21/set-default-jvm-linux-sun-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

