Some pictures from the international cat exhibition

Some of the pictures I have taken at the cat exhibition in Ostrava (2. 5. 2009).

Enjoy:-)

⇥ Read the article in full

About

I am software developer living in Ostrava, Czech Republic. My hobbies are reading sf&f, photography, cycling, hiking, geocaching, swimming and of course programming.

Read More   ⎋

Subscribe to RSS Feed

Categories

Archives

Recent articles

Hudson CI server

I have recently learned about new Continuous Integration server on the Stackoverflow.com. It is Hudson. If you are setting up CI server it is definitely a interesting project to consider. And did I mention it is free too?

I will come up with more observations later, when I have opportunity to try it.

Proper sorting with collation has never been easier

I haven’t been blogging for quite some time and I guess that I had good reasons (we were moving to a bigger apartment). But now the things have settled a bit and I am back with new post.

While working on our little project with Vitek, we found ourselves in need of in-memory collection sorting. It is of course better to sort data in a database, but if you don’t have any, then it is a bit problem. Collection sorting in Java is also not difficult. You just need to put your data in some sortable collection, throw in a Comparator, and call Collections.sort(). Piece of cake. It is not fast when it comes to large collections, but it works. But the problem arises when it comes to non-ascii character sets.

Well … not really - I will show later. We needed to sort collection of Result objects by different columns and display them in proper order according to the Czech Locale settings (č after c, ě after e, á after a and so on). That means one has implement the collation sequence in the comparator. How I was asking.

Fortunately Java API comes handy in such situations… and eureka: here is the SOLUTION. Java contains very useful class for such situations I was previously not aware about: Collator.

The Collator class performs locale-sensitive String comparison. You use this class to build searching and sorting routines for natural language text.

Collator is an abstract base class. Subclasses implement specific collation strategies. One subclass, RuleBasedCollator, is currently provided with the Java 2 platform and is applicable to a wide set of languages. Other subclasses may be created to handle more specialized needs.

Like other locale-sensitive classes, you can use the static factory method, getInstance, to obtain the appropriate CollatorCollator if you need to understand the details of a particular collation strategy or if you need to modify that strategy. object for a given locale. You will only need to look at the subclasses of

The following example shows how to compare two strings using the Collator for the default locale.

 // Compare two strings in the default locale
Collator myCollator = Collator.getInstance();
if( myCollator.compare("abc", "ABC") < 0 )
System.out.println("abc is less than ABC");
 else
System.out.println("abc is greater than or equal to ABC");

So far the API documentation. And how does the code now looks like?

class ResultCityAscendingComparator implements Comparator {    

/** {@inheritDoc} */
public int compare(IResult o1, IResult o2) {
String city1 = o1.getAddress().getCity();
String city2 = o2.getAddress().getCity();
            if (city1 == null && city2 != null) {
                return -1;
            } else if (city1 != null && city2 == null) {
                return 1;
            } else if (city1 == null && city2 == null) {
                return 0;
            } else {
                return collator.compare(city1, city2);
            }
        }    

    }    

class ResultCityDescendingComparator extends ResultCityAscendingComparator {  

/** {@inheritDoc} */
        @Override
public int compare(IResult o1, IResult o2) {
            return -1 * super.compare(o1, o2);
        }   

    }

You can collect all comparators (both ascending and descending) for one specific object in one class and wrap them in inner classes. Then the Sorter class can contain factory methods to provide generic Comparators for each field you want to sort by. Neat, isn’t it? It wasn’t that much code after all..

Sun Certified Java Programmer

Beside my JavaBlackBelt activities I have also managed to obtain more “official” certificate type. I have succeeded in SCJP exam today. This was my first attempt to get the certificate and that makes me happy. I must not tell anything about the test, maybe except the fact that quite a big part of the questions were gimmicks or test of the perception and collectedness.

After a day at work and then more than 2 hours of uninterrupted deliberation I think that I deserve some sleep now:-)

Setting up Continuum continuous build server

I have been experimenting with the continuous integration with help of the Continuum server. The process is rather straightforward but here are some observations anyway. I have put them to the checklist. I have been working according to the tutorial found on java.net: Continuous Integration with Continuum which is a very good reading to kick you off.

  1. The installation of Continuum is pretty easy. It comes together with all needed components including Jetty as a web server and Derby as database back-end.
  2. Then you of course need the project to play with - I have used my hobby project Parrot. The project must have some kind of build script - you can choose either from Maven2+, Maven1, Ant or Shell projects. I have chosen Maven2 for this.
  3. Then you need to enhance your build script with SCM specification - so that build server knows where to get latest version of the project. Please note that you must provide the full path to the directory where your .pom file resides (i.e. <connection>scm:svn:https://somerepository.com/svn/trunk/0.0.1</connection>) otherwise you are about to get the ContinuumBuildExecutorException: Could not find Maven project descriptor, which was my case:-)
  4. You can play with other maven properties like setting up developer’s name and email address, configure the email server etc. but these settings are not particularly needed for setting up the build itself.
  5. Then import the build script from the scm location and you are done.

Build error?Continuum is neat, although not as powerful as Atlassian Bamboo (which we are using in our day to day routine). It completely lacks reporting functionality, is not so well graphically designed, but it is free and such flaws are coming with the territory. Someone may say that CruiseControl is better, and I cannot argue, because I haven’t tried that yet. I have discovered that upon failed tests the build is still successful. I have to elaborate on this a bit more.

Perhaps next time?

Animal photos


Warning: getimagesize(/DISK3/WWW/petrmacek.com/www/wp-content/myfotos/animals/Lemuri.jpg) [function.getimagesize]: failed to open stream: Permission denied in /DISK3/WWW/petrmacek.com/www/wp-content/plugins/mygallery/myfunctions/mygalleryfunctions.php on line 763

I have created a first gallery of photos. Here are some pictures of animals I have taken in Lešná ZOO: