Revision 445

tmp/org.txm.core/src/java/org/txm/core/results/comparators/MultipleComparators.java (revision 445)
6 6
import java.util.ArrayList;
7 7
import java.util.Comparator;
8 8

  
9
import org.txm.core.results.ITXMResult;
9
import org.txm.core.results.TXMResult;
10 10

  
11 11
/**
12 12
 * Multiple chained TXM result comparisons management.
......
14 14
 * @author sjacquot
15 15
 *
16 16
 */
17
public class MultipleComparators implements Comparator<ITXMResult> {
17
public class MultipleComparators implements Comparator<TXMResult> {
18 18
	
19
	protected ArrayList<Comparator<ITXMResult>> comparators;
19
	protected ArrayList<Comparator<TXMResult>> comparators;
20 20
	 
21 21
	/**
22 22
	 * 
23 23
	 * @param comparators
24 24
	 */
25
    public MultipleComparators(ArrayList<Comparator<ITXMResult>> comparators) {
25
    public MultipleComparators(ArrayList<Comparator<TXMResult>> comparators) {
26 26
        this.comparators = comparators;
27 27
    }
28 28
 
29 29
	@Override
30
	public int compare(ITXMResult o1, ITXMResult o2) {
30
	public int compare(TXMResult o1, TXMResult o2) {
31 31
	   for(int i = 0; i < this.comparators.size(); i++) {
32 32
            int result = this.comparators.get(i).compare(o1, o2);
33 33
            if (result != 0) {
tmp/org.txm.core/src/java/org/txm/core/results/comparators/Comparators.java (revision 445)
7 7
import java.util.Collections;
8 8
import java.util.Comparator;
9 9

  
10
import org.txm.core.results.ITXMResult;
10
import org.txm.core.results.TXMResult;
11 11

  
12 12
/**
13 13
 * Class to manage different comparators for a sorting type.
......
40 40
	 * @param sorting
41 41
	 * @return
42 42
	 */
43
	public static Comparator<ITXMResult> getComparator(int sorting)	{
43
	public static Comparator<TXMResult> getComparator(int sorting)	{
44 44
		//FIXME: to complete and improve to sort on more than one key
45 45
		
46 46
		switch(sorting) {
47 47
		default:			
48 48
		// NODE_WEIGHT
49 49
		case 0:
50
			new Comparator<ITXMResult>() {
50
			new Comparator<TXMResult>() {
51 51
				@Override
52
				public int compare(ITXMResult o1, ITXMResult o2) {
52
				public int compare(TXMResult o1, TXMResult o2) {
53 53
					return o1.getWeight() - o2.getWeight();
54 54
				}
55 55
			};
56 56
			break;
57 57
		// SIMPLE_NAME_ALPHANUM
58 58
		case 1:
59
			new Comparator<ITXMResult>() {
59
			new Comparator<TXMResult>() {
60 60
				@Override
61
				public int compare(ITXMResult o1, ITXMResult o2) {
61
				public int compare(TXMResult o1, TXMResult o2) {
62 62
					return o1.getSimpleName().compareTo(o2.getSimpleName());
63 63
				}
64 64
			};
......
75 75
	 * @param sorting
76 76
	 * @param reversed
77 77
	 */
78
	public static void sort(ArrayList<ITXMResult> results, boolean reversed, int... sorting)	{
79
		ArrayList<Comparator<ITXMResult>> comparators = new ArrayList<Comparator<ITXMResult>>();
78
	public static void sort(ArrayList<TXMResult> results, boolean reversed, int... sorting)	{
79
		ArrayList<Comparator<TXMResult>> comparators = new ArrayList<Comparator<TXMResult>>();
80 80
		for(int i = 0; i < sorting.length; i++) {
81 81
			comparators.add(getComparator(sorting[i]));
82 82
		}
83
		Comparator<ITXMResult> comparator = new MultipleComparators(comparators);
83
		Comparator<TXMResult> comparator = new MultipleComparators(comparators);
84 84
		if(reversed)	{
85 85
			comparator = Collections.reverseOrder(comparator);
86 86
		}

Also available in: Unified diff