View Javadoc

1   /*
2    ORDI - Ontology Repository and Data Integration
3   
4    Copyright (c) 2004-2007, OntoText Lab. / SIRMA
5   
6    This library is free software; you can redistribute it and/or modify it under
7    the terms of the GNU Lesser General Public License as published by the Free
8    Software Foundation; either version 2.1 of the License, or (at your option)
9    any later version.
10   This library is distributed in the hope that it will be useful, but WITHOUT
11   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12   FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13   details.
14   You should have received a copy of the GNU Lesser General Public License along
15   with this library; if not, write to the Free Software Foundation, Inc.,
16   59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17   */
18  package com.ontotext.ordi;
19  
20  import com.ontotext.ordi.exception.ORDIException;
21  
22  /**
23   * Interface for ORDI classes to provide ability to retrieve the delegate
24   * instance when the instance in question is in fact proxy class.
25   * 
26   * @see java.sql.Wrapper
27   * @author vassil
28   */
29  public interface Wrapper {
30  
31      /**
32       * Returns true if this either implements the interface argument or is
33       * directly or indirectly a wrapper for an object that does.
34       * 
35       * @param iface
36       *            A Class defining an interface that the result must implement.
37       * @return an object that implements the interface. May be a proxy for the
38       *         actual implementing object.
39       * @throws ORDIException
40       */
41      public boolean isWrapperFor(Class<?> iface) throws ORDIException;
42  
43      /**
44       * Returns an object that implements the given interface to allow access to
45       * non-standard methods, or standard methods not exposed by the proxy.
46       * 
47       * @param iface
48       *            a Class defining an interface.
49       * @return true if this implements the interface or directly or indirectly
50       *         wraps an object that does.
51       * @throws ORDIException
52       */
53      public <T> T unwrap(Class<T> iface) throws ORDIException;
54  }