<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:iweb="http://www.apple.com/iweb" version="2.0">
  <channel>
    <title>Projects that I’ve been involved with.</title>
    <link>http://www.david.koontz.name/home/Projects/Projects.html</link>
    <description>I’ve had the pleasure to work on a variety of projects in my career.  Here are some of the highlights of software &amp;amp; hardware projects I’ve been a part of in the past.</description>
    <generator>iWeb 3.0.1</generator>
    <item>
      <title>Mapping Engineering Practices to Agile Principles</title>
      <link>http://www.david.koontz.name/home/Projects/Entries/2011/10/8_Mapping_Engineering_Practices_to_Agile_Principles.html</link>
      <guid isPermaLink="false">b95ac8da-1240-45d2-a137-42dd9ca11d85</guid>
      <pubDate>Sat, 8 Oct 2011 11:27:36 +0200</pubDate>
      <description>&lt;a href=&quot;http://www.david.koontz.name/home/Projects/Entries/2011/10/8_Mapping_Engineering_Practices_to_Agile_Principles_files/IMG_2799.jpg&quot;&gt;&lt;img src=&quot;http://www.david.koontz.name/home/Projects/Media/object001_1.jpg&quot; style=&quot;float:left; padding-right:10px; padding-bottom:10px; width:425px; height:212px;&quot;/&gt;&lt;/a&gt;I’ve done this exercise a number of times with various organization in transition to some form of Agile - Scrum, XP, Kanban, etc.  It works well at the developer level and also at the executive level (although they don’t really understand the engineering practices as well as they want to appear to know them).&lt;br/&gt;&lt;br/&gt;&lt;a href=&quot;Entries/2011/10/8_Mapping_Engineering_Practices_to_Agile_Principles_files/Mapping%20Practices%20to%20Principles.pdf&quot;&gt;Mapping Practices to Principles.pdf&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;A quick facilitation guide is on the last page - it will help you facilitate this exercise with your group.&lt;br/&gt;&lt;br/&gt;</description>
      <enclosure url="http://www.david.koontz.name/home/Projects/Entries/2011/10/8_Mapping_Engineering_Practices_to_Agile_Principles_files/IMG_2799.jpg" length="117554" type="image/jpeg"/>
    </item>
    <item>
      <title>Definition of Done Exercise</title>
      <link>http://www.david.koontz.name/home/Projects/Entries/2011/10/1_Definition_of_Done_Exercise.html</link>
      <guid isPermaLink="false">8280f525-86a3-4da6-bb2f-4c9a3f991ace</guid>
      <pubDate>Sat, 1 Oct 2011 00:05:36 +0200</pubDate>
      <description>&lt;a href=&quot;http://www.david.koontz.name/home/Projects/Entries/2011/10/1_Definition_of_Done_Exercise_files/IMG_7460.jpg&quot;&gt;&lt;img src=&quot;http://www.david.koontz.name/home/Projects/Media/object008_1.jpg&quot; style=&quot;float:left; padding-right:10px; padding-bottom:10px; width:426px; height:299px;&quot;/&gt;&lt;/a&gt;Assuming you are on a Scrum/Agile software development team, then one of the first 'working agreements' you have created with your team is a 'Definition of Done' - right?&lt;br/&gt;Oh - you don't have a definition of what aspects a user story that is done will exhibit. Well then, you need to create a list of attributes of a done story. One way to do this would be to Google 'definition of done' ... here let me do that for you: &lt;a href=&quot;http://tinyurl.com/3br9o6n&quot;&gt;http://tinyurl.com/3br9o6n&lt;/a&gt;. Then you could just use someone else's definition - there DONE!&lt;br/&gt;But that would be cheating - right? It is not the artifact the list of done criteria that is important for your team - it is the act of doing it for themselves, it is that shared understanding of having a debate over some of the gray areas that create a true working agreement. If some of the team believes that a story being done means that there can be no bugs found in the code - but some believe that there can be some minor issues - well, then you have a great point to have a team discussion. Better at the beginning of the project, rather than right before the boss says 'ship it'. If you are having this dialogue (more than a debate/discussion - everyone is explaining their assumptions and exposing their values underlying their position in dialogue) then your team has entered the 2nd stage of team formation (Forming, Storming, Norming, Preforming) - congratulations! Now there is the second reason to create a definition of done - it moves the team along the continuum of strangers to team-mates.&lt;br/&gt;So rather than using someone else's list you want to create your own. Yes, sometimes you need a little water to prime the pump. Or you could get the energy flowing in the meeting with an exercise to get people out of their seats (you increase blood flow to the brain by 20% just by standing up) and up at the white board and interacting with each other. Try drawing a target (very large) - 3 concentric circles (or rectangles) on the board, label the inner most 'Now', the outer 'Later' and the middle 'Next'. That is a form of prioritization (now -&amp;amp;gt; next -&amp;amp;gt; later) that you want your team to become very familiar with (we use it in backlog ordering - right?). Then place stickies or index cards on the table and have someone write just one aspect of the definition of done on a card/sticky, then place it on the board in the proper location. Take turns, the next person may either - move the card to a 'better' location (now, next, later) or create a new card and post it. Play continues until we exhaust the fun in the game, or get good enough. You might want to dialogue on the aspect of growing your definition of done over time. One could easily imagine that done means something different in sprint one than it does for sprint 73 after four releases and lots of customer feedback, now that you have continuous deployment working.&lt;br/&gt;If you want some cheater index cards then use mine - they are no better than anyone else's answer to a team question, but these might get a reluctant team up and interacting in the game of collaboration.&lt;br/&gt;&lt;a href=&quot;Entries/2011/10/1_Definition_of_Done_Exercise_files/Definition%20of%20Done%20Exercise.pdf&quot;&gt;Definition of Done Exercise.pdf&lt;br/&gt;&lt;/a&gt;&lt;a href=&quot;Entries/2011/10/1_Definition_of_Done_Exercise_files/Definition%20of%20Ready%20Exercise.pdf&quot;&gt;Definition of Ready Exercise.pdf&lt;/a&gt;&lt;br/&gt;&lt;a href=&quot;Entries/2011/10/1_Definition_of_Done_Exercise_files/Definition%20of%20Done%20%26%20Definition%20of%20Ready%20Exercise%20-%20Facilitators%20Guide.pdf&quot;&gt;Definition of Done &amp;amp; Definition of Ready Exercise - Facilitators Guide.pdf&lt;/a&gt;&lt;br/&gt;</description>
      <enclosure url="http://www.david.koontz.name/home/Projects/Entries/2011/10/1_Definition_of_Done_Exercise_files/IMG_7460.jpg" length="172699" type="image/jpeg"/>
    </item>
    <item>
      <title>Pair Chess Game Exercise</title>
      <link>http://www.david.koontz.name/home/Projects/Entries/2011/2/19_Pair_Chess_Game_Exercise.html</link>
      <guid isPermaLink="false">765e7bd4-8f82-4b92-a3a2-c9387805e11d</guid>
      <pubDate>Sun, 20 Feb 2011 00:42:32 +0100</pubDate>
      <description>&lt;a href=&quot;http://www.david.koontz.name/home/Projects/Entries/2011/2/19_Pair_Chess_Game_Exercise_files/200419204-1.jpg&quot;&gt;&lt;img src=&quot;http://www.david.koontz.name/home/Projects/Media/object002_2.jpg&quot; style=&quot;float:left; padding-right:10px; padding-bottom:10px; width:425px; height:212px;&quot;/&gt;&lt;/a&gt;Some years ago I designed this exercise for a Pair Programming simulation using the media of the game of chess.  The idea was to have a pair on each side of the board, they would work together to finish a famous game against their opponents (a pair also).&lt;br/&gt;I never used the exercise because the developers I was working with didn't know the game of chess, and didn't seem interested in the simulation.   If you use this please let me know how it works out.&lt;br/&gt;&lt;br/&gt;Game 1 (after 31 ... Bxa2) Garry Kasparov (White) vs X3D Fritz Computer (Black) Man-Machine World Chess Championship 2003&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;Chess Game Pairing Exercise Instructor.PDF&lt;br/&gt; &lt;br/&gt;Download the PDF for more instructions.&lt;br/&gt;</description>
      <enclosure url="http://www.david.koontz.name/home/Projects/Entries/2011/2/19_Pair_Chess_Game_Exercise_files/200419204-1.jpg" length="61287" type="image/jpeg"/>
    </item>
    <item>
      <title>iTelephoto 100-400mm f/4.5-5.6 L IS Zoom Lens for iPhone</title>
      <link>http://www.david.koontz.name/home/Projects/Entries/2009/8/10_iTelephoto_100-400mm_f_4.5-5.6_L_IS_Zoom_Lens_for_iPhone.html</link>
      <guid isPermaLink="false">9059b3c2-e20a-444c-9aaf-837eaf5cb71a</guid>
      <pubDate>Tue, 11 Aug 2009 00:09:49 +0200</pubDate>
      <description>&lt;a href=&quot;http://www.david.koontz.name/home/Projects/Entries/2009/8/10_iTelephoto_100-400mm_f_4.5-5.6_L_IS_Zoom_Lens_for_iPhone_files/iPhone%20Telephoto%20Lens%202.jpg&quot;&gt;&lt;img src=&quot;http://www.david.koontz.name/home/Projects/Media/object019.jpg&quot; style=&quot;float:left; padding-right:10px; padding-bottom:10px; width:376px; height:268px;&quot;/&gt;&lt;/a&gt;I’ve been taking all my pictures with this new lens &amp;amp; camera combination for the iPhone.  The image quality is great from edge to edge and the telephoto zoom allows image reach from Illahee to Ketchikan.&lt;br/&gt;&lt;br/&gt;iDuct Systems EF mounting hardware&lt;br/&gt;&lt;br/&gt;The Canon 100 - 400 F IS zoom lens is mounted to the iPhone with iDuct Systems custom hardware ($8.97 at Ace Hardware).  &lt;br/&gt;&lt;br/&gt;&lt;br/&gt;Canon 100-400mm f/4.5-5.6L IS&lt;br/&gt;L-series super telephoto zoom lens equipped with an Image Stabilizer. The fluorite and Super UD-glass elements largely eliminate secondary spectrum. The floating system also ensures high picture quality at all focal lengths. The Image Stabilizer has two modes and it is compatible with Extenders 1.4x II and 2x II.&lt;br/&gt;&lt;br/&gt;</description>
      <enclosure url="http://www.david.koontz.name/home/Projects/Entries/2009/8/10_iTelephoto_100-400mm_f_4.5-5.6_L_IS_Zoom_Lens_for_iPhone_files/iPhone%20Telephoto%20Lens%202.jpg" length="66294" type="image/jpeg"/>
    </item>
    <item>
      <title>OverpunchFormat - Java class</title>
      <link>http://www.david.koontz.name/home/Projects/Entries/2008/4/13_OverpunchFormat_-_Java_class.html</link>
      <guid isPermaLink="false">152f9ae5-0679-402d-81e9-395e641f325b</guid>
      <pubDate>Mon, 14 Apr 2008 07:34:34 +0200</pubDate>
      <description>&lt;a href=&quot;http://www.david.koontz.name/home/Projects/Entries/2008/4/13_OverpunchFormat_-_Java_class_files/Fishing_break_2.jpg&quot;&gt;&lt;img src=&quot;http://www.david.koontz.name/home/Projects/Media/object020.png&quot; style=&quot;float:left; padding-right:10px; padding-bottom:10px; width:425px; height:212px;&quot;/&gt;&lt;/a&gt;OverpunchFormat is a subclass of DecimalFormat that formats decimal numbers into NSF Overpunch Format.&lt;br/&gt;The purpose of an Overpunch format is to encode the sign (+/-) into the least significant (right-most) digit via an encoding scheme. Also the values are typically dollar amounts, and therefore are integers representing cents (1/100 dollar). The use of DecimalFormat's setMultipler method will make quick work of this scaling. &lt;br/&gt;&lt;br/&gt;Get the Java source code for OverpunchFormat.java.&lt;br/&gt;&lt;br/&gt;OverpunchFormat is a subclass of DecimalFormat that formats decimal numbers into NSF Overpunch Format.&lt;br/&gt;&lt;br/&gt;The purpose of an Overpunch format is to encode the sign (+/-) into the least significant (right-most) digit via an encoding scheme. Also the values are typically dollar amounts, and therefore are integers representing cents (1/100 dollar). The use of DecimalFormat's setMultipler method will make quick work of this scaling. &lt;br/&gt;&lt;br/&gt;//package name.koontz.util;&lt;br/&gt;&lt;br/&gt;import java.io.Serializable;&lt;br/&gt;import java.text.NumberFormat;&lt;br/&gt;import java.text.ParsePosition;&lt;br/&gt;import java.text.FieldPosition;&lt;br/&gt;//import java.lang.Number;&lt;br/&gt;//import java.lang.StringBuffer;&lt;br/&gt;import java.text.*;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;/**&lt;br/&gt; * OverpunchFormat is a subclass of DecimalFormat that formats&lt;br/&gt; * decimal numbers into NSF Overpunch Format.&lt;br/&gt; * &amp;lt;p&gt;&lt;br/&gt; * The purpose of an Overpunch format is to encode the sign (+/-) into the&lt;br/&gt; * least significant (right-most) digit via an encoding scheme.  Also the values are&lt;br/&gt; * typically dollar amounts, and therefore are integers representing cents&lt;br/&gt; * (1/100 dollar). The use of the setMultipler method will make quick work of&lt;br/&gt; * this scaling.&lt;br/&gt; * &amp;lt;p&gt;&lt;br/&gt; * &amp;lt;Blockquote&gt;&lt;br/&gt; * &amp;lt;i&gt;&lt;br/&gt; * &amp;lt;b&gt;Holy hanging chad! Batman,&amp;lt;/b&gt; the bat computer has detected an&lt;br/&gt; * overpunched field, what could it mean?&lt;br/&gt; * &amp;lt;p&gt;&lt;br/&gt; * Well, Robin, it means the Joker has saved a byte in transmition cost, but it&lt;br/&gt; * will take the bat computer only 23 instructions to figure out what this sign&lt;br/&gt; * could be...&lt;br/&gt; * &amp;lt;/i&gt;&lt;br/&gt; * &amp;lt;/Blockquote&gt;&lt;br/&gt; * &amp;lt;p&gt;&lt;br/&gt; * &amp;lt;p&gt;&lt;br/&gt; * OverpunchFormat does not support locales, itself!  So do not expect Kanji&lt;br/&gt; * characters in your overpunched output.&lt;br/&gt; * &amp;lt;p&gt;&lt;br/&gt; *&lt;br/&gt; * &amp;lt;h3&gt;Overpunch Encoding&amp;lt;/h3&gt;&lt;br/&gt; * &amp;lt;pre&gt;&lt;br/&gt; *             Least&lt;br/&gt; *          Significant   Positive      Negative&lt;br/&gt; *             Digit     Overpunch     Overpunch&lt;br/&gt; *               0           {             }&lt;br/&gt; *               1           A             J&lt;br/&gt; *               2           B             K&lt;br/&gt; *               3           C             L&lt;br/&gt; *               4           D             M&lt;br/&gt; *               5           E             N&lt;br/&gt; *               6           F             O&lt;br/&gt; *               7           G             P&lt;br/&gt; *               8           H             Q&lt;br/&gt; *               9           J             R&lt;br/&gt; *&lt;br/&gt; * &amp;lt;/pre&gt;&lt;br/&gt; *&lt;br/&gt; * Example:&amp;lt;br&gt;&lt;br/&gt; * &amp;lt;blockquote&gt;&lt;br/&gt; * -1575  =&gt;  157N&amp;lt;br&gt;&lt;br/&gt; * +1200  =&gt;  120{&amp;lt;br&gt;&lt;br/&gt; * &amp;lt;/blockquote&gt;&lt;br/&gt; * &amp;lt;p&gt;&lt;br/&gt; *&lt;br/&gt; * If OverpunchFormat.parse(String, ParsePosition) fails to parse a string, it&lt;br/&gt; * returns null, leaves the ParsePosition index unchanged, and sets the&lt;br/&gt; * ParsePosition error index.&lt;br/&gt; * &amp;lt;p&gt;&lt;br/&gt; * A OverpunchFormat pattern contains only a postive pattern (no negative subpattern).&lt;br/&gt; * Since the whole concept of an overpunched value is to&lt;br/&gt; * encode the sign within the last digit, there will be no negative subpattern.&lt;br/&gt; *&lt;br/&gt; * &amp;lt;p&gt;&lt;br/&gt; * Note:  DecimalFormat JVM 1.2.2 bugs Sun Bug Id 4322804, 4254220, 4243108&amp;lt;br&gt;&lt;br/&gt; *&lt;br/&gt; *&lt;br/&gt; * @see Format&lt;br/&gt; * @see NumberFormat&lt;br/&gt; * @see DecimalFormat&lt;br/&gt; * @see ParsePosition&lt;br/&gt; */&lt;br/&gt;public class OverpunchFormat extends java.text.DecimalFormat&lt;br/&gt;    implements Cloneable, Serializable  {&lt;br/&gt;&lt;br/&gt;    // array of overpunch replacement characters&lt;br/&gt;    private static final char[] positiveDigit = {'{', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I'};&lt;br/&gt;    //                          overpunch digit   0    1    2    3    4    5    6    7    8    9&lt;br/&gt;    private static final char[] negativeDigit = {'}', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R'};&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;    public OverpunchFormat() {&lt;br/&gt;        super();&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    public OverpunchFormat(String pattern) throws IllegalArgumentException  {&lt;br/&gt;        super(pattern);&lt;br/&gt;        //&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    /**&lt;br/&gt;     * Returns an instance of Number with a value matching the given string.&lt;br/&gt;     *&lt;br/&gt;     *&lt;br/&gt;     * @param text                the string to be parsed&lt;br/&gt;     * @param parsePosition       on entry, where to begin parsing; on exit, just past the last parsed character. If parsing fails, the index will not move and the error index will be set.&lt;br/&gt;     * @return                    the parsed value, or null if the parse fails&lt;br/&gt;     */&lt;br/&gt;    public Number parse(String text, ParsePosition parsePosition) {&lt;br/&gt;        //&lt;br/&gt;        int sign = 1;  // or -1 if negative&lt;br/&gt;        char lastDigit;&lt;br/&gt;        char overpunchChar = '{';&lt;br/&gt;        int overpunchIndex = 0;&lt;br/&gt;&lt;br/&gt;        // start at the parsePosition within text - look for a non-numeric char&lt;br/&gt;        // that's the overpunch char&lt;br/&gt;        if ( parsePosition.getIndex() &amp;lt; text.length() ) {&lt;br/&gt;            for (int i = parsePosition.getIndex(); i &amp;lt; text.length(); i++) {&lt;br/&gt;                char c = text.charAt(i);&lt;br/&gt;                if ( Character.getType(c) == Character.DECIMAL_DIGIT_NUMBER ) {&lt;br/&gt;                    continue;&lt;br/&gt;                } else {&lt;br/&gt;                    // found first non digit char - that's the overpunch&lt;br/&gt;                    overpunchChar = c;&lt;br/&gt;                    overpunchIndex = i;&lt;br/&gt;                    break;&lt;br/&gt;                }&lt;br/&gt;            }&lt;br/&gt;        }&lt;br/&gt;&lt;br/&gt;        // reverse the overpunch&lt;br/&gt;&lt;br/&gt;        switch (overpunchChar) {&lt;br/&gt;        case  '}':&lt;br/&gt;             sign = -1;&lt;br/&gt;             lastDigit = '0';&lt;br/&gt;             break;&lt;br/&gt;        case  '{':&lt;br/&gt;             sign = 1;&lt;br/&gt;             lastDigit = '0';&lt;br/&gt;             break;&lt;br/&gt;        case  'A':&lt;br/&gt;             sign = 1;&lt;br/&gt;             lastDigit = '1';&lt;br/&gt;             break;&lt;br/&gt;        case  'B':&lt;br/&gt;             sign = 1;&lt;br/&gt;             lastDigit = '2';&lt;br/&gt;             break;&lt;br/&gt;        case  'C':&lt;br/&gt;             sign = 1;&lt;br/&gt;             lastDigit = '3';&lt;br/&gt;             break;&lt;br/&gt;        case  'D':&lt;br/&gt;             sign = 1;&lt;br/&gt;             lastDigit = '4';&lt;br/&gt;             break;&lt;br/&gt;        case  'E':&lt;br/&gt;             sign = 1;&lt;br/&gt;             lastDigit = '5';&lt;br/&gt;             break;&lt;br/&gt;        case  'F':&lt;br/&gt;             sign = 1;&lt;br/&gt;             lastDigit = '6';&lt;br/&gt;             break;&lt;br/&gt;        case  'G':&lt;br/&gt;             sign = 1;&lt;br/&gt;             lastDigit = '7';&lt;br/&gt;             break;&lt;br/&gt;        case  'H':&lt;br/&gt;             sign = 1;&lt;br/&gt;             lastDigit = '8';&lt;br/&gt;             break;&lt;br/&gt;        case  'I':&lt;br/&gt;             sign = 1;&lt;br/&gt;             lastDigit = '9';&lt;br/&gt;             break;&lt;br/&gt;        case  'J':&lt;br/&gt;             sign = -1;&lt;br/&gt;             lastDigit = '1';&lt;br/&gt;             break;&lt;br/&gt;        case  'K':&lt;br/&gt;             sign = -1;&lt;br/&gt;             lastDigit = '2';&lt;br/&gt;             break;&lt;br/&gt;        case  'L':&lt;br/&gt;             sign = -1;&lt;br/&gt;             lastDigit = '3';&lt;br/&gt;             break;&lt;br/&gt;        case  'M':&lt;br/&gt;             sign = -1;&lt;br/&gt;             lastDigit = '4';&lt;br/&gt;             break;&lt;br/&gt;        case  'N':&lt;br/&gt;             sign = -1;&lt;br/&gt;             lastDigit = '5';&lt;br/&gt;             break;&lt;br/&gt;        case  'O':&lt;br/&gt;             sign = -1;&lt;br/&gt;             lastDigit = '6';&lt;br/&gt;             break;&lt;br/&gt;        case  'P':&lt;br/&gt;             sign = -1;&lt;br/&gt;             lastDigit = '7';&lt;br/&gt;             break;&lt;br/&gt;        case  'Q':&lt;br/&gt;             sign = -1;&lt;br/&gt;             lastDigit = '8';&lt;br/&gt;             break;&lt;br/&gt;        case  'R':&lt;br/&gt;             sign = -1;&lt;br/&gt;             lastDigit = '9';&lt;br/&gt;             break;&lt;br/&gt;        default:&lt;br/&gt;             // not the overpunch char - error&lt;br/&gt;             parsePosition.setErrorIndex(overpunchIndex);&lt;br/&gt;             return null;  // error return null&lt;br/&gt;&lt;br/&gt;        }&lt;br/&gt;&lt;br/&gt;        // replace with the overpunch char in text with the digit&lt;br/&gt;        StringBuffer sb = new StringBuffer(text);&lt;br/&gt;&lt;br/&gt;        sb.setCharAt(overpunchIndex, lastDigit);&lt;br/&gt;&lt;br/&gt;        // now call the super's function&lt;br/&gt;        Number n = super.parse(sb.toString(), parsePosition);&lt;br/&gt;&lt;br/&gt;        if ( n instanceof Double ) {&lt;br/&gt;            double d = n.doubleValue();&lt;br/&gt;            d = d * sign;&lt;br/&gt;            n = new Double(d);&lt;br/&gt;        } else if ( n instanceof Long ) {&lt;br/&gt;            long l = n.longValue();&lt;br/&gt;            l = l * sign;&lt;br/&gt;            n = new Long(l);&lt;br/&gt;        } else {&lt;br/&gt;            ;  // nothing&lt;br/&gt;        }&lt;br/&gt;&lt;br/&gt;        return n;&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    /**&lt;br/&gt;     * Formats a long to produce a string.&lt;br/&gt;     *&lt;br/&gt;     * @param number               the long to format&lt;br/&gt;     * @param result               where the text is to be appended&lt;br/&gt;     * @param fieldPosition        On input: an alignment field, if desired. On output: the offsets of the alignment field.&lt;br/&gt;     * @return                     The value passed in as the result parameter&lt;br/&gt;     */&lt;br/&gt;    public StringBuffer format(long number, StringBuffer result, FieldPosition fieldPosition) {&lt;br/&gt;//System.out.println(&amp;quot;OverpunchFormat.format|long number&amp;quot;);&lt;br/&gt;//System.out.println(&amp;quot;OverpunchFormat.format( &amp;quot;+number+&amp;quot;, &amp;quot;+result.toString()+&amp;quot;, &amp;quot;+fieldPosition+&amp;quot; )&amp;quot;);&lt;br/&gt;        //&lt;br/&gt;        StringBuffer buf = new StringBuffer(result.length()+20);&lt;br/&gt;        long abs = Math.abs(number);          // get the absolute value&lt;br/&gt;//System.out.println(&amp;quot;    abs = &amp;quot;+abs);&lt;br/&gt;&lt;br/&gt;        // call DecmialFormat to format all but the overpunch&lt;br/&gt;        buf = super.format(abs, result, fieldPosition);&lt;br/&gt;//System.out.println(&amp;quot;    super.format() returns buf = &amp;quot; + buf.toString());&lt;br/&gt;        // now we must workout the overpunch&lt;br/&gt;        //&lt;br/&gt;        // get last digit of the string&lt;br/&gt;        char overpunchChar = buf.charAt(buf.length()-1);&lt;br/&gt;//System.out.println(&amp;quot;    buf.length()-1 = &amp;quot; + (buf.length()-1));&lt;br/&gt;//System.out.println(&amp;quot;    overpunchChar = &amp;quot; + overpunchChar);&lt;br/&gt;        // convert last digit to index into the overpunch (+/-) array&lt;br/&gt;        int overpunchIndex = Character.getNumericValue(overpunchChar);&lt;br/&gt;//System.out.println(&amp;quot;    overpunchIndex = &amp;quot; + overpunchIndex);&lt;br/&gt;        // get overpunch char&lt;br/&gt;        if ( number &amp;lt; 0 ) {&lt;br/&gt;            overpunchChar = negativeDigit[overpunchIndex];&lt;br/&gt;        } else {&lt;br/&gt;            overpunchChar = positiveDigit[overpunchIndex];&lt;br/&gt;        }&lt;br/&gt;//System.out.println(&amp;quot;    overpunchChar = &amp;quot; + overpunchChar);&lt;br/&gt;        // replace the lastChar in the string with new lastChar&lt;br/&gt;        buf.deleteCharAt(buf.length()-1);&lt;br/&gt;        buf.append(overpunchChar);&lt;br/&gt;//System.out.println(&amp;quot;    buf = &amp;quot; + buf.toString());&lt;br/&gt;&lt;br/&gt;        return buf;&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    /**&lt;br/&gt;     * Formats a double to produce a string.&lt;br/&gt;     *&lt;br/&gt;     * @param number               the double to format&lt;br/&gt;     * @param result               where the text is to be appended&lt;br/&gt;     * @param fieldPosition        On input: an alignment field, if desired. On output: the offsets of the alignment field.&lt;br/&gt;     * @return                     The value passed in as the result parameter&lt;br/&gt;     */&lt;br/&gt;    public StringBuffer format(double number, StringBuffer result, FieldPosition fieldPosition) {&lt;br/&gt;//System.out.println(&amp;quot;OverpunchFormat.format|double number&amp;quot;);&lt;br/&gt;//System.out.println(&amp;quot;OverpunchFormat.format( &amp;quot;+number+&amp;quot;, &amp;quot;+result.toString()+&amp;quot;, &amp;quot;+fieldPosition+&amp;quot; )&amp;quot;);&lt;br/&gt;        //&lt;br/&gt;        StringBuffer buf = new StringBuffer(result.length()+20);&lt;br/&gt;        double abs = Math.abs(number);          // get the absolute value&lt;br/&gt;//System.out.println(&amp;quot;    abs = &amp;quot;+abs);&lt;br/&gt;&lt;br/&gt;        // call DecmialFormat to format all but the overpunch&lt;br/&gt;        buf = super.format(abs, result, fieldPosition);&lt;br/&gt;//System.out.println(&amp;quot;    super.format() returns buf = &amp;quot; + buf.toString());&lt;br/&gt;&lt;br/&gt;        // now we must workout the overpunch&lt;br/&gt;        //&lt;br/&gt;        // get last digit of the string&lt;br/&gt;        char overpunchChar = buf.charAt(buf.length()-1);&lt;br/&gt;//System.out.println(&amp;quot;    buf.length()-1 = &amp;quot; + (buf.length()-1));&lt;br/&gt;//System.out.println(&amp;quot;    overpunchChar = &amp;quot; + overpunchChar);&lt;br/&gt;&lt;br/&gt;        // convert last digit to index into the overpunch (+/-) array&lt;br/&gt;        int overpunchIndex = Character.getNumericValue(overpunchChar);&lt;br/&gt;//System.out.println(&amp;quot;    overpunchIndex = &amp;quot; + overpunchIndex);&lt;br/&gt;&lt;br/&gt;        // get overpunch char&lt;br/&gt;        if ( number &amp;lt; 0 ) {&lt;br/&gt;            overpunchChar = negativeDigit[overpunchIndex];&lt;br/&gt;        } else {&lt;br/&gt;            overpunchChar = positiveDigit[overpunchIndex];&lt;br/&gt;        }&lt;br/&gt;//System.out.println(&amp;quot;    overpunchChar = &amp;quot; + overpunchChar);&lt;br/&gt;&lt;br/&gt;        // replace the lastChar in the string with new lastChar&lt;br/&gt;        buf.deleteCharAt(buf.length()-1);&lt;br/&gt;        buf.append(overpunchChar);&lt;br/&gt;//System.out.println(&amp;quot;    buf = &amp;quot; + buf.toString());&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;        return buf;&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;    /**&lt;br/&gt;     *  The main program for the class - a test method.&lt;br/&gt;     *&lt;br/&gt;     *@param  args  the text to parse&lt;br/&gt;     */&lt;br/&gt;    public static void main(String[] args) {&lt;br/&gt;&lt;br/&gt;        OverpunchFormat of = new OverpunchFormat();&lt;br/&gt;        of.applyPattern(&amp;quot;0000000&amp;quot;); // fixed field zero padded&lt;br/&gt;        of.setMultiplier(100);      // imply 2 decimal places&lt;br/&gt;&lt;br/&gt;        if (args.length &amp;lt; 2) {&lt;br/&gt;            System.out.println(&amp;quot;Usage: java OverpunchFormat 'pattern' 'value'&amp;quot;);&lt;br/&gt;            System.out.println(&amp;quot;Examples format():&amp;quot;);&lt;br/&gt;            System.out.println(&amp;quot;  9876      -&gt; &amp;quot; +of.format(9876l));&lt;br/&gt;            System.out.println(&amp;quot;    -1.35   -&gt; &amp;quot; +of.format(-1.35));&lt;br/&gt;            System.out.println(&amp;quot;      .2389 -&gt; &amp;quot; +of.format(0.2389));&lt;br/&gt;            System.out.println(&amp;quot;note; fixed field zero padding, implied decimal place, rounding and encoding&amp;quot;);&lt;br/&gt;&lt;br/&gt;            StringBuffer sb = new StringBuffer(&amp;quot;x=012345F dollars &amp;quot;);&lt;br/&gt;            ParsePosition pos = new ParsePosition(2);&lt;br/&gt;            System.out.println(&amp;quot;Examples parse():&amp;quot;);&lt;br/&gt;            System.out.println(&amp;quot;  before call:&amp;quot; + sb);&lt;br/&gt;            System.out.println(&amp;quot;  parse(sb, pos) where pos =&amp;quot; + pos);&lt;br/&gt;            System.out.println(&amp;quot;  parse returns a Number = &amp;quot; + of.parse(sb.toString(), pos));&lt;br/&gt;            System.out.println(&amp;quot;  and sets ParsePosition.index = &amp;quot; + pos.getIndex() + &amp;quot; &amp;amp; errorIndex = &amp;quot; + pos.getErrorIndex());&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;            System.exit(99);&lt;br/&gt;        } else {&lt;br/&gt;            StringBuffer sb = new StringBuffer(&amp;quot;OverpunchFormat of &amp;quot;+ args[1] +&amp;quot; is &amp;quot;);&lt;br/&gt;            of.applyPattern(args[0]);&lt;br/&gt;            of.format(Double.valueOf(args[1]), sb, new FieldPosition(NumberFormat.FRACTION_FIELD) );&lt;br/&gt;&lt;br/&gt;            System.out.println(sb.toString());&lt;br/&gt;&lt;br/&gt;        }&lt;br/&gt;&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;}</description>
      <enclosure url="http://www.david.koontz.name/home/Projects/Entries/2008/4/13_OverpunchFormat_-_Java_class_files/Fishing_break_2.jpg" length="207234" type="image/jpeg"/>
    </item>
    <item>
      <title>SequentialExtension - Java class</title>
      <link>http://www.david.koontz.name/home/Projects/Entries/2008/4/13_SequentialExtension_-_Java_class.html</link>
      <guid isPermaLink="false">734e3d21-fa30-4ea9-a77b-56dc22a9d2d7</guid>
      <pubDate>Mon, 14 Apr 2008 07:21:33 +0200</pubDate>
      <description>&lt;a href=&quot;http://www.david.koontz.name/home/Projects/Entries/2008/4/13_SequentialExtension_-_Java_class_files/Tracy_kayaking.jpg&quot;&gt;&lt;img src=&quot;http://www.david.koontz.name/home/Projects/Media/object021.png&quot; style=&quot;float:left; padding-right:10px; padding-bottom:10px; width:425px; height:212px;&quot;/&gt;&lt;/a&gt;SequentialExtension is a Java class to create filenames with a sequential extension. Given a directory with file.001, file.002, file.005; what is the next sequential filename? Either file.003 or file.006 - this utility class will return either java.io.File based on your desire for infix mode (file.003) or not (file.006).&lt;br/&gt;&lt;br/&gt;Get the Java source code for &lt;a href=&quot;Entries/2008/4/13_SequentialExtension_-_Java_class_files/SequentialExtension.java&quot;&gt;SequentialExtension.java.&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;A utility class for generating sequential file extensions.&lt;br/&gt;&lt;br/&gt;Assume a directory with:&lt;br/&gt;&lt;br/&gt;    |- file.name.001&lt;br/&gt;    |- file.name.002&lt;br/&gt;    |- file.name.005&lt;br/&gt;&lt;br/&gt;What is the next file name in the sequential set?&lt;br/&gt;file.name.006 or maybe file.name.003&lt;br/&gt;Depends on what you want to do.&lt;br/&gt;&lt;br/&gt;The method nextSequentialFile will generate a File object to meet either need. &lt;br/&gt;&lt;br/&gt;/*&lt;br/&gt; * Copyright (c) 2003 David A. Koontz&lt;br/&gt; * Licensed under the Open Software License version 2.0&lt;br/&gt; * &lt;a href=&quot;http://www.opensource.org/licenses/osl-2.0.php&quot;&gt;http://www.opensource.org/licenses/osl-2.0.php&lt;/a&gt;&lt;br/&gt; */&lt;br/&gt;&lt;br/&gt;import java.io.*;&lt;br/&gt;&lt;br/&gt;/**&lt;br/&gt; *  Utility class for generating sequential file extensions.&lt;br/&gt; *&lt;br/&gt; *&lt;br/&gt; *  Assume a directory with:&lt;br/&gt;&lt;br/&gt; * &lt;br/&gt; *     |- file.name.001&lt;br/&gt; *     |- file.name.002&lt;br/&gt; *     |- file.name.005&lt;br/&gt; * &lt;br/&gt; * What is the next file name in the sequential set?&lt;br/&gt;&lt;br/&gt; * file.name.006 or maybe file.name.003&lt;br/&gt;&lt;br/&gt; * Depends on what you want to do.&lt;br/&gt; *&lt;br/&gt; * The method nextSequentialFile will generate a&lt;br/&gt; * File object to meet either need.&lt;br/&gt; *&lt;br/&gt; * @author  David A. Koontz&lt;br/&gt; */&lt;br/&gt;&lt;br/&gt;public class SequentialExtension {&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;	/**&lt;br/&gt;	 * Finds the next file extension of a sequential extension.&lt;br/&gt;	 *&lt;br/&gt;	 * Given file.001, file.002, file.005 in a directory this&lt;br/&gt;	 * method will return file.003 when infix == true&lt;br/&gt;	 * or file.006 when infix == false.&lt;br/&gt;	 *&lt;br/&gt;	 * If baseName is null or empty string then every file within the&lt;br/&gt;	 * directory is considered within the sequential set.&lt;br/&gt;	 *&lt;br/&gt;	 * @param directory   the directory in which to search&lt;br/&gt;	 * @param baseName    the filename's base part&lt;br/&gt;	 * @param infix		  when true gaps in sequence will be infiled&lt;br/&gt;	 * @return            the File with the next sequential number&lt;br/&gt;     */&lt;br/&gt;	public File nextSequentialFile(File directory, String baseName, boolean infix) {&lt;br/&gt;		File seqFile = null;&lt;br/&gt;&lt;br/&gt;        if( (directory==null) || (!directory.isDirectory()) )&lt;br/&gt;               throw new IllegalArgumentException(&amp;quot;Invalid directory&amp;quot;);&lt;br/&gt;&lt;br/&gt;		if ( infix ) {&lt;br/&gt;			// start with *.000  or *.001&lt;br/&gt;			// int next = 1;  // if you want to start with *.001&lt;br/&gt;			// just for sanity we limit the sequence loop to *.999&lt;br/&gt;&lt;br/&gt;			for ( int next = 0; next &amp;lt; 1000; next++ ) {&lt;br/&gt;				// generate the next extension in sequential set&lt;br/&gt;				String numStr = makeNumericExtension(next);&lt;br/&gt;&lt;br/&gt;				seqFile = new File(directory, baseName + '.' + numStr);&lt;br/&gt;&lt;br/&gt;				if ( ! seqFile.exists() ) {&lt;br/&gt;					break;  // found a non-existant file name - break out of loop &amp;amp; return it&lt;br/&gt;				}&lt;br/&gt;			}&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;			if ( seqFile == null ) {&lt;br/&gt;				throw new UnsupportedOperationException(&amp;quot;All sequential files 000 - 999 exist for &amp;quot;+baseName+&amp;quot;!&amp;quot;);&lt;br/&gt;			}&lt;br/&gt;		} else {&lt;br/&gt;			// not inclusive - meaning generate extension at end of current set&lt;br/&gt;			// so file.001, file.002, file.005 results in file.006&lt;br/&gt;			int max = findMaxSequentialExtension(directory, baseName);&lt;br/&gt;			int next = max + 1;&lt;br/&gt;&lt;br/&gt;			// generate the next extension in sequential set&lt;br/&gt;			String numStr = makeNumericExtension(next);&lt;br/&gt;&lt;br/&gt;			seqFile = new File( directory, baseName + '.' + numStr );&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;		}&lt;br/&gt;&lt;br/&gt;		return seqFile;&lt;br/&gt;&lt;br/&gt;	}&lt;br/&gt;&lt;br/&gt;	/**&lt;br/&gt;	 *  Generate a three digit extension (zero padded).&lt;br/&gt;	 *&lt;br/&gt;	 *  Like: &amp;quot;003&amp;quot; or &amp;quot;023&amp;quot; (also &amp;quot;4321&amp;quot;).&lt;br/&gt;	 */&lt;br/&gt;	private static String makeNumericExtension(int number) {&lt;br/&gt;		String numStr = &amp;quot;&amp;quot; + number;&lt;br/&gt;		if ( numStr.length() == 1 )&lt;br/&gt;		   numStr = &amp;quot;00&amp;quot; + number;&lt;br/&gt;		else if ( numStr.length() == 2 )&lt;br/&gt;		   numStr = &amp;quot;0&amp;quot; + number;&lt;br/&gt;&lt;br/&gt;		return numStr;&lt;br/&gt;&lt;br/&gt;	}&lt;br/&gt;&lt;br/&gt;	/**&lt;br/&gt;	 * Finds the next file extension of a sequential extension.&lt;br/&gt;	 *&lt;br/&gt;	 * Given file.001, file.002, file.005 in a directory this&lt;br/&gt;	 * method will return file.003.&lt;br/&gt;	 *&lt;br/&gt;	 * If baseName is null or empty string then every file within the&lt;br/&gt;	 * directory is considered within the sequential set.&lt;br/&gt;	 *&lt;br/&gt;	 * @param directory   the directory in which to search&lt;br/&gt;	 * @param baseName    the filename's base part&lt;br/&gt;	 * @return            the File with the next sequential number&lt;br/&gt;     */&lt;br/&gt;	public File nextSequentialFile(File directory, String baseName) {&lt;br/&gt;        if( (directory==null) || (!directory.isDirectory()) )&lt;br/&gt;               throw new IllegalArgumentException(&amp;quot;Invalid directory&amp;quot;);&lt;br/&gt;        // start with *.000  or *.001&lt;br/&gt;        // int next = 1;  // if you want to start with *.001&lt;br/&gt;		// just for sanity we limit the sequence loop to *.999&lt;br/&gt;        File seqFile = null;&lt;br/&gt;&lt;br/&gt;        for ( int next = 0; next &amp;lt; 1000; next++ ) {&lt;br/&gt;			// generate the next extension in sequential set&lt;br/&gt;			String numStr = &amp;quot;&amp;quot; + next;&lt;br/&gt;			if ( numStr.length() == 1 )&lt;br/&gt;			   numStr = &amp;quot;00&amp;quot;+next;&lt;br/&gt;			else if ( numStr.length() == 2 )&lt;br/&gt;			   numStr = &amp;quot;0&amp;quot;+next;&lt;br/&gt;&lt;br/&gt;			seqFile = new File(directory, baseName + '.' + numStr);&lt;br/&gt;&lt;br/&gt;			if ( ! seqFile.exists() ) {&lt;br/&gt;				break;  // found a non-existant file name - break out of loop &amp;amp; return it&lt;br/&gt;			}&lt;br/&gt;		}&lt;br/&gt;&lt;br/&gt;		if ( seqFile == null ) {&lt;br/&gt;			throw new UnsupportedOperationException(&amp;quot;All sequential files 000 - 999 exist for &amp;quot;+baseName+&amp;quot;!&amp;quot;);&lt;br/&gt;		}&lt;br/&gt;&lt;br/&gt;		return seqFile;&lt;br/&gt;&lt;br/&gt;	}&lt;br/&gt;&lt;br/&gt;    /**&lt;br/&gt;     * Finds the max file extension of a sequential file.&lt;br/&gt;     *&lt;br/&gt;     * Given file.001, file.002, file.005 in a directory this&lt;br/&gt;     * method will return 5.&lt;br/&gt;     *&lt;br/&gt;     * Uses a FileFilter to search the directory if baseName is&lt;br/&gt;     * provided. If baseName is null or empty string then every&lt;br/&gt;     * file within the directory is considered within the sequential set.&lt;br/&gt;     *&lt;br/&gt;     * @param directory   the directory in which to search&lt;br/&gt;     * @param baseName    the filename's base part&lt;br/&gt;     * @return            the max sequential number&lt;br/&gt;     */&lt;br/&gt;    private int findMaxSequentialExtension(File directory, String baseName) {&lt;br/&gt;        if( (directory==null) || (!directory.isDirectory()) )&lt;br/&gt;               throw new IllegalArgumentException(&amp;quot;Invalid directory&amp;quot;);&lt;br/&gt;        // start with *.000&lt;br/&gt;        // int maxValue = 0;  // if you want to start with *.001&lt;br/&gt;        int maxValue = -1;&lt;br/&gt;        File[] files;&lt;br/&gt;        if ( baseName!=null &amp;amp;&amp;amp; baseName.length()&gt;0 ) {&lt;br/&gt;           files = directory.listFiles(new BaseNameFilter(baseName));&lt;br/&gt;        } else {&lt;br/&gt;           files = directory.listFiles();&lt;br/&gt;        }&lt;br/&gt;        for(int i=0; i &amp;lt; files.length; i++) {&lt;br/&gt;            // ignore directories &amp;amp; do not recurse into sub-dir&lt;br/&gt;            if(files[i].isFile()) {&lt;br/&gt;                String name = files[i].getName();&lt;br/&gt;                int dotIndex = name.lastIndexOf('.');&lt;br/&gt;                // if no dot lastIndexOf returns -1&lt;br/&gt;                // what about unix hidden (dot) files&lt;br/&gt;                if (dotIndex &gt; 0) {&lt;br/&gt;					// only if there is a basename&lt;br/&gt;					String ext = name.substring(dotIndex+1);&lt;br/&gt;&lt;br/&gt;					System.out.println( &amp;quot;found ext = &amp;quot; + ext );&lt;br/&gt;					try {&lt;br/&gt;						int num = Integer.parseInt(ext);&lt;br/&gt;						if ( num &gt; maxValue ) maxValue=num;&lt;br/&gt;					}catch(NumberFormatException nfe) {&lt;br/&gt;						; // ignore&lt;br/&gt;					}&lt;br/&gt;				}&lt;br/&gt;            }&lt;br/&gt;        }&lt;br/&gt;&lt;br/&gt;        return maxValue;&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;   /**&lt;br/&gt;    *  Strips path and extension from a filename.&lt;br/&gt;    *&lt;br/&gt;    */&lt;br/&gt;   public static String getBaseName( String name )&lt;br/&gt;   {&lt;br/&gt;      // strip path.&lt;br/&gt;      String base = new File( name ).getName();&lt;br/&gt;      // strip possible extension.&lt;br/&gt;      int index = base.lastIndexOf( '.' );&lt;br/&gt;      if( index != -1 )&lt;br/&gt;         base = base.substring( 0, index );&lt;br/&gt;&lt;br/&gt;      return base;&lt;br/&gt;   }&lt;br/&gt;&lt;br/&gt;   /**&lt;br/&gt;    *  Strips path and extension from a filename.&lt;br/&gt;    *&lt;br/&gt;    *  example: path/file.name.txt  -&gt;  file.name&lt;br/&gt;    *&lt;br/&gt;    * Note: define extension as the substring after the last dot.&lt;br/&gt;    *&lt;br/&gt;    */&lt;br/&gt;   public static String getBaseName( File name )&lt;br/&gt;   {&lt;br/&gt;      // strip path.&lt;br/&gt;      String base = name.getName();&lt;br/&gt;      // strip possible extension.&lt;br/&gt;      int index = base.lastIndexOf( '.' );&lt;br/&gt;      if( index != -1 )&lt;br/&gt;         base = base.substring( 0, index );&lt;br/&gt;&lt;br/&gt;      return base;&lt;br/&gt;   }&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;   /**&lt;br/&gt;    *  Strips path and base name from a filename.&lt;br/&gt;    *&lt;br/&gt;    *  example: path/file.txt  -&gt;  txt&lt;br/&gt;    *&lt;br/&gt;    * Note: define extension as the substring after the last dot.&lt;br/&gt;    *&lt;br/&gt;    * example: path/long.file.name.ext -&gt; ext&lt;br/&gt;    */&lt;br/&gt;   public static String getFileExtension( File file, boolean keepDot )&lt;br/&gt;   {&lt;br/&gt;      // strip path&lt;br/&gt;      String base = file.getName();&lt;br/&gt;	  // strip possible extension&lt;br/&gt;      String extension = &amp;quot;&amp;quot;;&lt;br/&gt;      int index = base.lastIndexOf( '.' );&lt;br/&gt;      if( index != -1 )&lt;br/&gt;      {&lt;br/&gt;         if( keepDot )&lt;br/&gt;            extension = base.substring( index );&lt;br/&gt;         else&lt;br/&gt;            extension = base.substring( index + 1 );&lt;br/&gt;      }&lt;br/&gt;      return extension;&lt;br/&gt;   }&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;    /**&lt;br/&gt;     * A Filter for filenames of a given base name.&lt;br/&gt;     *&lt;br/&gt;     * For use in File.listFiles&lt;br/&gt;&lt;br/&gt;     * &lt;br/&gt;     * File[] files = directory.listFiles(BaseNameFilter(&amp;quot;MyFile&amp;quot;));&lt;br/&gt;     * &lt;br/&gt;&lt;br/&gt;     * Would return MyFile.001, MyFile.002, MyFile.txt, etc.&lt;br/&gt;     */&lt;br/&gt;    class BaseNameFilter implements FileFilter {&lt;br/&gt;       // inner class&lt;br/&gt;       private String name;&lt;br/&gt;       BaseNameFilter(String baseName) {&lt;br/&gt;           name = baseName;&lt;br/&gt;       }&lt;br/&gt;       public boolean accept(File f) {&lt;br/&gt;           //&lt;br/&gt;           String bn = getBaseName(f.getName());&lt;br/&gt;           // is file system case sensitive? how would I know?&lt;br/&gt;           // shouldn't Java System know?&lt;br/&gt;           // if ( name.equalsIgnoreCase(bn) ) {&lt;br/&gt;           if ( name.equals(bn) ) {&lt;br/&gt;               return true;&lt;br/&gt;           }&lt;br/&gt;           return false;&lt;br/&gt;       }&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    /**&lt;br/&gt;     * A Filter for filenames of a given extension.&lt;br/&gt;     *&lt;br/&gt;     * For use in File.listFiles&lt;br/&gt;&lt;br/&gt;     * &lt;br/&gt;     * File[] files = directory.listFiles(ExtensionFilter(&amp;quot;txt&amp;quot;));&lt;br/&gt;     * &lt;br/&gt;&lt;br/&gt;     * Would return junk.txt, apple.txt, MyFile.txt, etc.&lt;br/&gt;     */&lt;br/&gt;    class ExtensionFilter implements FileFilter {&lt;br/&gt;       // inner class&lt;br/&gt;       private String name;&lt;br/&gt;       ExtensionFilter(String extension) {&lt;br/&gt;           name = extension;&lt;br/&gt;       }&lt;br/&gt;       public boolean accept(File f) {&lt;br/&gt;           //&lt;br/&gt;           String ext = getFileExtension(f, false);&lt;br/&gt;           // is file system case sensitive? how would I know?&lt;br/&gt;           // shouldn't Java System know?&lt;br/&gt;           // if ( name.equalsIgnoreCase(ext) ) {&lt;br/&gt;           if ( name.equals(ext) ) {&lt;br/&gt;               return true;&lt;br/&gt;           }&lt;br/&gt;           return false;&lt;br/&gt;       }&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;    /**&lt;br/&gt;     *  Unit testing the Filters &amp;amp; findMaxSequentialExtension()&lt;br/&gt;     */&lt;br/&gt;	public static void main( String[] args ) {&lt;br/&gt;&lt;br/&gt;		File nextFile = null;&lt;br/&gt;		String baseName = &amp;quot;file.name&amp;quot;;&lt;br/&gt;&lt;br/&gt;		SequentialExtension se = new SequentialExtension(&amp;quot;.&amp;quot;);&lt;br/&gt;&lt;br/&gt;		// generate the next extension (not infix) in sequential set&lt;br/&gt;&lt;br/&gt;		nextFile = se.nextSequentialFile(se.cwd, baseName, false);&lt;br/&gt;&lt;br/&gt;		try {&lt;br/&gt;			if ( nextFile.createNewFile() ) {&lt;br/&gt;				System.out.println(&amp;quot;Created &amp;quot; + nextFile.getName() );&lt;br/&gt;			} else {&lt;br/&gt;				System.out.println(&amp;quot;Failed to create &amp;quot; + nextFile.getName() );&lt;br/&gt;			}&lt;br/&gt;		} catch (IOException ex) {&lt;br/&gt;			System.out.println(&amp;quot;Failed&amp;quot; + ex);&lt;br/&gt;		}&lt;br/&gt;&lt;br/&gt;		// generate the infixed extension within a sequential set&lt;br/&gt;&lt;br/&gt;		nextFile = se.nextSequentialFile(se.cwd, baseName, true);&lt;br/&gt;		try {&lt;br/&gt;			if ( nextFile.createNewFile() ) {&lt;br/&gt;				System.out.println(&amp;quot;Created &amp;quot; + nextFile.getName() );&lt;br/&gt;			} else {&lt;br/&gt;				System.out.println(&amp;quot;Failed to create &amp;quot; + nextFile.getName() );&lt;br/&gt;			}&lt;br/&gt;		} catch (IOException ex) {&lt;br/&gt;			System.out.println(&amp;quot;Failed&amp;quot; + ex);&lt;br/&gt;		}&lt;br/&gt;&lt;br/&gt;		se.list(baseName);&lt;br/&gt;&lt;br/&gt;		/* This is program output after a few runs &amp;amp; deleting a few files&lt;br/&gt;		   Note the missing files (003 &amp;amp; 004).&lt;br/&gt;&lt;br/&gt;				found ext = 000&lt;br/&gt;				found ext = 001&lt;br/&gt;				found ext = 002&lt;br/&gt;				found ext = 005&lt;br/&gt;				found ext = 006&lt;br/&gt;				Created file.name.007&lt;br/&gt;				Created file.name.003&lt;br/&gt;				List of 'file.name' files:&lt;br/&gt;				   file.name.000&lt;br/&gt;				   file.name.001&lt;br/&gt;				   file.name.002&lt;br/&gt;				   file.name.005&lt;br/&gt;				   file.name.006&lt;br/&gt;				   file.name.007&lt;br/&gt;				   file.name.003&lt;br/&gt;&lt;br/&gt;		*/&lt;br/&gt;&lt;br/&gt;		se.list();&lt;br/&gt;	}&lt;br/&gt;&lt;br/&gt;	File cwd;&lt;br/&gt;&lt;br/&gt;	public SequentialExtension(String dir) {&lt;br/&gt;		cwd = new File(dir);&lt;br/&gt;	}&lt;br/&gt;&lt;br/&gt;	public void list(String basename) {&lt;br/&gt;		File[] files = cwd.listFiles(new BaseNameFilter(basename) );&lt;br/&gt;		System.out.println(&amp;quot;List of '&amp;quot; + basename + &amp;quot;' files:&amp;quot;);&lt;br/&gt;		for (int i = 0; i &amp;lt; files.length; i++) {&lt;br/&gt;			System.out.println(&amp;quot;   &amp;quot;+ files[i].getName() );&lt;br/&gt;		}&lt;br/&gt;	}&lt;br/&gt;	public void list() {&lt;br/&gt;		File[] files = cwd.listFiles( );&lt;br/&gt;		System.out.println(&amp;quot;List of files:&amp;quot;);&lt;br/&gt;		for (int i = 0; i &amp;lt; files.length; i++) {&lt;br/&gt;			System.out.println(&amp;quot;   &amp;quot;+ files[i].getName() );&lt;br/&gt;		}&lt;br/&gt;	}&lt;br/&gt;&lt;br/&gt;}&lt;br/&gt;&lt;br/&gt;/*&lt;br/&gt; * Copyright (c) 2003 David A. Koontz&lt;br/&gt; * Licensed under the Open Software License version 2.0&lt;br/&gt; * &lt;a href=&quot;http://www.opensource.org/licenses/osl-2.0.php&quot;&gt;http://www.opensource.org/licenses/osl-2.0.php&lt;/a&gt;&lt;br/&gt; */&lt;br/&gt;&lt;br/&gt;</description>
      <enclosure url="http://www.david.koontz.name/home/Projects/Entries/2008/4/13_SequentialExtension_-_Java_class_files/Tracy_kayaking.jpg" length="76572" type="image/jpeg"/>
    </item>
    <item>
      <title>TelephoneNumber - Java class</title>
      <link>http://www.david.koontz.name/home/Projects/Entries/2008/4/13_TelephoneNumber_-_Java_class.html</link>
      <guid isPermaLink="false">44462dd6-5577-4c6c-87ab-59bc02fc7714</guid>
      <pubDate>Mon, 14 Apr 2008 07:13:35 +0200</pubDate>
      <description>&lt;a href=&quot;http://www.david.koontz.name/home/Projects/Entries/2008/4/13_TelephoneNumber_-_Java_class_files/IMG0027.jpg&quot;&gt;&lt;img src=&quot;http://www.david.koontz.name/home/Projects/Media/object022.png&quot; style=&quot;float:left; padding-right:10px; padding-bottom:10px; width:425px; height:212px;&quot;/&gt;&lt;/a&gt;The TelephoneNumber class was designed to use the java.text.MessageFormat class to format a US phone number with the proper characters and spacing. The class excepts numbers any many different ways and parses them into it's internal data so that it can display the phone number in the standard way, i.e. (800) 555-1212. It can even accept an alpha number like &amp;quot;877 HOLY-COW&amp;quot; and with the right options format it as alpha or numbers.&lt;br/&gt;&lt;br/&gt; The &lt;a href=&quot;Entries/2008/4/13_TelephoneNumber_-_Java_class_files/TelephoneNumber.java&quot;&gt;TelephoneNumber&lt;/a&gt; class represents a US telephone number.&lt;br/&gt;&lt;br/&gt;This class contains many constructors for various uses. It then stores the telephone number internally in seperate codes (area code, exchange, etc.). This encourages use of the format method to output the telephone number in any style the programmer wishes.&lt;br/&gt;&lt;br/&gt;[needs i18n work]&lt;br/&gt;&lt;br/&gt;Example usage:&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;           long number = 8005551212L;&lt;br/&gt;           TelephoneNumber phone = new TelephoneNumber(number);&lt;br/&gt;           StringBuffer msg = new StringBuffer(&amp;quot;Call me at &amp;quot;);&lt;br/&gt;           msg.append(phone.format());&lt;br/&gt;           // msg is now &amp;quot;Call me at (800) 555-1212&amp;quot;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;US Format:&lt;br/&gt;The general US format is a 3 digit area code, a 3 digit exchange, a 4 digit station. Typically written (800) 555-1212. Area codes are concidered optional unless you live in a '10 digit' calling area as many people now do. In which case you may want to set the isTenDigitArea flag which removes the parenthesis from the String output ie Denver area code requires 10 digit dailing 303 555-1212.&lt;br/&gt;&lt;br/&gt;International Format:&lt;br/&gt;International phone numbers are often written in this format:&lt;br/&gt;+CC-(N)AAA-EEE-SSSS.&lt;br/&gt;This expresses the numbers used for both international and national long-distance calls. In the example, +CC indicates the country code, while (N) indicates the NDD. When dialing from outside the country, the NDD would not be used after dialing the country code; when dialing from within that country, the NDD would be used, but the country code would not. Where AAA indicates the area code, EEE indicates the exchange, and SSSS indicates the station.&lt;br/&gt;&lt;br/&gt;Country Code:&lt;br/&gt;The country code is the national prefix to be used when dialing TO that particular country FROM another country.&lt;br/&gt;&lt;br/&gt;NDD Prefix: (National Direct Dialing)&lt;br/&gt;The NDD prefix is the access code used to make a call WITHIN that country from one city to another (when calling another city in the same vicinity, this may not be necessary). The NDD is followed by the city/area code for the place you are calling.&lt;br/&gt;&lt;br/&gt;IDD Prefix: (International Direct Dialing)&lt;br/&gt;The IDD prefix is the international prefix needed to dial a call FROM a country TO another country. This is followed by the country code for the country you are calling. The IDD is not part of the telephone number - but is a property of the locale, or the 'dailing device'.&lt;br/&gt;&lt;br/&gt;Outside Line Prefix:&lt;br/&gt;The Outside line prefix is use inside some private branch exchange (PBX) to connect with the outer exchange/trunk. It is typically 9 in the average US company. This is not part of the telephone number - but once again the property of the locale, or the 'dailing device'. &lt;br/&gt;&lt;br/&gt;/*&lt;br/&gt; * Copyright (c) 2003 David A. Koontz&lt;br/&gt; *    Licensed under the Open Software License version 2.0&lt;br/&gt; *&lt;br/&gt; *    See:  &lt;a href=&quot;http://www.opensource.org/licenses/osl-2.0.php&quot;&gt;http://www.opensource.org/licenses/osl-2.0.php&lt;/a&gt;&lt;br/&gt; *    Grant of Copyright License. Licensor hereby grants You a world-wide,&lt;br/&gt; *    royalty-free, non-exclusive, perpetual, sublicenseable license to&lt;br/&gt; *    do the following:&lt;br/&gt;&lt;br/&gt; *     a) to reproduce the Original Work in copies;&lt;br/&gt; *     b) to prepare derivative works (&amp;quot;Derivative Works&amp;quot;) based upon&lt;br/&gt; *        the Original Work;&lt;br/&gt; *     c) to distribute copies of the Original Work and Derivative Works&lt;br/&gt; *        to the public, with the proviso that copies of Original Work or&lt;br/&gt; *        Derivative Works that You distribute shall be licensed under the&lt;br/&gt; *        Open Software License;&lt;br/&gt; *     d) to perform the Original Work publicly; and&lt;br/&gt; *     e) to display the Original Work publicly.&lt;br/&gt; */&lt;br/&gt;&lt;br/&gt;//package com.&amp;lt;somewhere&gt;.util;&lt;br/&gt;&lt;br/&gt;import java.text.MessageFormat;&lt;br/&gt;&lt;br/&gt;/**&lt;br/&gt; * The &amp;lt;code&gt;TelephoneNumber&amp;lt;/code&gt; class represents a US telephone number.&lt;br/&gt; * &amp;lt;p&gt;&lt;br/&gt; * This class contains many constructors for various uses. It then stores the&lt;br/&gt; * telephone number internally in seperate codes (area code, exchange, etc.).&lt;br/&gt; * This encourages use of the &amp;lt;code&gt;format&amp;lt;/code&gt; method to output the&lt;br/&gt; * telephone number in any style the programmer wishes.&lt;br/&gt; * &amp;lt;p&gt;&lt;br/&gt; * &amp;lt;i&gt;[needs i18n work]&amp;lt;/i&gt;&lt;br/&gt; * &amp;lt;p&gt;&lt;br/&gt; * &amp;lt;b&gt;Example usage:&amp;lt;/b&gt;&amp;lt;br&gt;&lt;br/&gt; * &amp;lt;Blockquote&gt;&amp;lt;code&gt;&amp;lt;pre&gt;&lt;br/&gt; *       long number = 8005551212L;&lt;br/&gt; *       TelephoneNumber phone = new TelephoneNumber(number);&lt;br/&gt; *       StringBuffer msg = new StringBuffer(&amp;quot;Call me at &amp;quot;);&lt;br/&gt; *       msg.append(phone.format());&lt;br/&gt; *       // msg is now &amp;quot;Call me at (800) 555-1212&amp;quot;&lt;br/&gt; * &amp;lt;/pre&gt;&amp;lt;/code&gt;&amp;lt;/Blockquote&gt;&lt;br/&gt; * &amp;lt;p&gt;&lt;br/&gt; * &amp;lt;b&gt;US Format:&amp;lt;/b&gt; &amp;lt;br&gt;&lt;br/&gt; * The general US format is a 3 digit area code, a 3 digit exchange, a 4 digit&lt;br/&gt; * station. Typically written &amp;lt;b&gt;(800) 555-1212&amp;lt;/b&gt;.  Area codes are concidered&lt;br/&gt; * optional unless you live in a '10 digit' calling area as many people now do.&lt;br/&gt; * In which case you may want to set the &amp;lt;code&gt;isTenDigitArea&amp;lt;/code&gt; flag which&lt;br/&gt; * removes the parenthesis from the String output ie Denver area code&lt;br/&gt; * requires 10 digit dailing &amp;lt;b&gt;303 555-1212&amp;lt;/b&gt;.&lt;br/&gt; * &amp;lt;p&gt;&lt;br/&gt; * &amp;lt;b&gt;International Format:&amp;lt;/b&gt; &amp;lt;br&gt;&lt;br/&gt; * International phone numbers are often written in this format:&amp;lt;br&gt;&lt;br/&gt; *    &amp;lt;b&gt;+CC-(N)AAA-EEE-SSSS.&amp;lt;/b&gt;    &amp;lt;br&gt;&lt;br/&gt; * This expresses the numbers used for both international and&lt;br/&gt; * national long-distance calls.  In the example, +CC indicates&lt;br/&gt; * the country code, while (N) indicates the NDD.  When dialing&lt;br/&gt; * from outside the country, the NDD would not be used after dialing&lt;br/&gt; * the country code; when dialing from within that country, the NDD&lt;br/&gt; * would be used, but the country code would not. Where AAA indicates&lt;br/&gt; * the area code, EEE indicates the exchange, and SSSS indicates the&lt;br/&gt; * station.&lt;br/&gt; * &amp;lt;p&gt;&lt;br/&gt; * &amp;lt;p&gt;&lt;br/&gt; *&lt;br/&gt; * &amp;lt;b&gt;Country Code:&amp;lt;/b&gt; &amp;lt;br&gt;&lt;br/&gt; * The country code is the national prefix to be used when dialing &amp;lt;b&gt;TO&amp;lt;/b&gt;&lt;br/&gt; * that particular country &amp;lt;b&gt;FROM&amp;lt;/b&gt; another country.&lt;br/&gt; * &amp;lt;p&gt;&lt;br/&gt; *&lt;br/&gt; * &amp;lt;b&gt;NDD Prefix:&amp;lt;/b&gt; (National Direct Dialing) &amp;lt;br&gt;&lt;br/&gt; * The NDD prefix is the access code used to make a call &amp;lt;b&gt;WITHIN&amp;lt;/b&gt;&lt;br/&gt; * that country from one city to another (when calling another city in&lt;br/&gt; * the same vicinity, this may not be necessary).&lt;br/&gt; * The NDD is followed by the city/area code for the place you are&lt;br/&gt; * calling.&lt;br/&gt; * &amp;lt;p&gt;&lt;br/&gt; *&lt;br/&gt; * &amp;lt;b&gt;IDD Prefix:&amp;lt;/b&gt; (International Direct Dialing) &amp;lt;br&gt;&lt;br/&gt; * The IDD prefix is the international prefix needed to dial a call&lt;br/&gt; * &amp;lt;b&gt;FROM&amp;lt;/b&gt; a country &amp;lt;b&gt;TO&amp;lt;/b&gt; another country. This is&lt;br/&gt; * followed by the country code for the country you are calling.&lt;br/&gt; * The IDD is not part of the telephone number - but is a property of&lt;br/&gt; * the locale, or the 'dailing device'.&lt;br/&gt; * &amp;lt;p&gt;&lt;br/&gt; * &amp;lt;b&gt;Outside Line Prefix:&amp;lt;/b&gt;&amp;lt;br&gt;&lt;br/&gt; * The Outside line prefix is use inside some private branch exchange (PBX)&lt;br/&gt; * to connect with the outer exchange/trunk. It is typically &amp;lt;b&gt;9&amp;lt;/b&gt; in the&lt;br/&gt; * average US company.  This is not part of the telephone number - but&lt;br/&gt; * once again the property of the locale, or the 'dailing device'.&lt;br/&gt; *&lt;br/&gt; *&lt;br/&gt; *&lt;br/&gt; * @author David A. Koontz &amp;lt;a href=&amp;quot;&lt;a href=&quot;mailto:dakoontz@yahoo.com/&quot;&gt;mailto:dakoontz@yahoo.com&lt;/a&gt;&amp;quot;&gt;[&lt;a href=&quot;mailto:dakoontz@yahoo.com/&quot;&gt;dakoontz@yahoo.com&lt;/a&gt;]&amp;lt;/a&gt;&lt;br/&gt; * @version 1.0, 7/20/2003&lt;br/&gt; * @see MessageFormat&lt;br/&gt; * @see &amp;lt;a href=&amp;quot;&lt;a href=&quot;http://www.opensource.org/licenses/osl-2.0.php&quot;&gt;http://www.opensource.org/licenses/osl-2.0.php&lt;/a&gt;&amp;quot;&gt;Open Software License&amp;lt;/a&gt; version 2.0&lt;br/&gt; *&lt;br/&gt; */&lt;br/&gt;public class TelephoneNumber {&lt;br/&gt;&lt;br/&gt;    // International direct dial code is not part of a telephone&lt;br/&gt;    // number - it would be info in the locale that the dialer is in.&lt;br/&gt;    /** National direct dial code */&lt;br/&gt;    protected String ndd;             // NDD of US is 1; UK is 0&lt;br/&gt;    /** Country code */&lt;br/&gt;    protected String countryCode;     // Country code of US is 1; UK is 44&lt;br/&gt;    /** Area code */&lt;br/&gt;    protected String areaCode;&lt;br/&gt;    /** Exchange */&lt;br/&gt;    protected String exchange;&lt;br/&gt;    /** Station */&lt;br/&gt;    protected String station;&lt;br/&gt;    /** Extension */&lt;br/&gt;    protected String extension;&lt;br/&gt;    /** Is phone number part of a ten digit dialing area. */&lt;br/&gt;    protected boolean isTenDigitArea = false;&lt;br/&gt;    /** Alphanumeric phone number */&lt;br/&gt;    protected String alphaNumber;    // used when we store &amp;quot;(800) GOT MILK&amp;quot;&lt;br/&gt;    /** Is phone number an alphanumberic */&lt;br/&gt;    protected boolean isAlphaNumber = false;&lt;br/&gt;&lt;br/&gt;    /** The default format pattern - US centric */&lt;br/&gt;    protected String defaultPatternUS = &amp;quot;({2}) {3}-{4}&amp;quot;;&lt;br/&gt;    /** The default format pattern */&lt;br/&gt;    protected String defaultPattern = defaultPatternUS;&lt;br/&gt;&lt;br/&gt;    /**&lt;br/&gt;     * Basic constructor.&lt;br/&gt;     */&lt;br/&gt;    public TelephoneNumber() {&lt;br/&gt;        this(null, null, null, &amp;quot;555&amp;quot;, &amp;quot;1212&amp;quot;, null);&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    /**&lt;br/&gt;     * General constructor.&lt;br/&gt;     * Create &amp;lt;b&gt;+1-(1)(800) 555-1212 ext: 34&amp;lt;/b&gt;&lt;br/&gt;     *&lt;br/&gt;     * @param countryCode    the country code (US is 1; UK is 44)&lt;br/&gt;     * @param ndd            the national direct dial code (US is 1; UK is 0)&lt;br/&gt;     * @param areaCode       the area code (or city code)&lt;br/&gt;     * @param exchange       the exchange&lt;br/&gt;     * @param station        the station&lt;br/&gt;     * @param extension      the extension (inside the PBX)&lt;br/&gt;     */&lt;br/&gt;    public TelephoneNumber(String countryCode, String ndd, String areaCode, String exchange, String station, String extension) {&lt;br/&gt;        if ( exchange == null )&lt;br/&gt;                throw new IllegalArgumentException(&amp;quot;null arg forms not allowed for 'exchange'&amp;quot;);&lt;br/&gt;        if ( station == null )&lt;br/&gt;                throw new IllegalArgumentException(&amp;quot;null arg forms not allowed for 'station'&amp;quot;);&lt;br/&gt;        this.countryCode = countryCode;&lt;br/&gt;        this.ndd         = ndd;&lt;br/&gt;        this.areaCode    = areaCode;&lt;br/&gt;        this.exchange    = exchange;&lt;br/&gt;        this.station     = station;&lt;br/&gt;        this.extension   = extension;&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    /**&lt;br/&gt;     * Create &amp;lt;b&gt;(800) 555-1212 ext: 34&amp;lt;/b&gt;&lt;br/&gt;     */&lt;br/&gt;    public TelephoneNumber(String areaCode, String exchange, String station, String extension) {&lt;br/&gt;        this(null, null, areaCode, exchange, station, extension);&lt;br/&gt;&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    /**&lt;br/&gt;     * Create  &amp;lt;b&gt;555-1212 ext: 34&amp;lt;/b&gt;&lt;br/&gt;     */&lt;br/&gt;    public TelephoneNumber( String exchange, String station, String extension) {&lt;br/&gt;        this(null, null, null, exchange, station, extension);&lt;br/&gt;&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    /**&lt;br/&gt;     * Create &amp;lt;b&gt;555-1212&amp;lt;/b&gt;&lt;br/&gt;     */&lt;br/&gt;    public TelephoneNumber( String exchange, String station) {&lt;br/&gt;        this(null, null, null, exchange, station, null);&lt;br/&gt;&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    /**&lt;br/&gt;     * Create &amp;lt;b&gt;888 HOLY COW&amp;lt;/b&gt; by using alphanumeric digits&lt;br/&gt;     */&lt;br/&gt;    public TelephoneNumber( boolean isAlphaNumeric, String alphaNumber) {&lt;br/&gt;        this();&lt;br/&gt;        this.isAlphaNumber = isAlphaNumeric;&lt;br/&gt;        if ( isAlphaNumber == true ) {&lt;br/&gt;            this.alphaNumber = alphaNumber;&lt;br/&gt;            // parse it&lt;br/&gt;            String[] nums = parse(convertFromAlpha(alphaNumber));&lt;br/&gt;            // ignore country code &amp;amp; NDD&lt;br/&gt;            this.areaCode = nums[1];&lt;br/&gt;            this.exchange = nums[2];&lt;br/&gt;            this.station  = nums[3];&lt;br/&gt;            this.extension= nums[4];&lt;br/&gt;&lt;br/&gt;        } else {&lt;br/&gt;            // parse this also - assuming no alpha char.&lt;br/&gt;            String[] nums = parse(alphaNumber);&lt;br/&gt;            // ignore country code &amp;amp; NDD&lt;br/&gt;            this.areaCode = nums[1];&lt;br/&gt;            this.exchange = nums[2];&lt;br/&gt;            this.station  = nums[3];&lt;br/&gt;            this.extension= nums[4];&lt;br/&gt;        }&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    /**&lt;br/&gt;     * Create  &amp;lt;b&gt;(888) 555-1212&amp;lt;/b&gt; by parsing string&lt;br/&gt;     */&lt;br/&gt;    public TelephoneNumber( String str) {&lt;br/&gt;        this();&lt;br/&gt;        // parse the string into numbers array&lt;br/&gt;        String[] nums = parse(str);&lt;br/&gt;        // ignore country code &amp;amp; NDD&lt;br/&gt;        this.areaCode = nums[1];&lt;br/&gt;        this.exchange = nums[2];&lt;br/&gt;        this.station  = nums[3];&lt;br/&gt;        this.extension= nums[4];&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    /**&lt;br/&gt;     * Create &amp;lt;b&gt;(479) 555-1212&amp;lt;/b&gt; by parsing a long integer&lt;br/&gt;     */&lt;br/&gt;    public TelephoneNumber(long number) {&lt;br/&gt;        this();&lt;br/&gt;        String[] nums = parse(number);&lt;br/&gt;&lt;br/&gt;        // convert from longs to strings&lt;br/&gt;        this.areaCode = nums[1];&lt;br/&gt;        this.exchange = nums[2];&lt;br/&gt;        this.station = nums[3];&lt;br/&gt;&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    /** Create &amp;lt;b&gt;555-1212&amp;lt;/b&gt; via long integers&lt;br/&gt;     */&lt;br/&gt;    public TelephoneNumber( long exchange, long station) {&lt;br/&gt;        this();&lt;br/&gt;        // convert from longs to strings&lt;br/&gt;        if (exchange &gt; 0) {&lt;br/&gt;            this.exchange = String.valueOf(exchange);&lt;br/&gt;        }&lt;br/&gt;        if (station &gt; 0) {&lt;br/&gt;            this.station = String.valueOf(station);&lt;br/&gt;        }&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    /**&lt;br/&gt;     * Create &amp;lt;b&gt;(479) 555-1212&amp;lt;/b&gt; via long integers&lt;br/&gt;     */&lt;br/&gt;    public TelephoneNumber(long areaCode, long exchange, long station) {&lt;br/&gt;        this();&lt;br/&gt;        // convert from longs to strings&lt;br/&gt;        if (areaCode &gt; 0) {&lt;br/&gt;            this.areaCode = String.valueOf(areaCode);&lt;br/&gt;        }&lt;br/&gt;        if (exchange &gt; 0) {&lt;br/&gt;            this.exchange = String.valueOf(exchange);&lt;br/&gt;        }&lt;br/&gt;        if (station &gt; 0) {&lt;br/&gt;            this.station = String.valueOf(station);&lt;br/&gt;        }&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;    /**&lt;br/&gt;     * Parse a string like &amp;lt;b&gt;&amp;quot;(888) 555-1212 x 68&amp;quot;&amp;lt;/b&gt; into a phone number.&lt;br/&gt;     * Requires area code.&lt;br/&gt;     * Does not allow country codes etc.&lt;br/&gt;     * US centric.&lt;br/&gt;     */&lt;br/&gt;    protected String[] parse( String str) {&lt;br/&gt;        String[] numbers = new String[5];&lt;br/&gt;        StringBuffer ndd = new StringBuffer();&lt;br/&gt;        StringBuffer area = new StringBuffer();&lt;br/&gt;        StringBuffer exch = new StringBuffer();&lt;br/&gt;        StringBuffer stat = new StringBuffer();&lt;br/&gt;        StringBuffer ext = new StringBuffer();&lt;br/&gt;        char ch = ' ';&lt;br/&gt;        int areaCount = 0;&lt;br/&gt;        int exchCount = 0;&lt;br/&gt;        int statCount = 0;&lt;br/&gt;&lt;br/&gt;        if ( str != null &amp;amp;&amp;amp; str.length()&gt;0 ) {&lt;br/&gt;            // for each char in string&lt;br/&gt;            for (int i = 0; i &amp;lt; str.length(); i++) {&lt;br/&gt;                ch = str.charAt(i);&lt;br/&gt;                // only look at digits&lt;br/&gt;                if ( Character.isDigit(ch) ) {&lt;br/&gt;                    // this is only finding this pattern 123 123 1234 99...&lt;br/&gt;                    if ( areaCount &amp;lt; 3 ) {&lt;br/&gt;                        area.append(ch);&lt;br/&gt;                        areaCount++;&lt;br/&gt;                    } else if ( exchCount &amp;lt; 3 ) {&lt;br/&gt;                        exch.append(ch);&lt;br/&gt;                        exchCount++;&lt;br/&gt;                    } else if ( statCount &amp;lt; 4 ) {&lt;br/&gt;                        stat.append(ch);&lt;br/&gt;                        statCount++;&lt;br/&gt;                    } else {&lt;br/&gt;                        ext.append(ch);&lt;br/&gt;                    }&lt;br/&gt;                    // doesnot work for &amp;quot;571 3345 ext 897&amp;quot;&lt;br/&gt;                    //@todo - get better parser&lt;br/&gt;                }&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;            }&lt;br/&gt;        }&lt;br/&gt;        numbers[0] = ndd.toString();&lt;br/&gt;        numbers[1] = area.toString();&lt;br/&gt;        numbers[2] = exch.toString();&lt;br/&gt;        numbers[3] = stat.toString();&lt;br/&gt;        numbers[4] = ext.toString();&lt;br/&gt;&lt;br/&gt;        return numbers;&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    /**&lt;br/&gt;     * Parse a long integer like &amp;lt;b&gt;4795718080&amp;lt;/b&gt; into phone number.&lt;br/&gt;     * Does not allow country codes or extensions.&lt;br/&gt;     * US centric.&lt;br/&gt;     */&lt;br/&gt;    protected String[] parse(long number) {&lt;br/&gt;        String[] nums = new String[5];&lt;br/&gt;        long area = 0;&lt;br/&gt;        long exch = 0;&lt;br/&gt;        long stat = 0;&lt;br/&gt;        // parse the long from right to left&lt;br/&gt;        // assume US style phone number without extension&lt;br/&gt;        // example: 8005551212 or 2368000&lt;br/&gt;        if (number &gt; 0) {&lt;br/&gt;            if (number &gt; 9999) {&lt;br/&gt;                exch = number / 10000;&lt;br/&gt;                stat = number - (exch * 10000);&lt;br/&gt;                if ( exch &gt; 999 ) {&lt;br/&gt;                    area = exch / 1000;&lt;br/&gt;                    exch = exch - (area * 1000);&lt;br/&gt;                }&lt;br/&gt;            }&lt;br/&gt;        }&lt;br/&gt;        // convert from longs to strings&lt;br/&gt;        if (area &gt; 0) {&lt;br/&gt;            nums[1] = String.valueOf(area);&lt;br/&gt;        }&lt;br/&gt;        if (exch &gt; 0) {&lt;br/&gt;            nums[2] = String.valueOf(exch);&lt;br/&gt;        }&lt;br/&gt;        if (stat &gt; 0) {&lt;br/&gt;            nums[3] = String.valueOf(stat);&lt;br/&gt;        }&lt;br/&gt;&lt;br/&gt;        return nums;&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    /** Convert alphanumeric phone number to numeric. */&lt;br/&gt;    protected static String convertFromAlpha(String alpha) {&lt;br/&gt;        // If you don't want US style key pad - change it.&lt;br/&gt;        return convertFromAlphaUS(alpha);&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    /** Convert alphanumeric phone number to numeric - US centric */&lt;br/&gt;    protected static String convertFromAlphaUS(String alpha) {&lt;br/&gt;        // convert a US alphanumeric number into numberic&lt;br/&gt;        // example:  800 GOT MILK -&gt; 800 468-6455&lt;br/&gt;        // where the Alpha to Numberic Key Pad&lt;br/&gt;        //&lt;br/&gt;        //      1     2     3&lt;br/&gt;        //           ABC   DEF&lt;br/&gt;        //&lt;br/&gt;        //      4     5     6&lt;br/&gt;        //     GHI   JKL   MNO&lt;br/&gt;        //&lt;br/&gt;        //      7     8     9&lt;br/&gt;        //    PQRS   TUV   WXYZ&lt;br/&gt;        //&lt;br/&gt;        //     *      0     #&lt;br/&gt;        //&lt;br/&gt;&lt;br/&gt;        // prep the alpha string&lt;br/&gt;        StringBuffer sb = new StringBuffer(alpha.toUpperCase().trim());&lt;br/&gt;&lt;br/&gt;        // for each char in the string&lt;br/&gt;        for (int i = 0; i &amp;lt; sb.length(); i++) {&lt;br/&gt;            char ch = sb.charAt(i);&lt;br/&gt;            if ( Character.isDigit(ch) ) {&lt;br/&gt;                ; // ignore it&lt;br/&gt;            } else if ( ch == '(' || ch == ')' ) {&lt;br/&gt;                ; // ignore them&lt;br/&gt;            } else if ( ch == 'A' || ch == 'B' || ch == 'C' ) {&lt;br/&gt;                sb.deleteCharAt(i);&lt;br/&gt;                sb.insert(i, '2');&lt;br/&gt;            } else if ( ch == 'D' || ch == 'E' || ch == 'F' ) {&lt;br/&gt;                sb.deleteCharAt(i);&lt;br/&gt;                sb.insert(i, '3');&lt;br/&gt;            } else if ( ch == 'G' || ch == 'H' || ch == 'I' ) {&lt;br/&gt;                sb.deleteCharAt(i);&lt;br/&gt;                sb.insert(i, '4');&lt;br/&gt;            } else if ( ch == 'J' || ch == 'K' || ch == 'L' ) {&lt;br/&gt;                sb.deleteCharAt(i);&lt;br/&gt;                sb.insert(i, '5');&lt;br/&gt;            } else if ( ch == 'M' || ch == 'N' || ch == 'O' ) {&lt;br/&gt;                sb.deleteCharAt(i);&lt;br/&gt;                sb.insert(i, '6');&lt;br/&gt;            } else if ( ch == 'P' || ch == 'Q' || ch == 'R' || ch == 'S') {&lt;br/&gt;                sb.deleteCharAt(i);&lt;br/&gt;                sb.insert(i, '7');&lt;br/&gt;            } else if ( ch == 'T' || ch == 'U' || ch == 'V' ) {&lt;br/&gt;                sb.deleteCharAt(i);&lt;br/&gt;                sb.insert(i, '8');&lt;br/&gt;            } else if ( ch == 'W' || ch == 'X' || ch == 'Y' || ch == 'Z' ) {&lt;br/&gt;                sb.deleteCharAt(i);&lt;br/&gt;                sb.insert(i, '9');&lt;br/&gt;            } else {&lt;br/&gt;                ; // ignore&lt;br/&gt;            }&lt;br/&gt;&lt;br/&gt;        }&lt;br/&gt;&lt;br/&gt;        return sb.toString();&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    /**&lt;br/&gt;     * Format the telephone number with the supplied &amp;lt;code&gt;MessageFormat&amp;lt;/code&gt; pattern.&lt;br/&gt;     * The pattern has 7 &amp;lt;code&gt;messageFormatElement&amp;lt;/code&gt; arguments (0 - 6).&lt;br/&gt;     * &amp;lt;p&gt;&lt;br/&gt;     * argument 0 - ndd&amp;lt;br&gt;&lt;br/&gt;     * argument 1 - countryCode&amp;lt;br&gt;&lt;br/&gt;     * argument 2 - areaCode&amp;lt;br&gt;&lt;br/&gt;     * argument 3 - exchange&amp;lt;br&gt;&lt;br/&gt;     * argument 4 - station&amp;lt;br&gt;&lt;br/&gt;     * argument 5 - extension&amp;lt;br&gt;&lt;br/&gt;     * argument 6 - alphanumeric&amp;lt;br&gt;&lt;br/&gt;     * &amp;lt;p&gt;&lt;br/&gt;     * &amp;lt;b&gt;Examples:&amp;lt;/b&gt;&amp;lt;br&gt;&lt;br/&gt;     * &amp;quot;({2}) {3}-{4} ext {5}&amp;quot; gives &amp;quot;(800) 555-1212 ext 99&amp;quot;&amp;lt;br&gt;&lt;br/&gt;     * &amp;quot;{2}.{3}.{4}&amp;quot; gives &amp;quot;800.555.1212&amp;quot;&amp;lt;br&gt;&lt;br/&gt;     * &amp;quot;{6} [{2} {3}-{4}]&amp;quot; gives &amp;quot;888 HOLY COW [888 465-9269]&amp;quot;&amp;lt;br&gt;&lt;br/&gt;     *&lt;br/&gt;     * @param pattern    the format pattern to be used&lt;br/&gt;     * @see MessageFormat&lt;br/&gt;     *&lt;br/&gt;     */&lt;br/&gt;    public String format(String pattern) {&lt;br/&gt;        // create objects array from telephone codes&lt;br/&gt;        Object[] objects = {ndd, countryCode, areaCode, exchange, station, extension, alphaNumber};&lt;br/&gt;&lt;br/&gt;        // create a MessageFormat with pattern&lt;br/&gt;        MessageFormat mf = new MessageFormat(pattern);&lt;br/&gt;        return mf.format(objects);&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    /**&lt;br/&gt;     * Format the telephone number with the &amp;lt;code&gt;defaultPattern&amp;lt;/code&gt; &amp;lt;code&gt;MessageFormat&amp;lt;/code&gt;.&lt;br/&gt;     * US centric.&lt;br/&gt;     */&lt;br/&gt;    public String format() {&lt;br/&gt;        // create objects array from telephone codes&lt;br/&gt;        Object[] objects = {ndd, countryCode, areaCode, exchange, station, extension, alphaNumber};&lt;br/&gt;&lt;br/&gt;        // create a MessageFormat with default pattern&lt;br/&gt;        MessageFormat mf = new MessageFormat(defaultPattern);&lt;br/&gt;        return mf.format(objects);&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    /** Human readable output&lt;br/&gt;     */&lt;br/&gt;    public String toString() {&lt;br/&gt;        return toStringUS();&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    /** US centric human readable output&lt;br/&gt;     */&lt;br/&gt;    public String toStringUS() {&lt;br/&gt;        // use US convention: &amp;quot;(800) 555-1212 ext: 20&amp;quot;&lt;br/&gt;        StringBuffer sb = new StringBuffer(20);&lt;br/&gt;        if ( this.isAlphaNumber ) {&lt;br/&gt;            // just spit back the string&lt;br/&gt;            sb.append(this.alphaNumber);&lt;br/&gt;            sb.append(&amp;quot; [&amp;quot;).append(areaCode).append(&amp;quot; &amp;quot;).append(exchange).append(&amp;quot; &amp;quot;).append(station).append(&amp;quot;]&amp;quot;);&lt;br/&gt;        } else {&lt;br/&gt;&lt;br/&gt;            if (countryCode != null &amp;amp;&amp;amp; countryCode.length() &gt; 0) {&lt;br/&gt;                // format country code as '+CC-'&lt;br/&gt;                sb.append(&amp;quot;+&amp;quot;).append(countryCode).append(&amp;quot;-&amp;quot;);&lt;br/&gt;            }&lt;br/&gt;            if (ndd != null &amp;amp;&amp;amp; ndd.length() &gt; 0) {&lt;br/&gt;                if (countryCode != null &amp;amp;&amp;amp; countryCode.equals(&amp;quot;1&amp;quot;) ) {&lt;br/&gt;                    // in the US we don't write both the country code &amp;amp; the NDD&lt;br/&gt;                    ; // igonre the NDD&lt;br/&gt;                } else {&lt;br/&gt;                    // format NDD as '(N) '&lt;br/&gt;                    sb.append(&amp;quot;(&amp;quot;).append(ndd).append(&amp;quot;) &amp;quot;);&lt;br/&gt;                }&lt;br/&gt;            }&lt;br/&gt;&lt;br/&gt;            if (areaCode != null &amp;amp;&amp;amp; areaCode.length() &gt; 0) {&lt;br/&gt;                // we could use a java.text.Format - but noooooo&lt;br/&gt;                // assume US style (000)&lt;br/&gt;                if ( areaCode.length() == 1 ) {&lt;br/&gt;                    if (isTenDigitArea == true) {&lt;br/&gt;                        sb.append(&amp;quot;00&amp;quot;).append(areaCode).append(&amp;quot; &amp;quot;);&lt;br/&gt;                    } else {&lt;br/&gt;                        sb.append(&amp;quot;(&amp;quot;).append(&amp;quot;00&amp;quot;).append(areaCode).append(&amp;quot;) &amp;quot;);&lt;br/&gt;                    }&lt;br/&gt;                } else if (areaCode.length() == 2 ) {&lt;br/&gt;                    if (isTenDigitArea == true) {&lt;br/&gt;                        sb.append(&amp;quot;0&amp;quot;).append(areaCode).append(&amp;quot; &amp;quot;);&lt;br/&gt;                    } else {&lt;br/&gt;                        sb.append(&amp;quot;(&amp;quot;).append(&amp;quot;0&amp;quot;).append(areaCode).append(&amp;quot;) &amp;quot;);&lt;br/&gt;                    }&lt;br/&gt;                } else if (areaCode.length() == 3 ) {&lt;br/&gt;                    if (isTenDigitArea == true) {&lt;br/&gt;                        sb.append(areaCode).append(&amp;quot; &amp;quot;);&lt;br/&gt;                    } else {&lt;br/&gt;                        sb.append(&amp;quot;(&amp;quot;).append(areaCode).append(&amp;quot;) &amp;quot;);&lt;br/&gt;                    }&lt;br/&gt;                } else {&lt;br/&gt;                    // more than 3 digits? - OK whatever&lt;br/&gt;                    if (isTenDigitArea == true) {&lt;br/&gt;                        sb.append(areaCode).append(&amp;quot; &amp;quot;);&lt;br/&gt;                    } else {&lt;br/&gt;                        sb.append(&amp;quot;(&amp;quot;).append(areaCode).append(&amp;quot;) &amp;quot;);&lt;br/&gt;                    }&lt;br/&gt;                }&lt;br/&gt;            }&lt;br/&gt;&lt;br/&gt;            // exchange - assume US style 000&lt;br/&gt;            if ( exchange.length() == 1 ) {&lt;br/&gt;                sb.append(&amp;quot;00&amp;quot;).append(exchange).append(&amp;quot;-&amp;quot;);&lt;br/&gt;            } else if (exchange.length() == 2 ) {&lt;br/&gt;                sb.append(&amp;quot;0&amp;quot;).append(exchange).append(&amp;quot;-&amp;quot;);&lt;br/&gt;            } else if (exchange.length() == 3 ) {&lt;br/&gt;                sb.append(exchange).append(&amp;quot;-&amp;quot;);&lt;br/&gt;            } else {&lt;br/&gt;                // more than 3 digits? - OK whatever&lt;br/&gt;                sb.append(exchange).append(&amp;quot;-&amp;quot;);&lt;br/&gt;            }&lt;br/&gt;&lt;br/&gt;            // station - assume US style 0000&lt;br/&gt;            if ( station.length() == 1 ) {&lt;br/&gt;                sb.append(&amp;quot;000&amp;quot;).append(station);&lt;br/&gt;            } else if (station.length() == 2 ) {&lt;br/&gt;                sb.append(&amp;quot;00&amp;quot;).append(station);&lt;br/&gt;            } else if (station.length() == 3 ) {&lt;br/&gt;                sb.append(&amp;quot;0&amp;quot;).append(station);&lt;br/&gt;            } else {&lt;br/&gt;                sb.append(station);&lt;br/&gt;            }&lt;br/&gt;&lt;br/&gt;            if (extension != null &amp;amp;&amp;amp; extension.length() &gt; 0) {&lt;br/&gt;                sb.append(&amp;quot; ext: &amp;quot;).append(extension);&lt;br/&gt;            }&lt;br/&gt;        }&lt;br/&gt;&lt;br/&gt;        return sb.toString();&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    /** MAIN - a test stub */&lt;br/&gt;    public static void main(String[] args) {&lt;br/&gt;        // test it out&lt;br/&gt;        TelephoneNumber  n1 = new TelephoneNumber(); // test null params&lt;br/&gt;        TelephoneNumber  n2 = new TelephoneNumber(571L, 9999L); // test 2 longs&lt;br/&gt;        TelephoneNumber  n3 = new TelephoneNumber(479L, 571L, 1003L); // test 3 longs&lt;br/&gt;        TelephoneNumber  n4 = new TelephoneNumber(303L, 222L, 7800L);   // test ten digit dialing&lt;br/&gt;                         n4.isTenDigitArea = true;&lt;br/&gt;&lt;br/&gt;        TelephoneNumber  n5 = new TelephoneNumber(&amp;quot;(888) 341-8876&amp;quot;);  // test formated string&lt;br/&gt;        TelephoneNumber  n6 = new TelephoneNumber(127, 345, 8765); // test 3 integers&lt;br/&gt;        TelephoneNumber  n7 = new TelephoneNumber(true, &amp;quot;800 GOT MILK&amp;quot;);  // test parsing Alpha&lt;br/&gt;        TelephoneNumber  n8 = new TelephoneNumber(3L, 4L, 5L);     // test zero padding&lt;br/&gt;        TelephoneNumber  n9 = new TelephoneNumber(&amp;quot;1&amp;quot;, &amp;quot;1&amp;quot;, &amp;quot;479&amp;quot;, &amp;quot;571&amp;quot;, &amp;quot;8509&amp;quot;, &amp;quot;40&amp;quot;); // test 6 strings&lt;br/&gt;        TelephoneNumber n10 = new TelephoneNumber(9876543210L);    // test 1 long&lt;br/&gt;        TelephoneNumber n11 = new TelephoneNumber(false, &amp;quot;/800/ 555-1212 x 0&amp;quot;); // test parsing Non-Alpha&lt;br/&gt;&lt;br/&gt;        System.out.println(&amp;quot;TelephoneNumber(): &amp;quot; + n1);&lt;br/&gt;        System.out.println(&amp;quot;TelephoneNumber(571L, 9999L): &amp;quot; + n2);&lt;br/&gt;        System.out.println(&amp;quot;TelephoneNumber(479L, 571L, 1003L): &amp;quot; + n3);&lt;br/&gt;        System.out.println(&amp;quot;TelephoneNumber(303L, 222L, 7800L): &amp;quot; + n4);&lt;br/&gt;        System.out.println(&amp;quot;TelephoneNumber(\&amp;quot;(888) 341-8876\&amp;quot;): &amp;quot; + n5);&lt;br/&gt;        System.out.println(&amp;quot;TelephoneNumber(127, 345, 8765): &amp;quot; + n6);&lt;br/&gt;        System.out.println(&amp;quot;TelephoneNumber(true, \&amp;quot;800 GOT MILK\&amp;quot;): &amp;quot; + n7);&lt;br/&gt;        System.out.println(&amp;quot;TelephoneNumber(3L, 4L, 5L): &amp;quot; + n8);&lt;br/&gt;        System.out.println(&amp;quot;TelephoneNumber(\&amp;quot;1\&amp;quot;, \&amp;quot;1\&amp;quot;, \&amp;quot;479\&amp;quot;, \&amp;quot;571\&amp;quot;, \&amp;quot;8509\&amp;quot;, \&amp;quot;40\&amp;quot;): &amp;quot; + n9);&lt;br/&gt;        System.out.println(&amp;quot;TelephoneNumber(9876543210L): &amp;quot; + n10);&lt;br/&gt;        System.out.println(&amp;quot;TelephoneNumber(false, \&amp;quot;/800/ 555-1212 x 0\&amp;quot;): &amp;quot; + n11);&lt;br/&gt;        System.out.println(&amp;quot;TelephoneNumber.format(\&amp;quot;{6} [{2} {3}-{4}]\&amp;quot;): &amp;quot; + n7.format(&amp;quot;{6} [{2} {3}-{4}]&amp;quot;));&lt;br/&gt;        System.out.println(&amp;quot;TelephoneNumber.format(): &amp;quot; + n9.format());&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    /******************************************************************/&lt;br/&gt;    /***  Getter/Setter                                             ***/&lt;br/&gt;    /******************************************************************/&lt;br/&gt;&lt;br/&gt;    public String getNdd() {&lt;br/&gt;        return ndd;&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    public void setNdd(String value) {&lt;br/&gt;        ndd = value;&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    public String getCountryCode() {&lt;br/&gt;        return countryCode;&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    public void setCountryCode(String value) {&lt;br/&gt;        countryCode = value;&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    public String getAreaCode() {&lt;br/&gt;        return areaCode;&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    public void setAreaCode(String value) {&lt;br/&gt;        areaCode = value;&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    public String getExchange() {&lt;br/&gt;        return exchange;&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    public void setExchange(String value) {&lt;br/&gt;        exchange = value;&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    public String getStation() {&lt;br/&gt;        return station;&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    public void setStation(String value) {&lt;br/&gt;        station = value;&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    public String getExtension() {&lt;br/&gt;        return extension;&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    public void setExtension(String value) {&lt;br/&gt;        extension = value;&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    public boolean isTenDigitArea() {&lt;br/&gt;        return isTenDigitArea;&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    public void setTenDigitArea(boolean value) {&lt;br/&gt;        isTenDigitArea = value;&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    public String getAlphaNumber() {&lt;br/&gt;        return alphaNumber;&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    public void setAlphaNumber(String value) {&lt;br/&gt;        alphaNumber = value;&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    public boolean isAlphaNumber() {&lt;br/&gt;        return isAlphaNumber;&lt;br/&gt;    }&lt;br/&gt;&lt;br/&gt;    public void setAlphaNumber(boolean value) {&lt;br/&gt;        isAlphaNumber = value;&lt;br/&gt;    }&lt;br/&gt;}</description>
      <enclosure url="http://www.david.koontz.name/home/Projects/Entries/2008/4/13_TelephoneNumber_-_Java_class_files/IMG0027.jpg" length="161510" type="image/jpeg"/>
    </item>
    <item>
      <title>Refactoring - examples from the book</title>
      <link>http://www.david.koontz.name/home/Projects/Entries/2008/4/13_Photo_of_the_Day.html</link>
      <guid isPermaLink="false">3a59d315-a739-4754-80f4-58b7853bb16a</guid>
      <pubDate>Mon, 14 Apr 2008 06:56:04 +0200</pubDate>
      <description>&lt;a href=&quot;http://www.david.koontz.name/home/Projects/Entries/2008/4/13_Photo_of_the_Day_files/Chief%20Seattle%20Fire%20Boat%20%20006.jpg&quot;&gt;&lt;img src=&quot;http://www.david.koontz.name/home/Projects/Media/object023.png&quot; style=&quot;float:left; padding-right:10px; padding-bottom:10px; width:425px; height:212px;&quot;/&gt;&lt;/a&gt;Martin Fowler's book Refactoring: Improving the Design of Existing Code has a simple example of a movie rental domain model, which he refactors from a less than ideal object-oriented design to a more robust OO design. Included in this &lt;a href=&quot;Entries/2008/4/13_Photo_of_the_Day_files/Refactoring_FirstExample.zip&quot;&gt;Refactoring_FirstExample.zip&lt;/a&gt; Zip file are the Java source code files of the Movie, Rental, and Customer classes. Along with a JUnit CustomerTest class. Using these example source files you too can follow along with the refactoring that Fowler presents in the first few chapters of his book.&lt;br/&gt;</description>
      <enclosure url="http://www.david.koontz.name/home/Projects/Entries/2008/4/13_Photo_of_the_Day_files/Chief%20Seattle%20Fire%20Boat%20%20006.jpg" length="154610" type="image/jpeg"/>
    </item>
  </channel>
</rss>

