Coverage report

  %line %branch
org.apache.portals.graffito.jcr.persistence.impl.ObjectIterator
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.impl;
 19  
 
 20  
 import java.util.Iterator;
 21  
 
 22  
 import javax.jcr.Node;
 23  
 import javax.jcr.NodeIterator;
 24  
 import javax.jcr.Session;
 25  
 
 26  
 import org.apache.portals.graffito.jcr.persistence.objectconverter.ObjectConverter;
 27  
 
 28  
 
 29  
 /**
 30  
  * ObjectIterator is a wrapper class for JCR NodeIterator
 31  
  * 
 32  
  * @author <a href="mailto:christophe.lombart@gmail.com">Christophe Lombart</a>
 33  
  *
 34  
  */
 35  
 public class ObjectIterator implements Iterator
 36  
 {
 37  
 
 38  
 	private NodeIterator nodeIterator;
 39  
 
 40  
 	private Class objectClass;
 41  
 
 42  
 	private Session session;
 43  
 
 44  
 	private ObjectConverter objectConverter;
 45  
 
 46  
 	
 47  
 	/**
 48  
 	 * Constructor 
 49  
 	 * 
 50  
 	 * @param iterator JCR node iterator 
 51  
 	 * @param objectClass the object class used to instantiate the objects
 52  
 	 * @param converter The object converter
 53  
 	 * @param session the JCR session 
 54  
 	 */
 55  
 	public ObjectIterator(NodeIterator iterator, Class objectClass, ObjectConverter converter, Session session)
 56  0
 	{
 57  0
 		nodeIterator = iterator;
 58  0
 		this.objectClass = objectClass;
 59  0
 		objectConverter = converter;
 60  0
 		this.session = session;
 61  0
 	}
 62  
 
 63  
 	/**
 64  
 	 * 
 65  
 	 * @see java.util.Iterator#hasNext()
 66  
 	 */
 67  
 	public boolean hasNext()
 68  
 	{
 69  0
 		return nodeIterator.hasNext();
 70  
 	}
 71  
 
 72  
 	/**
 73  
 	 * 
 74  
 	 * @see java.util.Iterator#next()
 75  
 	 */
 76  
 	public Object next() 
 77  
 	{
 78  
 
 79  
 		try
 80  
 		{
 81  0
 			Node node = nodeIterator.nextNode();
 82  0
 			return objectConverter.getObject(session, objectClass, node.getPath());
 83  
 		}
 84  0
 		catch (Exception e)
 85  
 		{
 86  0
            return null;			
 87  
 		}
 88  
 
 89  
 	}
 90  
 
 91  
 	/**
 92  
 	 * 
 93  
 	 * @see java.util.Iterator#remove()
 94  
 	 */
 95  
 	public void remove()
 96  
 	{
 97  0
 		nodeIterator.remove();
 98  0
 	}
 99  
 
 100  
 }

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