Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.api / src / main / java / org / gvsig / fmap / dal / complements / Search.java @ 44262

History | View | Annotate | Download (2.88 KB)

1
/*
2
 * To change this license header, choose License Headers in Project Properties.
3
 * To change this template file, choose Tools | Templates
4
 * and open the template in the editor.
5
 */
6
package org.gvsig.fmap.dal.complements;
7

    
8
import java.util.Comparator;
9
import java.util.List;
10
import java.util.function.Predicate;
11
import org.apache.commons.lang3.StringUtils;
12
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
13
import org.gvsig.fmap.dal.feature.FeatureType;
14
import org.gvsig.tools.complement.Complement;
15
import org.gvsig.tools.dataTypes.DataTypes;
16

    
17
/**
18
 *
19
 * @author jjdelcerro
20
 */
21
public interface Search extends Complement<FeatureType> {
22

    
23
    public static final String COMPLEMENT_MANE = "DAL.Search";
24

    
25
    public static final String DAL_SEARCH_RESULT_COLUMNS = "DAL.Search.Result.Columns";
26
    public static final String DAL_SEARCH_ATTRIBUTE_PRIORITY = "DAL.Search.Attribute.Priority";
27

    
28
    public static Predicate<FeatureAttributeDescriptor> BASIC_TYPES_FILTER = FeatureType.BASIC_TYPES_FILTER;
29
    public static Predicate<FeatureAttributeDescriptor> ALL_FILTER = FeatureType.ALL_FILTER;
30
    
31
    public static final Comparator<FeatureAttributeDescriptor> LABEL_ORDER = new Comparator<FeatureAttributeDescriptor>() {
32
        @Override
33
        public int compare(FeatureAttributeDescriptor o1, FeatureAttributeDescriptor o2) {
34
            return StringUtils.compareIgnoreCase(o1.getLabel(), o2.getLabel());
35
        }
36
    };
37

    
38
    public static final Comparator<FeatureAttributeDescriptor> STR_INT_LONG_LABEL_ORDER = new Comparator<FeatureAttributeDescriptor>() {
39
        @Override
40
        public int compare(FeatureAttributeDescriptor o1, FeatureAttributeDescriptor o2) {
41
            int t1 = o1.getType();
42
            int t2 = o2.getType();
43
            if (t1 == DataTypes.STRING) {
44
                if (t2 == DataTypes.STRING) {
45
                    return StringUtils.compareIgnoreCase(o1.getLabel(), o2.getLabel());
46
                }
47
                return -1;
48
            } else if (t2 == DataTypes.STRING) {
49
                return 1;
50
            }
51
            if (t1 == DataTypes.INT || t1 == DataTypes.LONG) {
52
                if (t2 == DataTypes.INT || t2 == DataTypes.LONG) {
53
                    return StringUtils.compareIgnoreCase(o1.getLabel(), o2.getLabel());
54
                }
55
                return -1;
56
            } else if (t2 == DataTypes.INT || t2 == DataTypes.LONG) {
57
                return 1;
58
            }
59
            return StringUtils.compareIgnoreCase(o1.getLabel(), o2.getLabel());
60
        }
61
    };
62

    
63

    
64
    public int getPriority(FeatureAttributeDescriptor attribute); 
65
    
66
    public List<String> getResultColumnNames();
67
    
68
    public List<FeatureAttributeDescriptor> getOrderedAttributes(
69
            Predicate<FeatureAttributeDescriptor> filter,
70
            Comparator<FeatureAttributeDescriptor> comparator,
71
            int max
72
    );
73

    
74
    public List<FeatureAttributeDescriptor> getFavorites();
75
    
76
}