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 @ 44340
History | View | Annotate | Download (3.07 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_ATTRIBUTE_PRIORITY = "DAL.Search.Attribute.Priority"; |
26 |
|
27 |
public static Predicate<FeatureAttributeDescriptor> BASIC_TYPES_FILTER = FeatureType.BASIC_TYPES_FILTER; |
28 |
public static Predicate<FeatureAttributeDescriptor> ALL_FILTER = FeatureType.ALL_FILTER; |
29 |
|
30 |
public static final Comparator<FeatureAttributeDescriptor> LABEL_ORDER = new Comparator<FeatureAttributeDescriptor>() { |
31 |
@Override
|
32 |
public int compare(FeatureAttributeDescriptor o1, FeatureAttributeDescriptor o2) { |
33 |
return StringUtils.compareIgnoreCase(o1.getLabel(), o2.getLabel());
|
34 |
} |
35 |
}; |
36 |
|
37 |
public static final Comparator<FeatureAttributeDescriptor> STR_INT_LONG_LABEL_ORDER = new Comparator<FeatureAttributeDescriptor>() { |
38 |
@Override
|
39 |
public int compare(FeatureAttributeDescriptor o1, FeatureAttributeDescriptor o2) { |
40 |
int t1 = o1.getType();
|
41 |
int t2 = o2.getType();
|
42 |
if (t1 == DataTypes.STRING) {
|
43 |
if (t2 == DataTypes.STRING) {
|
44 |
return StringUtils.compareIgnoreCase(o1.getLabel(), o2.getLabel());
|
45 |
} |
46 |
return -1; |
47 |
} else if (t2 == DataTypes.STRING) { |
48 |
return 1; |
49 |
} |
50 |
if (t1 == DataTypes.INT || t1 == DataTypes.LONG) {
|
51 |
if (t2 == DataTypes.INT || t2 == DataTypes.LONG) {
|
52 |
return StringUtils.compareIgnoreCase(o1.getLabel(), o2.getLabel());
|
53 |
} |
54 |
return -1; |
55 |
} else if (t2 == DataTypes.INT || t2 == DataTypes.LONG) { |
56 |
return 1; |
57 |
} |
58 |
return StringUtils.compareIgnoreCase(o1.getLabel(), o2.getLabel());
|
59 |
} |
60 |
}; |
61 |
|
62 |
|
63 |
public int getPriority(FeatureAttributeDescriptor attribute); |
64 |
|
65 |
public List<String> getResultColumnNames(); |
66 |
|
67 |
public interface OrderedAttribute { |
68 |
public static final int TYPE_REGURAL = 0; |
69 |
public static final int TYPE_RECENT = 1; |
70 |
public static final int TYPE_FAVORITE = 2; |
71 |
|
72 |
public FeatureAttributeDescriptor getDescriptor();
|
73 |
public int getType(); |
74 |
} |
75 |
public List<OrderedAttribute> getOrderedAttributes( |
76 |
Predicate<FeatureAttributeDescriptor> filter,
|
77 |
Comparator<FeatureAttributeDescriptor> comparator,
|
78 |
int max
|
79 |
); |
80 |
|
81 |
public List<FeatureAttributeDescriptor> getFavorites(); |
82 |
|
83 |
} |