1
|
/**
|
2
|
* Copyright (C) 2009 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.cdm.hibernate.search;
|
11
|
|
12
|
import org.hibernate.search.bridge.StringBridge;
|
13
|
import org.joda.time.DateTimeFieldType;
|
14
|
import org.joda.time.Partial;
|
15
|
|
16
|
public class PartialBridge implements StringBridge {
|
17
|
|
18
|
public String objectToString(Object object) {
|
19
|
if(object != null) {
|
20
|
Partial partial = ((Partial)object);
|
21
|
StringBuilder stringBuilder = new StringBuilder();
|
22
|
if(partial.isSupported(DateTimeFieldType.year())) {
|
23
|
stringBuilder.append(partial.get(DateTimeFieldType.year()));
|
24
|
|
25
|
if(partial.isSupported(DateTimeFieldType.monthOfYear())) {
|
26
|
stringBuilder.append(partial.get(DateTimeFieldType.monthOfYear()));
|
27
|
|
28
|
if(partial.isSupported(DateTimeFieldType.dayOfYear())) {
|
29
|
stringBuilder.append(partial.get(DateTimeFieldType.dayOfYear()));
|
30
|
}
|
31
|
}
|
32
|
return stringBuilder.toString();
|
33
|
}
|
34
|
}
|
35
|
return null;
|
36
|
}
|
37
|
|
38
|
}
|