View Javadoc

1   /*
2    * Copyright Aduna (http://www.aduna-software.com/) (c) 2007.
3    *
4    * Licensed under the Aduna BSD-style license.
5    */
6   package org.openrdf.repository.augur.helpers;
7   
8   import info.aduna.iteration.ExceptionConvertingIteration;
9   import info.aduna.iteration.Iteration;
10  
11  import org.openrdf.query.QueryEvaluationException;
12  import org.openrdf.repository.RepositoryException;
13  
14  
15  /**
16   *
17   * @author Herko ter Horst
18   */
19  public class RepositoryCloseableIteration<E> extends ExceptionConvertingIteration<E, RepositoryException> {
20  
21  	/**
22  	 * @param iter
23  	 */
24  	public RepositoryCloseableIteration(Iteration<? extends E, ? extends QueryEvaluationException> iter) {
25  		super(iter);
26  	}
27  
28  	@Override
29  	protected RepositoryException convert(Exception e) {
30  		if(e instanceof QueryEvaluationException) {
31  			return new RepositoryException(e);			
32  		}
33  		else if(e instanceof RuntimeException) {
34  			throw (RuntimeException)e;
35  		}
36  		else if (e == null) {
37  			throw new IllegalArgumentException("e must not be null");
38  		}
39  		else {
40  			throw new IllegalArgumentException("Unexpected exception type: " + e.getClass());
41  		}
42  	}
43  }