Coverage report

  %line %branch
org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl.TimestampTypeConverterImpl
0% 
0% 

 1  
 /*
 2  
  * Copyright 2004-2005 The Apache Software Foundation or its licensors,
 3  
  *                     as applicable.
 4  
  *
 5  
  * Licensed under the Apache License, Version 2.0 (the "License");
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  *
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 
 18  
 package org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl;
 19  
 
 20  
 import java.sql.Timestamp;
 21  
 
 22  
 import javax.jcr.RepositoryException;
 23  
 import javax.jcr.Value;
 24  
 import javax.jcr.ValueFactory;
 25  
 
 26  
 import org.apache.portals.graffito.jcr.exception.IncorrectAtomicTypeException;
 27  
 import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter;
 28  
 
 29  
 /**
 30  
  * 
 31  
  * Timestamp Type Converter
 32  
  * 
 33  
  * @author <a href="mailto:christophe.lombart@gmail.com">Christophe Lombart</a>
 34  
  * @author <a href='mailto:the_mindstorm[at]evolva[dot]ro'>Alexandru Popescu</a>
 35  
  */
 36  0
 public class TimestampTypeConverterImpl implements AtomicTypeConverter
 37  
 {
 38  
 	/**
 39  
 	 * 
 40  
 	 * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getValue(java.lang.Object)
 41  
 	 */
 42  
 	public Value getValue(ValueFactory valueFactory, Object propValue)
 43  
 	{
 44  0
 		if (propValue == null)
 45  0
 			return null;
 46  0
 		long value = ((Timestamp) propValue).getTime();
 47  0
 		return valueFactory.createValue(value);
 48  
 	}
 49  
 
 50  
     /**
 51  
      * 
 52  
      * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Value)
 53  
      */
 54  
 	public Object getObject(Value value)
 55  
     {
 56  
 		try
 57  
 		{
 58  0
 			long beanPropValue = value.getLong();
 59  0
 			return new Timestamp(beanPropValue);
 60  
 		}
 61  0
 		catch (RepositoryException e)
 62  
 		{
 63  0
 			throw new IncorrectAtomicTypeException("Impossible to convert the value : " + value.toString(), e);
 64  
 		}
 65  
 	}
 66  
 	
 67  
 	/**
 68  
 	 * 
 69  
 	 * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getStringValue(java.lang.Object)
 70  
 	 */
 71  
 	public String getStringValue(Object object)
 72  
 	{
 73  0
 		return new Long(((Timestamp) object).getTime()).toString();
 74  
 	}	
 75  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.