KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > cms > util > StringComparator


1 /**
2  *
3  * Magnolia and its source-code is licensed under the LGPL.
4  * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
5  * When copying, adapting, or redistributing this document in keeping with the guidelines above,
6  * you are required to provide proper attribution to obinary.
7  * If you reproduce or distribute the document without making any substantive modifications to its content,
8  * please use the following attribution line:
9  *
10  * Copyright 1993-2005 obinary Ltd. (http://www.obinary.com) All rights reserved.
11  *
12  */

13 package info.magnolia.cms.util;
14
15 import info.magnolia.cms.core.Content;
16
17 import java.util.Comparator JavaDoc;
18
19
20 /**
21  * @author Sameer Charles
22  * @version 1.1
23  */

24 public class StringComparator implements Comparator JavaDoc {
25
26     /**
27      * Logger.
28      */

29
30     private String JavaDoc nodeDataName;
31
32     public StringComparator(String JavaDoc nodeDataName) {
33         this.nodeDataName = nodeDataName;
34     }
35
36     public int compare(Object JavaDoc o, Object JavaDoc o1) throws ClassCastException JavaDoc {
37         String JavaDoc uri1;
38         String JavaDoc uri2;
39
40         uri1 = ((Content) o).getNodeData(this.nodeDataName).getString();
41         uri2 = ((Content) o1).getNodeData(this.nodeDataName).getString();
42
43         return uri1.compareTo(uri2);
44     }
45 }
46
Popular Tags