2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.remote
.json
.processor
.value
;
12 import net
.sf
.json
.JsonConfig
;
13 import net
.sf
.json
.processors
.JsonValueProcessor
;
15 import org
.apache
.logging
.log4j
.LogManager
;import org
.apache
.logging
.log4j
.Logger
;
16 import org
.joda
.time
.Partial
;
17 import org
.joda
.time
.format
.ISODateTimeFormat
;
19 import eu
.etaxonomy
.cdm
.hibernate
.PartialUserType
;
22 * Partial time as four digit year, two digit month of year, and two digit day of month (yyyy-MM-dd).
23 * @author a.kohlbecker
27 public class PartialJSONValueProcessor
implements JsonValueProcessor
{
28 private static Logger logger
= LogManager
.getLogger(PartialJSONValueProcessor
.class);
32 * @see net.sf.json.processors.JsonValueProcessor#processArrayValue(java.lang.Object, net.sf.json.JsonConfig)
34 public Object
processArrayValue(Object object
, JsonConfig jsonConfig
) {
38 Partial partial
= (Partial
) object
;
39 if (logger
.isDebugEnabled()) {
40 logger
.debug("processArrayValue of joda.time.DateTime: " + PartialUserType
.partialToString(partial
));
42 return partial
.toString(ISODateTimeFormat
.date());
46 * @see net.sf.json.processors.JsonValueProcessor#processObjectValue(java.lang.String, java.lang.Object, net.sf.json.JsonConfig)
48 public Object
processObjectValue(String key
, Object object
, JsonConfig jsonConfig
) {
52 Partial partial
= (Partial
) object
;
53 if (logger
.isDebugEnabled()) {
54 logger
.debug("processObjectValue of joda.time.DateTime: " + PartialUserType
.partialToString(partial
));
56 return partial
.toString(ISODateTimeFormat
.date());