The Coffee Machine

Java & Eclipse tips blog

  • Categories

  • Archives

  •  

    November 2009
    M T W T F S S
    « Sep    
     1
    2345678
    9101112131415
    16171819202122
    23242526272829
    30  

Archive for the ‘Java’ Category

Sort a list of elements with the Comparable interface

Posted by ObLiB on September 11, 2008

JavaSometimes you’ve got to sort a list. Instead of doing our own sort method, you can use the Collections.sort(List list) method. To be sorted, your list elements must be “Comparable” (Like int, String, Date etc…). To do this, the only things to do are to implements the Comparable interface and define the public int compareTo(Object object) method in your element class.

Read the rest of this entry »

Posted in Java | Tagged: , , , , , , , | Leave a Comment »

XML with Java and JDOM

Posted by ObLiB on August 29, 2008

JavaA few months ago, I worked on a java project which had to manage XML data. The XML data that I had to deal with weren’t very complex so I try to find the easiest way to manage XML data with Java and I found JDOM.

We want to provide a solution for using XML from Java that is as simple as Java itself.
There is no compelling reason for a Java API to manipulate XML to be complex, tricky, unintuitive, or a pain in the neck. JDOMTM is both Java-centric and Java-optimized. It behaves like Java, it uses Java collections, it is completely natural API for current Java developers, and it provides a low-cost entry point for using XML.
While JDOM interoperates well with existing standards such as the Simple API for XML (SAX) and the Document Object Model (DOM), it is not an abstraction layer or enhancement to those APIs. Rather, it provides a robust, light-weight means of reading and writing XML data without the complex and memory-consumptive options that current API offerings provide.

The JDOM team

Read the rest of this entry »

Posted in API, Java | Tagged: , | 1 Comment »