svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.swing / org.gvsig.fmap.dal.swing.impl / src / main / java / org / gvsig / fmap / dal / swing / impl / searchPostProcess / distinctOn / FirstAggregateOperation.java @ 46542
History | View | Annotate | Download (1.39 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.swing.impl.searchPostProcess.distinctOn; |
7 |
|
8 |
/**
|
9 |
*
|
10 |
* @author jovivas
|
11 |
*/
|
12 |
public class FirstAggregateOperation extends AbstractAggregateOperation { |
13 |
public static class FirstAggregateOperationFactory implements AggregateOperationFactory{ |
14 |
|
15 |
public static final String NAME = "First value"; |
16 |
|
17 |
@Override
|
18 |
public String getName() { |
19 |
return NAME;
|
20 |
} |
21 |
|
22 |
@Override
|
23 |
public AggregateOperation create(Object... os) { |
24 |
return new FirstAggregateOperation(); |
25 |
} |
26 |
|
27 |
@Override
|
28 |
public boolean isApplicable(Object... value) { |
29 |
return true; |
30 |
} |
31 |
} |
32 |
|
33 |
Object first;
|
34 |
boolean isFirst = true; |
35 |
|
36 |
public FirstAggregateOperation() {
|
37 |
this.first = null; |
38 |
} |
39 |
|
40 |
@Override
|
41 |
public boolean isApplicable(Object... value) { |
42 |
return true; |
43 |
} |
44 |
|
45 |
@Override
|
46 |
public void reset() { |
47 |
this.first = null; |
48 |
this.isFirst=true; |
49 |
} |
50 |
|
51 |
@Override
|
52 |
public void perform(Object value) { |
53 |
if (isFirst) {
|
54 |
this.first = value;
|
55 |
isFirst = false;
|
56 |
} |
57 |
} |
58 |
|
59 |
@Override
|
60 |
public Object getValue() { |
61 |
return this.first; |
62 |
} |
63 |
|
64 |
} |