<?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>Shaaf's Blog &#187; utils</title>
	<atom:link href="http://www.shaafshah.com/tag/utils/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.shaafshah.com</link>
	<description>Another bit in the wall</description>
	<lastBuildDate>Wed, 12 Aug 2009 14:28:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Generate XML &#8211; DBMS_XMLGEN</title>
		<link>http://www.shaafshah.com/2008/12/10/generate-xml-dbms_xmlgen/</link>
		<comments>http://www.shaafshah.com/2008/12/10/generate-xml-dbms_xmlgen/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 14:58:04 +0000</pubDate>
		<dc:creator>Shaaf Shah</dc:creator>
				<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[DBMS_XMLGEN]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[utils]]></category>

		<guid isPermaLink="false">http://www.shaafshah.com/?p=137</guid>
		<description><![CDATA[On my way to my solution store just found this nice to use, old and easy feature. Possibilities endless, usage typically very easy. I used the following to generate XML from sqlplus: select dbms_xmlgen.getxml('select * from user') from dual; Output: < ROWSET > < ROW > < TNAME >Employee< / TNAME > < TABTYPE > [...]]]></description>
			<content:encoded><![CDATA[<p>On my way to my solution store just found this nice to use, old and easy feature.<br />
Possibilities endless, usage typically very easy.</p>
<p>I used the following to generate XML from sqlplus:</p>
<pre lang="SQL" line=1> select dbms_xmlgen.getxml('select * from user') from dual; </pre>
<p><strong>Output:</strong></p>
<pre lang="XML" line=1>
< ROWSET >
 < ROW >
  < TNAME >Employee< / TNAME >
  < TABTYPE > TABLE < / TABTYPE >
 < / ROW >
< / ROWSET >
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.shaafshah.com/2008/12/10/generate-xml-dbms_xmlgen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Doing the Locale &#8211; Danmark</title>
		<link>http://www.shaafshah.com/2008/11/12/doing-the-locale-danmark/</link>
		<comments>http://www.shaafshah.com/2008/11/12/doing-the-locale-danmark/#comments</comments>
		<pubDate>Wed, 12 Nov 2008 12:52:08 +0000</pubDate>
		<dc:creator>Shaaf Shah</dc:creator>
				<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[internationalization]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[locale]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[utils]]></category>

		<guid isPermaLink="false">http://www.shaafshah.com/?p=110</guid>
		<description><![CDATA[The following illustrates how to get the Number format working with a danish locale. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 import java.text.NumberFormat; import java.util.Currency; import java.util.Locale; &#160; &#160; public class TestLocale &#123; &#160; public static void main&#40;String [...]]]></description>
			<content:encoded><![CDATA[<p>The following illustrates how to get the Number format working with a danish locale.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.text.NumberFormat</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Currency</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Locale</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> TestLocale <span style="color: #009900;">&#123;</span>
&nbsp;
 <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> args<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
 <span style="color: #666666; font-style: italic;">// Create a Locale for Danmark</span>
 <span style="color: #003399;">Locale</span> DANMARK <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Locale</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;da&quot;</span>,<span style="color: #0000ff;">&quot;DK&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #666666; font-style: italic;">// get the currency instance for this locale.</span>
 Currency krone <span style="color: #339933;">=</span> Currency.<span style="color: #006633;">getInstance</span><span style="color: #009900;">&#40;</span>DANMARK<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #666666; font-style: italic;">// Get a Number format for the locale.</span>
 <span style="color: #003399;">NumberFormat</span> krFormat <span style="color: #339933;">=</span> <span style="color: #003399;">NumberFormat</span>.<span style="color: #006633;">getCurrencyInstance</span><span style="color: #009900;">&#40;</span>DANMARK<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #666666; font-style: italic;">// A symbol for the currency</span>
 <span style="color: #003399;">String</span> symbol <span style="color: #339933;">=</span> krFormat.<span style="color: #006633;">getCurrency</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getSymbol</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #666666; font-style: italic;">// A double amount</span>
 <span style="color: #000066; font-weight: bold;">double</span> amount <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10000.25</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// print it out after formatting.</span>
 <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>krFormat.<span style="color: #006633;">format</span><span style="color: #009900;">&#40;</span>amount<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.shaafshah.com/2008/11/12/doing-the-locale-danmark/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to read a file from the JAR?</title>
		<link>http://www.shaafshah.com/2008/10/31/how-to-read-a-file-from-the-jar/</link>
		<comments>http://www.shaafshah.com/2008/10/31/how-to-read-a-file-from-the-jar/#comments</comments>
		<pubDate>Fri, 31 Oct 2008 18:57:54 +0000</pubDate>
		<dc:creator>Shaaf Shah</dc:creator>
				<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[jar]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[utils]]></category>

		<guid isPermaLink="false">http://www.shaafshah.com/?p=103</guid>
		<description><![CDATA[Someone just asked me this question today. And I thought might as well put it down for info. 1 2 3 4 public TestReadFileFromJar&#40;&#41; throws FileNotFoundException, IOException &#123; InputStream is = getClass&#40;&#41;.getResource&#40;&#34;txtData/states.properties&#34;&#41;; read&#40;is&#41;; &#125; In the case above txtData is placed in the jar on the root. Remmember to add the path with the /]]></description>
			<content:encoded><![CDATA[<p>Someone just asked me this question today. And I thought might as well put it down for info.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"> <span style="color: #000000; font-weight: bold;">public</span> TestReadFileFromJar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">FileNotFoundException</span>, <span style="color: #003399;">IOException</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003399;">InputStream</span> is <span style="color: #339933;">=</span> getClass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getResource</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;txtData/states.properties&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        read<span style="color: #009900;">&#40;</span>is<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>In the case above txtData is placed in the jar on the root. Remmember to add the path with the /</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shaafshah.com/2008/10/31/how-to-read-a-file-from-the-jar/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Crocus &#8211; CSV Reader</title>
		<link>http://www.shaafshah.com/2008/10/03/crocus-csv-reader/</link>
		<comments>http://www.shaafshah.com/2008/10/03/crocus-csv-reader/#comments</comments>
		<pubDate>Fri, 03 Oct 2008 21:38:42 +0000</pubDate>
		<dc:creator>Shaaf Shah</dc:creator>
				<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[csv]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[utils]]></category>

		<guid isPermaLink="false">http://www.shaafshah.com/?p=51</guid>
		<description><![CDATA[Easy to use ready to go CSV File Reading utility. Read One or Multiple files into a RecordManager, quick access to the file with segmentation into Fields and Records. Merge Multiple CSV files in one. Listener to CSV Files. Download Here Organization: A CSV file is broken up as follows A CSVField has a group [...]]]></description>
			<content:encoded><![CDATA[<p>Easy to use ready to go CSV File Reading utility. Read One or Multiple files into a RecordManager, quick access to the file with segmentation into Fields and Records. Merge Multiple CSV files in one. Listener to CSV Files.</p>
<p><a title="Download Here" href="https://sourceforge.net/project/platformdownload.php?group_id=172152" target="_self">Download Here<br />
</a></p>
<p><strong>Organization:</strong><br />
A CSV file is broken up as follows<br />
A CSVField has a group of characters<br />
A CSVRecord has a group of CSVFields<br />
A CSVFile has a group of record</p>
<p><strong>How To Use:</strong></p>
<p>Reading a Single CSVFile into a RecordManager</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"> <span style="color: #666666; font-style: italic;">// Creating a single file interface</span>
CSVSingleFileInterface fileInterface <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> CSVSingleFileInterface<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/media/data/dev/workspace/crocus/testData/drupal-sample.csv&quot;</span>,CSVConstants.<span style="color: #006633;">COMMA</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// Calling the read returns a CSVRecordManager i.e. in memory</span>
AbstractCSVRecordManager manager <span style="color: #339933;">=</span> fileInterface.<span style="color: #006633;">read</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Reading multiple files into one RecordManager</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Specify a FileSet</span>
AbstractCSVFileSet fileSet <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> CSVFileSet<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Add files to the set</span>
fileSet.<span style="color: #006633;">addFile</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;testData/drupal-sample.csv&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
fileSet.<span style="color: #006633;">addFile</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;testData/countries.csv&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Add the fileSet to a Reading Interface</span>
CSVFileSetInterface fileSetInterface <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> CSVFileSetInterface<span style="color: #009900;">&#40;</span>fileSet<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//  Reading returns a manager same as in a Single file case.</span>
AbstractCSVRecordManager manager <span style="color: #339933;">=</span> fileSetInterface.<span style="color: #006633;">read</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>This functionality is not complete but a peak is available.<br />
You can now specify a Listener to Pre, Post and On Add of a record.<br />
<strong><br />
Setting up a Listener.</strong></p>
<p>To add you listener simply implement the RecordListener class</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Get a Record Manager</span>
AbstractCSVRecordManager manager <span style="color: #339933;">=</span> fileInterface.<span style="color: #006633;">getRecordManager</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Add a listener to the Manager.</span>
manager.<span style="color: #006633;">addRecordListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Implement an event listening method for listening to the RecordEvent.</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> eventPerformed<span style="color: #009900;">&#40;</span>RecordEvent recordEvent<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>recordEvent.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>for further information refer to the docs.  <a title="http://www.shaafshah.com/crocus/" href="http://www.shaafshah.com/crocus/" target="_self">http://www.shaafshah.com/crocus/</a></p>
<p><strong>The Build System:</strong></p>
<p>The build script supports the following targets</p>
<p>Build: init, clean, compile, jar, javadoc, tests</p>
<p>Including, Excluding files while creating compile, jar, tests</p>
<p><strong>FILE DETAILS (Paths and description):</strong></p>
<p><strong>PRE RULES:</strong></p>
<p>=========</p>
<p>CROCUS_DEV = the main directory i.e. examples from here onwards this will be the variable used for describing details.</p>
<p>You will need to set CROCUS_DEV env variable inorder to run the build process</p>
<p>Also you would need to set ANT_HOME for usage of ant. I have used Ant 1.6.5 for builds.</p>
<p>$CROCUS_DEV/src Holds the source code i.e. java files</p>
<p>$CROCUS_DEV/build Carries all the build related files</p>
<p>$CROCUS_DEV/build/build.xml Main build script</p>
<p>$CROCUS_DEV/build/include.xml patterns for inclusion of java files at the time of compilation</p>
<p>$CROCUS_DEV/build/exclude.xml patterns for exclusion of java files at the time of compilation</p>
<p>$CROCUS_DEV/build/tests_include.xml patterns for inclusion of test java files at the time of compilation</p>
<p>$CROCUS_DEV/build/tests_exclude.xml patterns for exclusion of test java files at the time of compilation</p>
<p>$CROCUS_DEV/build/tools tools used during build.</p>
<p>$CROCUS_DEV/build/jar_buildfiles you can simply specify a txt file with some wild card matches and name it as yourjar.jar for the build system to recognize that &#8220;yourjar.jar&#8221; will be the name for this jar that should have the packages in it as specified in this txt(yourjar.jar)</p>
<p>$CROCUS_DEV/build/bin Holds the uniz script and the bat file for developers to run the build script more or less as:</p>
<p>Windows:&gt; %CROCUS_DEV%/build all</p>
<p>Linux:&gt; $CROCUS_DEV/build.sh all</p>
<p>$CROCUS_DEV/build_results Holds all the results of the builds</p>
<p>$CROCUS_DEV/build_results/docs Created java docs</p>
<p>$CROCUS_DEV/build_results/classes Created classes</p>
<p>$CROCUS_DEV/build_results/tests Unit test results</p>
<p>$CROCUS_DEV/build_results/jars the jars created by the system</p>
<p>$CROCUS_DEV/jars/ Is the directory for jars related information</p>
<p>$CROCUS_DEV/jars/manifests Holds the manifests for the $CROCUS_DEV/build/jar_buildfiles.</p>
<p>Conventionally should use: Manifest.jarName</p>
<p>$CROCUS_DEV/jars/original3rdparty Holds any 3rd party vendor jars that might be used for putting in the classpath for the build system</p>
<p>$CROCUS_DEV/testData logically should hold all testData no matter how that might be. currently I have placed a few csv files (tabbed,comma,semicolon).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shaafshah.com/2008/10/03/crocus-csv-reader/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
