KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > htmlparser > util > sort > Ordered


1 // HTMLParser Library $Name: v1_5_20050313 $ - A java-based parser for HTML
2
// http://sourceforge.org/projects/htmlparser
3
// Copyright (C) 2004 Derrick Oswald
4
//
5
// Revision Control Information
6
//
7
// $Source: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/util/sort/Ordered.java,v $
8
// $Author: derrickoswald $
9
// $Date: 2004/01/02 16:24:58 $
10
// $Revision: 1.11 $
11
//
12
// This library is free software; you can redistribute it and/or
13
// modify it under the terms of the GNU Lesser General Public
14
// License as published by the Free Software Foundation; either
15
// version 2.1 of the License, or (at your option) any later version.
16
//
17
// This library is distributed in the hope that it will be useful,
18
// but WITHOUT ANY WARRANTY; without even the implied warranty of
19
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20
// Lesser General Public License for more details.
21
//
22
// You should have received a copy of the GNU Lesser General Public
23
// License along with this library; if not, write to the Free Software
24
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
//
26

27 package org.htmlparser.util.sort;
28
29 /**
30  * Describes an object that knows about ordering.
31  * Implementors must have a comparison function,
32  * which imposes a partial ordering on some
33  * collection of objects. Ordered objects can be passed to a
34  * sort method (such as org.htmlparser.util.sort.Sort) to allow precise control
35  * over the sort order.
36  * <p>
37  * An set of elements S is partially ordered
38  * if and only if <code>e1.compare(e2)==0</code> implies that
39  * <code>e1.equals(e2)</code> for every e1 and e2 in S.
40  * <p>
41  * This all goes away in JDK 1.2.
42  * <p>
43  * For use with java.lang.Comparable from JDK 1.2:
44  * <pre>
45  * public int compare (Object o1, Object o2)
46  * {
47  * return (((Ordered)o1).compare (o2));
48  * }
49  * </pre>
50  * @see Sort
51  */

52 public interface Ordered
53 {
54     /**
55      * Compares this object with another for order.
56      * Returns a negative integer, zero, or a positive integer
57      * as this object is less than, equal to, or greater
58      * than the second.
59      * <p>
60      * The implementor must ensure that
61      * <code>sgn(x.compare(y)) == -sgn(y.compare(x))</code>
62      * for all x and y. (This implies that <code>x.compare(y)</code>
63      * must throw an exception if and only if <code>y.compare(x)</code>
64      * throws an exception.)
65      * <p>
66      * The implementor must also ensure that the relation is transitive:
67      * <code>((x.compare(y)>0) && (y.compare(z)>0))</code>
68      * implies <code>x.compare(z)>0</code>.
69      * <p>
70      * Finally, the implementer must ensure that
71      * <code>x.compare(y)==0</code> implies that
72      * <code>sgn(x.compare(z))==sgn(y.compare(z))</code>
73      * for all z.
74      * @param that The object to compare this object against.
75      * @return A negative integer, zero, or a positive
76      * integer as this object is less than, equal to,
77      * or greater than the second.
78      * @exception ClassCastException The arguments type prevents it
79      * from being compared by this Ordered.
80      */

81     public int compare (Object JavaDoc that);
82 }
83
Popular Tags