<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1768487440536086184</id><updated>2011-11-05T13:07:22.152-07:00</updated><category term='groovytools'/><category term='C#'/><category term='gpp'/><category term='builder'/><category term='hibernate'/><category term='objectgraphbuilder'/><category term='UPC-A'/><category term='vpp'/><category term='ant'/><category term='odp.net'/><category term='metabuilder'/><category term='java'/><category term='UPC-E'/><category term='groovy'/><category term='11g'/><category term='closure'/><category term='visual studio 2010'/><category term='EAN'/><category term='UPC'/><category term='10g'/><category term='odt'/><category term='xe'/><category term='oracle'/><category term='.NET'/><title type='text'>uncaught exceptions</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://uncaught-exceptions.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1768487440536086184/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://uncaught-exceptions.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>didge</name><uri>http://www.blogger.com/profile/12317395457536633312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>6</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1768487440536086184.post-283671360571194661</id><published>2011-02-05T21:33:00.000-08:00</published><updated>2011-02-05T21:41:14.095-08:00</updated><title type='text'>Office Remodel</title><content type='html'>You know how one house project turns into another?  Anyway, long story short, I've been cleaning up old sci-fi books from my office and put a package of some really great ones to give to some friends.  I hate letting these go, but I know they will be going to good homes.  Hopefully, this will help me remember them because someday I'm going to make a list of my favorite sci-fi novels and these should be on there:&lt;br /&gt;&lt;br /&gt;Richard Morgan, Broken Angels, Altered Carbon (I got to get his other one now, Woken Furies)&lt;br /&gt;&lt;br /&gt;Alstair Reynolds, Diamond Dogs, Redemption Ark, Revelation Space (Need to get Chasm City)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1768487440536086184-283671360571194661?l=uncaught-exceptions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://uncaught-exceptions.blogspot.com/feeds/283671360571194661/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1768487440536086184&amp;postID=283671360571194661' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1768487440536086184/posts/default/283671360571194661'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1768487440536086184/posts/default/283671360571194661'/><link rel='alternate' type='text/html' href='http://uncaught-exceptions.blogspot.com/2011/02/office-remodel.html' title='Office Remodel'/><author><name>didge</name><uri>http://www.blogger.com/profile/12317395457536633312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1768487440536086184.post-7569674326806918659</id><published>2011-01-19T11:45:00.000-08:00</published><updated>2011-01-19T11:52:42.918-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='odt'/><category scheme='http://www.blogger.com/atom/ns#' term='11g'/><category scheme='http://www.blogger.com/atom/ns#' term='odp.net'/><category scheme='http://www.blogger.com/atom/ns#' term='xe'/><category scheme='http://www.blogger.com/atom/ns#' term='10g'/><category scheme='http://www.blogger.com/atom/ns#' term='visual studio 2010'/><category scheme='http://www.blogger.com/atom/ns#' term='oracle'/><title type='text'>Visual Studio 2010, Oracle 11g Client and XE 10g</title><content type='html'>Oracle's byzantine methods for configuration drive me up the wall.  I struggled for 2.5 days trying to get their 11g development tools (ODT and ODP.NET) to work with Visual Studio 2010 and an already installed Oracle XE (10g).&lt;br /&gt;&lt;br /&gt;The major issue was that the Universal Installer appeared to be loading the GAC with assemblies for version 2.112.2.0, but configured Visual Studio in the registry and machine.config files to use 4.112.2.0!  &lt;br /&gt;&lt;br /&gt;The final solution was to remove all Oracle assemblies from the GAC.  After that, things started working, just needed to make sure ORACLE_HOME and PATH were configured appropriately, too.  Hope that helps someone else!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1768487440536086184-7569674326806918659?l=uncaught-exceptions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://uncaught-exceptions.blogspot.com/feeds/7569674326806918659/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1768487440536086184&amp;postID=7569674326806918659' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1768487440536086184/posts/default/7569674326806918659'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1768487440536086184/posts/default/7569674326806918659'/><link rel='alternate' type='text/html' href='http://uncaught-exceptions.blogspot.com/2011/01/visual-studio-2010-oracle-11g-client.html' title='Visual Studio 2010, Oracle 11g Client and XE 10g'/><author><name>didge</name><uri>http://www.blogger.com/profile/12317395457536633312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1768487440536086184.post-2203453074801184002</id><published>2008-10-22T23:07:00.000-07:00</published><updated>2008-11-06T12:03:52.941-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='hibernate'/><category scheme='http://www.blogger.com/atom/ns#' term='groovytools'/><category scheme='http://www.blogger.com/atom/ns#' term='metabuilder'/><category scheme='http://www.blogger.com/atom/ns#' term='closure'/><category scheme='http://www.blogger.com/atom/ns#' term='objectgraphbuilder'/><category scheme='http://www.blogger.com/atom/ns#' term='builder'/><category scheme='http://www.blogger.com/atom/ns#' term='groovy'/><title type='text'>UPDATED: Re-visiting MetaBuilder</title><content type='html'>I previously blogged about a new feature of &lt;a href="http://groovytools.sourceforge.net/builder"&gt;MetaBuilder&lt;/a&gt; that I'm working on allows you to visit each object, as they are built, using a closure.  I've updated the functionality so that the build visitor closure is given a &lt;code&gt;CreateNodeEvent&lt;/code&gt; instance for each constructed node as follows:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;public class CreateNodeEvent {&lt;br /&gt; def name&lt;br /&gt; def node&lt;br /&gt; def parent&lt;br /&gt; def isRoot // set to true, if the new node is a root node&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;If not a root node, the closure should return the node, or possibly a different node, when it is done.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Using a Build Visitor to Build a List of Root Nodes&lt;br /&gt;&lt;/span&gt;An example closure that builds a list of all root nodes might be:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;{ if(isRoot) { myList &lt;&lt; it.node }; it.node }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;In fact, I thought that usage might be so common that I included another set of &lt;code&gt;buildList&lt;/code&gt; methods that returns a list of root nodes for you.&lt;br /&gt;&lt;br /&gt;I'd also thought about exposing the &lt;code&gt;ObjectGraphBuilder.postNodeCompletion()&lt;/code&gt; method, but it doesn't give you the node name, which is sometimes useful to have.  It also doesn't tell you whether you're dealing with a root node (though you can probably derive that from the fact that &lt;code&gt;parent == null&lt;/code&gt; for a root node.)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Using a Build Visitor to Build a Map of Root Nodes&lt;br /&gt;&lt;/span&gt;Here's another build visitor example: say I have classes &lt;code&gt;Order&lt;/code&gt; and &lt;code&gt;OrderLine&lt;/code&gt; as follows and I want to use MetaBuilder to read &lt;code&gt;Orders&lt;/code&gt; from a file into a map called &lt;code&gt;orders&lt;/code&gt;, keyed on &lt;code&gt;id&lt;/code&gt;:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;class OrderLine {&lt;br /&gt;   def upc&lt;br /&gt;   def qty&lt;br /&gt;   def price&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;class Order {&lt;br /&gt;   def id&lt;br /&gt;   def lines = []&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;MetaBuilder mb = new MetaBuilder(getClass().getClassLoader())&lt;br /&gt;mb.define {&lt;br /&gt;   order(factory: Order) {&lt;br /&gt;       properties {&lt;br /&gt;           id(req: true)&lt;br /&gt;       }&lt;br /&gt;       collections {&lt;br /&gt;           lines {&lt;br /&gt;               line (factory: OrderLine) {&lt;br /&gt;                   properties {&lt;br /&gt;                       upc(req: true)&lt;br /&gt;                       qty(req: true)&lt;br /&gt;                       price(req: true)&lt;br /&gt;                   }&lt;br /&gt;               }&lt;br /&gt;           }&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;def orders = [:]&lt;br /&gt;mb.build( { if(it.isRoot) { orders[it.node.id] = it.node }; it.node }, new File("orders.mb").toURL() )&lt;br /&gt;&lt;/pre&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;A Hibernate Example&lt;/span&gt;&lt;br /&gt;Andres Almiray's &lt;a href="http://www.jroller.com/aalmiray/entry/objectgraphbuilder_s_new_tricks"&gt;recent blog post&lt;/a&gt; on using &lt;code&gt;ObjectGraphBuilder&lt;/code&gt; to create Grails fixtures inspired this next example, which extends the previous&lt;br /&gt;example to insert each object into a database using Hibernate:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Session session = HibernateUtil.getSessionFactory().getCurrentSession();&lt;br /&gt;&lt;br /&gt;session.beginTransaction()&lt;br /&gt;&lt;br /&gt;mb.build( { if(it.isRoot) { session.save(it.node) }; it.node }, new File("orders.mb").toURL() )&lt;br /&gt;&lt;br /&gt;session.getTransaction().commit()&lt;br /&gt;&lt;/pre&gt;&lt;span style="font-weight: bold;font-size:130%;" &gt;Final Thoughts&lt;/span&gt;&lt;br /&gt;One of the benefits of this feature is that it enables you to process large numbers of build objects without having to incur the overhead of building a list to contain them all.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1768487440536086184-2203453074801184002?l=uncaught-exceptions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://uncaught-exceptions.blogspot.com/feeds/2203453074801184002/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1768487440536086184&amp;postID=2203453074801184002' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1768487440536086184/posts/default/2203453074801184002'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1768487440536086184/posts/default/2203453074801184002'/><link rel='alternate' type='text/html' href='http://uncaught-exceptions.blogspot.com/2008/10/re-visiting-metabuilder.html' title='UPDATED: Re-visiting MetaBuilder'/><author><name>didge</name><uri>http://www.blogger.com/profile/12317395457536633312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1768487440536086184.post-8006948397445687095</id><published>2008-10-15T16:50:00.000-07:00</published><updated>2008-10-15T17:24:10.202-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='UPC-A'/><category scheme='http://www.blogger.com/atom/ns#' term='EAN'/><category scheme='http://www.blogger.com/atom/ns#' term='.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='UPC'/><category scheme='http://www.blogger.com/atom/ns#' term='UPC-E'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><title type='text'>Expanding barcode scans into EANs</title><content type='html'>I recently had a project where I had to use a barcode scanner to make scans of numbers that were possibly smaller than the 13 digit EAN standard.  I had to then check these against the same number in a list, but the numbers in the list had been expanded to 13 digits using the algorithm below:&lt;br /&gt;&lt;br /&gt;If the scanned number has 13 or more digits, return it.&lt;br /&gt;If the scanned number has 12 digits, prepend a zero and return the result.&lt;br /&gt;&lt;br /&gt;If the scanned number had 6 digits, treat it as a Zero Compressed UPC-E, expand it 11 digits using the following table and continue:&lt;br /&gt;&lt;br /&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th&gt;Last digit&lt;/th&gt; &lt;th&gt;UPC-E equivalent is&lt;/th&gt; &lt;th&gt;UPC-A equivalent is&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;XXNNN0&lt;/td&gt; &lt;td&gt;0XX000-00NNN + check&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;XXNNN1&lt;/td&gt; &lt;td&gt;0XX100-00NNN + check&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;2&lt;/td&gt; &lt;td&gt;XXNNN2&lt;/td&gt; &lt;td&gt;0XX200-00NNN + check&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;3&lt;/td&gt; &lt;td&gt;XXXNN3&lt;/td&gt; &lt;td&gt;0XXX00-000NN + check&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;4&lt;/td&gt; &lt;td&gt;XXXXN4&lt;/td&gt; &lt;td&gt;0XXXX0-0000N + check&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;5&lt;/td&gt; &lt;td&gt;XXXXX5&lt;/td&gt; &lt;td&gt;0XXXXX-00005 + check&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;6&lt;/td&gt; &lt;td&gt;XXXXX6&lt;/td&gt; &lt;td&gt;0XXXXX-00006 + check&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;7&lt;/td&gt; &lt;td&gt;XXXXX7&lt;/td&gt; &lt;td&gt;0XXXXX-00007 + check&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;8&lt;/td&gt; &lt;td&gt;XXXXX8&lt;/td&gt; &lt;td&gt;0XXXXX-00008 + check&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;9&lt;/td&gt; &lt;td&gt;XXXXX9&lt;/td&gt; &lt;td&gt;0XXXXX-00009 + check&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;If the number (as scanned or expanded) has less than 12 digits, left pad it to 12 digits using zeros, add a check digit, and return the result.&lt;br /&gt;&lt;br /&gt;The check digit is computed as follows:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Sum the digits in all odd positions, and multiply the result by 3.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Sum the digits in all even positions.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Sum the totals calculated in steps 2 and 3.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;The check digit is 10 - (sum_of_totals % 10)&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;Here is my C# program that I used to work this out:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Text;&lt;br /&gt;&lt;br /&gt;namespace ConsoleApplication1 {&lt;br /&gt;    class Program {&lt;br /&gt;        protected static int[][] upcPartialChecksumDigit = new int[][]{ &lt;br /&gt;            new int[] { 0 * 1, 1 * 1, 2 * 1, 3 * 1, 4 * 1, 5 * 1, 6 * 1, 7 * 1, 8 * 1, 9 * 1 }, // 0&lt;br /&gt;            new int[] { 0 * 3, 1 * 3, 2 * 3, 3 * 3, 4 * 3, 5 * 3, 6 * 3, 7 * 3, 8 * 3, 9 * 3 }, // 1&lt;br /&gt;            new int[] { 0 * 1, 1 * 1, 2 * 1, 3 * 1, 4 * 1, 5 * 1, 6 * 1, 7 * 1, 8 * 1, 9 * 1 }, // 2&lt;br /&gt;            new int[] { 0 * 3, 1 * 3, 2 * 3, 3 * 3, 4 * 3, 5 * 3, 6 * 3, 7 * 3, 8 * 3, 9 * 3 }, // 3&lt;br /&gt;            new int[] { 0 * 1, 1 * 1, 2 * 1, 3 * 1, 4 * 1, 5 * 1, 6 * 1, 7 * 1, 8 * 1, 9 * 1 }, // 4&lt;br /&gt;            new int[] { 0 * 3, 1 * 3, 2 * 3, 3 * 3, 4 * 3, 5 * 3, 6 * 3, 7 * 3, 8 * 3, 9 * 3 }, // 5&lt;br /&gt;            new int[] { 0 * 1, 1 * 1, 2 * 1, 3 * 1, 4 * 1, 5 * 1, 6 * 1, 7 * 1, 8 * 1, 9 * 1 }, // 6&lt;br /&gt;            new int[] { 0 * 3, 1 * 3, 2 * 3, 3 * 3, 4 * 3, 5 * 3, 6 * 3, 7 * 3, 8 * 3, 9 * 3 }, // 7&lt;br /&gt;            new int[] { 0 * 1, 1 * 1, 2 * 1, 3 * 1, 4 * 1, 5 * 1, 6 * 1, 7 * 1, 8 * 1, 9 * 1 }, // 8&lt;br /&gt;            new int[] { 0 * 3, 1 * 3, 2 * 3, 3 * 3, 4 * 3, 5 * 3, 6 * 3, 7 * 3, 8 * 3, 9 * 3 }, // 9&lt;br /&gt;            new int[] { 0 * 1, 1 * 1, 2 * 1, 3 * 1, 4 * 1, 5 * 1, 6 * 1, 7 * 1, 8 * 1, 9 * 1 }, // 10&lt;br /&gt;            new int[] { 0 * 3, 1 * 3, 2 * 3, 3 * 3, 4 * 3, 5 * 3, 6 * 3, 7 * 3, 8 * 3, 9 * 3 }  // 11&lt;br /&gt;        };&lt;br /&gt;&lt;br /&gt;        /*&lt;br /&gt;        Note 6 digit UPC-E codes are expanded to 12 digit UPC-A codesas follows:&lt;br /&gt;        0  XXNNN0  00XX000-00NNN + check&lt;br /&gt;        1  XXNNN1  00XX100-00NNN + check&lt;br /&gt;        2  XXNNN2  00XX200-00NNN + check&lt;br /&gt;        3  XXXNN3  00XXX00-000NN + check&lt;br /&gt;        4  XXXXN4  00XXXX0-0000N + check&lt;br /&gt;        5  XXXXX5  00XXXXX-00005 + check&lt;br /&gt;        6  XXXXX6  00XXXXX-00006 + check&lt;br /&gt;        7  XXXXX7  00XXXXX-00007 + check&lt;br /&gt;        8  XXXXX8  00XXXXX-00008 + check&lt;br /&gt;        9  XXXXX9  00XXXXX-00009 + check&lt;br /&gt;        */&lt;br /&gt;        public static string getUPC(string id) {&lt;br /&gt;            if (id == null) return null;&lt;br /&gt;&lt;br /&gt;            StringBuilder s = new StringBuilder("0", 11);&lt;br /&gt;            if (id.Length == 6) {&lt;br /&gt;                switch (id[5] - '0') {&lt;br /&gt;                    case 0:&lt;br /&gt;                        id = s.Append(id[0]).Append(id[1]).Append("00000").Append(id[2]).Append(id[3]).Append(id[4]).ToString();&lt;br /&gt;                        break;&lt;br /&gt;                    case 1:&lt;br /&gt;                        id = s.Append(id[0]).Append(id[1]).Append("10000").Append(id[2]).Append(id[3]).Append(id[4]).ToString();&lt;br /&gt;                        break;&lt;br /&gt;                    case 2:&lt;br /&gt;                        id = s.Append(id[0]).Append(id[1]).Append("20000").Append(id[2]).Append(id[3]).Append(id[4]).ToString();&lt;br /&gt;                        break;&lt;br /&gt;                    case 3:&lt;br /&gt;                        id = s.Append(id[0]).Append(id[1]).Append(id[2]).Append("00000").Append(id[3]).Append(id[4]).ToString();&lt;br /&gt;                        break;&lt;br /&gt;                    case 4:&lt;br /&gt;                        id = s.Append(id[0]).Append(id[1]).Append(id[2]).Append(id[3]).Append("00000").Append(id[4]).ToString();&lt;br /&gt;                        break;&lt;br /&gt;                    case 5:&lt;br /&gt;                        id = s.Append(id[0]).Append(id[1]).Append(id[2]).Append(id[3]).Append(id[4]).Append("00005").ToString();&lt;br /&gt;                        break;&lt;br /&gt;                    case 6:&lt;br /&gt;                        id = s.Append(id[0]).Append(id[1]).Append(id[2]).Append(id[3]).Append(id[4]).Append("00006").ToString();&lt;br /&gt;                        break;&lt;br /&gt;                    case 7:&lt;br /&gt;                        id = s.Append(id[0]).Append(id[1]).Append(id[2]).Append(id[3]).Append(id[4]).Append("00007").ToString();&lt;br /&gt;                        break;&lt;br /&gt;                    case 8:&lt;br /&gt;                        id = s.Append(id[0]).Append(id[1]).Append(id[2]).Append(id[3]).Append(id[4]).Append("00008").ToString();&lt;br /&gt;                        break;&lt;br /&gt;                    case 9:&lt;br /&gt;                        id = s.Append(id[0]).Append(id[1]).Append(id[2]).Append(id[3]).Append(id[4]).Append("00009").ToString();&lt;br /&gt;                        break;&lt;br /&gt;                    default:&lt;br /&gt;                        return null;&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;            if (id.Length &lt; 12) {&lt;br /&gt;                id = id.PadLeft(12, '0');&lt;br /&gt;                int checksum = 0;&lt;br /&gt;                for (int i = 0; i &lt; 12; i++) { //should get unrolled by compiler hopefully&lt;br /&gt;                    int c = id[i] - '0';&lt;br /&gt;                    if (c &lt; 0 || c &gt; 9) return null;&lt;br /&gt;                    int partial = upcPartialChecksumDigit[i][c];&lt;br /&gt;                    checksum += partial;&lt;br /&gt;                }&lt;br /&gt;                char checksumDigit = (char)((10 - (checksum % 10)) + '0');&lt;br /&gt;                id += checksumDigit;&lt;br /&gt;            }&lt;br /&gt;            else if (id.Length == 12) {&lt;br /&gt;                id = '0' + id;&lt;br /&gt;            }&lt;br /&gt;            return id;&lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        static void Main(string[] args) {&lt;br /&gt;            string s = ConvertUPC("654321");&lt;br /&gt;            Console.WriteLine();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public static String ConvertUPC(string arg) {&lt;br /&gt;            return arg + " -&gt; " + getUPC(arg);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1768487440536086184-8006948397445687095?l=uncaught-exceptions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://uncaught-exceptions.blogspot.com/feeds/8006948397445687095/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1768487440536086184&amp;postID=8006948397445687095' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1768487440536086184/posts/default/8006948397445687095'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1768487440536086184/posts/default/8006948397445687095'/><link rel='alternate' type='text/html' href='http://uncaught-exceptions.blogspot.com/2008/10/expanding-barcode-scans-into-eans.html' title='Expanding barcode scans into EANs'/><author><name>didge</name><uri>http://www.blogger.com/profile/12317395457536633312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1768487440536086184.post-8501975679312082527</id><published>2008-09-05T11:33:00.000-07:00</published><updated>2008-09-05T14:09:56.413-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='groovytools'/><category scheme='http://www.blogger.com/atom/ns#' term='metabuilder'/><category scheme='http://www.blogger.com/atom/ns#' term='builder'/><category scheme='http://www.blogger.com/atom/ns#' term='groovy'/><title type='text'>Catching up!</title><content type='html'>A lot has happened since my last post: a vacation in France, the start of a new school year for the kids and the first release of a new Groovy utility that I've been working on, &lt;a href="http://groovytools.sourceforge.net/builder"&gt;MetaBuilder&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;MetaBuilder offers a number of features that make creating and using new builders safer and easier.  First and foremost, it lets you specify your builder using a simple build language with lots of functionality to validate and control how objects are built.&lt;br /&gt;&lt;br /&gt;Here's a Groovy script example to give you the flavor of it:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;import groovytools.builder.*&lt;br /&gt;&lt;br /&gt;MetaBuilder mb = new MetaBuilder()&lt;br /&gt;&lt;br /&gt;mb.define {&lt;br /&gt; customer {&lt;br /&gt;   properties {&lt;br /&gt;     name(req: true)&lt;br /&gt;     age(check: 1..120)&lt;br /&gt;     sex(check: ~/M|F/)&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;def aCustomer = mb.build {&lt;br /&gt; customer(name: 'J. Doe', age: 25, sex: 'M')&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;If you manage to mistype a property name or violate a check constraint, MetaBuilder will throw an exception.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1768487440536086184-8501975679312082527?l=uncaught-exceptions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://uncaught-exceptions.blogspot.com/feeds/8501975679312082527/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1768487440536086184&amp;postID=8501975679312082527' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1768487440536086184/posts/default/8501975679312082527'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1768487440536086184/posts/default/8501975679312082527'/><link rel='alternate' type='text/html' href='http://uncaught-exceptions.blogspot.com/2008/09/catching-up.html' title='Catching up!'/><author><name>didge</name><uri>http://www.blogger.com/profile/12317395457536633312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1768487440536086184.post-5106446386344946413</id><published>2008-07-09T12:42:00.000-07:00</published><updated>2008-07-09T16:07:11.228-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='groovytools'/><category scheme='http://www.blogger.com/atom/ns#' term='gpp'/><category scheme='http://www.blogger.com/atom/ns#' term='vpp'/><category scheme='http://www.blogger.com/atom/ns#' term='ant'/><category scheme='http://www.blogger.com/atom/ns#' term='groovy'/><title type='text'>Introducing: 'uncaught exceptions'</title><content type='html'>Welcome to uncaught exceptions wherein I'll be sharing all sorts of things I come across  while developing software and some other things, too.&lt;br /&gt;&lt;br /&gt;I'm primarily a Java software developer, but I do a lot with Oracle and most recently, &lt;a href="http://groovy.codehaus.org/"&gt;Groovy&lt;/a&gt;.  (If you're a serious Java developer and you haven't seen Groovy yet, head on over there and check it out.)&lt;br /&gt;&lt;br /&gt;One of the things that I've been working on for fun is &lt;a href="http://sourceforge.net/projects/groovytools"&gt;groovytools&lt;/a&gt;, a collection of Groovy tools and experiments.  The first of which is &lt;a href="http://groovytools.sourceforge.net/ant/gpp"&gt;GPP&lt;/a&gt;, a Groovy port of &lt;a href="http://vpp.sourceforge.net/"&gt;VPP&lt;/a&gt;, which is an &lt;a href="http://ant.apache.org/"&gt;Ant&lt;/a&gt; and &lt;a href="http://velocity.apache.org/"&gt;Velocity&lt;/a&gt;-based preprocessor.  Either GPP or VPP can be a useful for code generation, mail-merge and numerous other template-based tasks.  In general, I find Groovy much more convenient and less quirky to use than the venerable Velocity.  In fact, the port to Groovy was extremely smooth and since then I haven't used Velocity again.&lt;br /&gt;&lt;br /&gt;My advice to all programmers just getting started:&lt;br /&gt;&lt;blockquote&gt;&lt;pre&gt;while(true) {&lt;br /&gt;  try { ... }&lt;br /&gt;  catch (Exception e) { ... }&lt;br /&gt;}&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;For everyone else, never give up, just keep trying!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1768487440536086184-5106446386344946413?l=uncaught-exceptions.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://uncaught-exceptions.blogspot.com/feeds/5106446386344946413/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1768487440536086184&amp;postID=5106446386344946413' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1768487440536086184/posts/default/5106446386344946413'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1768487440536086184/posts/default/5106446386344946413'/><link rel='alternate' type='text/html' href='http://uncaught-exceptions.blogspot.com/2008/07/introducing-uncaught-exceptions.html' title='Introducing: &apos;uncaught exceptions&apos;'/><author><name>didge</name><uri>http://www.blogger.com/profile/12317395457536633312</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
