Archive for March, 2008

Java: Implement Composite Key Lookup for Map »

Here is a simple tip to implement composite key lookup for Map, either HashMap or Hashtable, etc Normally the key to a Map can be a String, Long, Integer, etc. But what if we need to implement our own key, e.g. combination of MSISDN and IMSI. Here is my SubscriberKey class. It has the composite [...]

PowerShell Prompt: A Useful Utility for Developer »

Thanks to Scott Hanselman, now I can easily use PowerShell prompt by right clicking on a folder. You can download the INF file from his blog at For those of you who want to have a more powerful scripting language on Windows comparable to *nix platform, you may already been using PowerShell. As described [...]

StringUtils.isNumeric("") is true ? »

Apache Commons is one of my favorite Java libraries. This is one of the mistake that I made recently. Guess what the following code will return System.out.println(StringUtils.isNumeric("")); The code will return true instead of false as what I expected. I checked the documentation, and it says for isNumeric. "Checks if the String contains only unicode [...]

TOra for Windows Finally »

I have mentioned TOra before. For those that are using Oracle, you will need a tool like Toad to help you in your day to day Oracle tasks. TOra is a ideal alternative for Toad if you are looking for open source solution. However, before this TOra is only available for *nix platform only. Now [...]

CakePHP 1.2 – Life Made A Lot Simpler for PHP Programmer »

I have been using CakePHP 1.1 for few projects, and now I am so used to it and tend to use it for every PHP project that I am doing. CakePHP 1.2 is still in beta but more features are incorporated into the core. One of the features that I think should be part of [...]

Ant + Ivy – A Flexible Build Tool »

Ant is the first Java build too that I used. I am currently using Maven as my primary build tool, but sometimes I found that it is very troublesome to use. The dependency management concept is good but the way Maven behaved sometimes is not up to my expectations or requirements. Next come Ivy. Apache [...]

Design Pattern: Design a Simple Workflow using Chain of Responsibility Pattern »

Download Source Code I was trying Apache Commons Chain when I was trying to design a simple workflow system for my back-end application using the Chain of Responsibility design pattern. Chain of Responsibility is a popular technique for organizing the execution of complex processing flows. It is not difficult if you want to write it [...]

iBatis: Support for Array or List Parameter with SQL IN Keyword »

This is a feature available in iBatis but it is not mentioned in the documentation. You can find the example in the iBatis source code under the unit tests. Let’s said I need to run the following SQL statement select * from my_table where col_1 in (’1′,’2′,’3′) So how do I pass in the values [...]

Java: Use Properties Carefully »

I saw this piece of code Properties prop = new Properties(); prop.put(“string”, “my string”); prop.put(“integer”, 11); System.out.println(prop.getProperty(“string”)); System.out.println(prop.getProperty(“integer”)); The output my string null Even though the Integer value 11 is put into the Properties, but it is not retrieved correctly. To make it work, you must use get Properties prop = new Properties(); prop.put(“string”, “my [...]

A Missing Features in iBatis ? »

Well, I think this is a missing feature in iBatis. Gave up after I searched and searched again for more information. <resultMap id=”TableA” class=”com.twit88.valueobject.TableA”> <result column=”COL_1″ property=”col1″ jdbcType=”VARCHAR”/> <result column=”COL_2″ property=”col2″ jdbcType=”VARCHAR”/> <result column=”COL_3″ property=”col3″ jdbcType=”TIMESTAMP”/> </resultMap> <select id=”select-record” resultMap=”MyResult” parameterClass=”com.twit88.valueobject.TableA”> <![CDATA[ select COL_1, COL_2 from tableA ]]> </select> The above will not work since [...]

Retroweaver: Use Java 1.5 Features and Run in JDK 1.4 »

This solved one dilemma that I faced. I like JDK 1.5 features but some of my old Java applications are dependant on some proprietary libraries which can only run on JDK 1.4. Retroweaver is a bytecode weaver that enables you to take advantage of the new Java 1.5 language features, while still retaining total binary [...]

Java: Start RMI Server using Specific IP Address »

Here is a simple thing which caused me problem for quite awhile.. I need to run on RMI client on Server A with IP address X which connects RMI server on Server B which is multi-homed, meaning it has multiple IP addresses. When the RMI server starts on Server B, it binds to IP address [...]

Java: A Simple RMI Client Proxy Class »

Download Source Code Here is a simple RMI client proxy class that will help you to connect to a RMI server, cache the connection, call the method. Some of the code snippet // FactoryMethod public RmiClientProxy(Class serviceInterface, String serviceUrl) { this.serviceInterface = serviceInterface; this.serviceUrl = serviceUrl; serviceProxy = createProxy(); prepare(); } This is a constructor [...]

Maven: Compile Your Application to be JDK 1.4, 1.5 or 1.6 Compatible »

I need to compile some of my Maven projects to be JDK 1.4 compatible, some for JDK 1.5 or JDK 1.6. To do this in Maven is very straight forward since I have different pom.xml for different applications. I write my code using JDK 1.5 syntax but I need the library to be JDK 1.4 [...]

Why You Should Use “isDebugEnabled” ? »

This is a simple mistake that I noticed is commonly made by developers. Often I saw the code like the followings ….. log.debug(“my debug message”); … log.debug(“variable A is set to ” + myVariableA); Whenever I saw this, I always change them to ….. if (log.isDebugEnabled()) log.debug(“my debug message”); … if (log.isDebugEnabled()) log.debug(“variable A is [...]

Send Email Using Telnet »

It is very straightforward to send email using telnet if you know some simple SMTP command > telnet 25 S: 220 ESMTP Postfix C: HELO S: 250 Hello, I am glad to meet you C: MAIL FROM:<> S: 250 Ok C: RCPT TO:<> S: 250 Ok C: DATA S: 354 End [...]

Access Your Email Using Telnet »

This is a simple trick that you may already know. It is very easy to access your email if your email server supports POP3 protocol. By right all email servers should support this protocol. The default port for POP3 is 110. $ telnet 110 Trying… Connected to Escape character is ‘^]’. +OK [...]

Freeware Note »

PC Inspector PhotoRec Recovery Manager Data Recovery SoftPerfect File Recovery IrfanView

.NET: Detect Incoming Call or SMS in Windows Mobile Phone »

Download Sample Code I was looking for way to detect incoming call or SMS in Nokia Symbian phones and Windows Mobile Phone. It was not easy to do this in Symbian OS but to do it in .NET is very straightforward. messageInterceptor = new MessageInterceptor(); messageInterceptor.InterceptionAction = InterceptionAction.NotifyAndDelete; //messageInterceptor.MessageCondition.CaseSensitive = true; //messageInterceptor.MessageCondition.Property = // MessageProperty.Sender; [...]

Superfish – An Excellent JQuery Menu Plugin »

I was searching high and low for a good JQuery menu plugin. After trying out many menu plugins out there, I decided to use Superfish. Superfish is working all browsers as JQuery itself. It supports drop down menus vertically aligned menus horizontally aligned navbar with submenus. Shows how you can indicate the user’s current page [...]