Source code: com/obinary/cms/util/SequenceComparator.java
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-2003 obinary Ltd. (http://www.obinary.com) All rights reserved.
11 *
12 * */
13
14
15
16
17
18
19 package com.obinary.cms.util;
20
21 import jdsl.core.ref.ComparableComparator;
22
23 import com.obinary.cms.core.Content;
24
25
26 /**
27 * Date: Apr 28, 2003
28 * Time: 11:20:59 AM
29 * @author Vinzenz Wyser
30 * @version 1.0
31 */
32
33
34 public class SequenceComparator extends ComparableComparator{
35 public int compare(Object o0, Object o1) throws ClassCastException {
36 try {
37 long pos0=(((Content)o0).getMetaData().getSequencePosition());
38 long pos1=(((Content)o1).getMetaData().getSequencePosition());
39
40 //System.out.println(((Content)o0).getTitle()+"["+pos0+"]::"+((Content)o1).getTitle()+"["+pos1+"]");
41
42 String s0="0";
43 String s1="0";
44
45 if (pos0>pos1) s0="1";
46 else if (pos0<pos1) s1="1";
47
48 return super.compare(s0,s1);
49
50 }
51 catch (IllegalStateException e) {
52 e.printStackTrace(); return 0;
53 }
54
55 }
56
57
58 public boolean isComparable(Object o) {
59 return true;
60 }
61
62 }