| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| SqlTimestampAdapter |
|
| 2.0;2 |
| 1 | /* | |
| 2 | * Copyright 2007-2010 The Kuali Foundation | |
| 3 | * | |
| 4 | * Licensed under the Educational Community License, Version 2.0 (the "License"); | |
| 5 | * you may not use this file except in compliance with the License. | |
| 6 | * You may obtain a copy of the License at | |
| 7 | * | |
| 8 | * http://www.opensource.org/licenses/ecl2.php | |
| 9 | * | |
| 10 | * Unless required by applicable law or agreed to in writing, software | |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | * See the License for the specific language governing permissions and | |
| 14 | * limitations under the License. | |
| 15 | */ | |
| 16 | package org.kuali.rice.core.api.util.jaxb; | |
| 17 | ||
| 18 | import org.apache.commons.lang.StringUtils; | |
| 19 | ||
| 20 | import javax.xml.bind.annotation.adapters.XmlAdapter; | |
| 21 | import java.sql.Timestamp; | |
| 22 | ||
| 23 | /** | |
| 24 | * This class allows for a {@link java.sql.Timestamp} instance to be passed across the wire by jaxws enabled services | |
| 25 | * | |
| 26 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
| 27 | * | |
| 28 | */ | |
| 29 | 0 | public class SqlTimestampAdapter extends XmlAdapter<String, Timestamp> { |
| 30 | ||
| 31 | /** | |
| 32 | * This overridden method ... | |
| 33 | * | |
| 34 | * @see javax.xml.bind.annotation.adapters.XmlAdapter#marshal(java.lang.Object) | |
| 35 | */ | |
| 36 | @Override | |
| 37 | public String marshal(Timestamp timestamp) throws Exception { | |
| 38 | 0 | return (null != timestamp ? Long.toString(timestamp.getTime()) : null); |
| 39 | } | |
| 40 | ||
| 41 | /** | |
| 42 | * This overridden method ... | |
| 43 | * | |
| 44 | * @see javax.xml.bind.annotation.adapters.XmlAdapter#unmarshal(java.lang.Object) | |
| 45 | */ | |
| 46 | @Override | |
| 47 | public Timestamp unmarshal(String timestampStr) throws Exception { | |
| 48 | 0 | return (StringUtils.isNotBlank(timestampStr) ? new Timestamp(Long.parseLong(timestampStr)) : null); |
| 49 | } | |
| 50 | ||
| 51 | } |