org.bdgp.io
Class DataAdapterRegistry

java.lang.Object
  |
  +--org.bdgp.io.DataAdapterRegistry

public class DataAdapterRegistry
extends java.lang.Object

A registry of data adapters. This class allows data adapters to be dynamically loaded and managed at runtime. The DataAdapterRegistry can provide the name, type, supported operations, etc. for a dynamically loaded DataAdapter. In order to get this information, the data adapter must be instantiated immediately after the class is loaded. Therefore, all data adapters that will be loaded by the registry MUST provide a zero-argument constructor. Otherwise the installation of the adapter will fail.


Constructor Summary
DataAdapterRegistry()
          Creates a new DataAdapterRegistry
 
Method Summary
protected  boolean adapterAtIndexSupports(int index, IOOperation op)
          Returns a boolean indicated whether the data adapter at the given index supports the given IOOperation.
 boolean adapterSupports(java.lang.String className, IOOperation op)
          Returns a boolean indicating whether a data adapter supports a particular IOOperation.
 DataAdapter getAdapter(java.lang.String className)
          Returns a new instance of a driver with the given class name.
 java.lang.String[] getAdapterNames()
          Returns the class names of all installed adapters.
 java.lang.String[] getAdapterNames(IOOperation op)
          Returns the class names of all installed adapters that support the given IOOperation.
 java.lang.String[] getAdapterNames(IOOperation op, boolean visualOnly)
          Returns the class names of all installed adapters that support the given IOOperation.
protected  int getIndexOfAdapter(java.lang.String className)
          Returns the index of the given adapter
 java.lang.String getNameForAdapter(java.lang.String className)
          Returns the name of the data adapter with the given class name.
 IOOperation[] getSupportedOperations(java.lang.String className)
          Returns the supported operations of the data adapter with the given class name.
 java.lang.String getTypeForAdapter(java.lang.String className)
          Returns the type of the data adapter with the given class name.
 void installDataAdapter(java.lang.String className)
          Installs a data adapter to this registry.
 boolean isInstalled(java.lang.String className)
           
 void removeDataAdapter(java.lang.String className)
          Uninstalls an adapter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataAdapterRegistry

public DataAdapterRegistry()
Creates a new DataAdapterRegistry
Method Detail

installDataAdapter

public void installDataAdapter(java.lang.String className)
                        throws DataAdapterException
Installs a data adapter to this registry.

getAdapter

public DataAdapter getAdapter(java.lang.String className)
Returns a new instance of a driver with the given class name.

isInstalled

public boolean isInstalled(java.lang.String className)

getNameForAdapter

public java.lang.String getNameForAdapter(java.lang.String className)
Returns the name of the data adapter with the given class name. This method will return the same value that would be returned by calling getName() on a new instance of a data adapter of the appropriate type.

getTypeForAdapter

public java.lang.String getTypeForAdapter(java.lang.String className)
Returns the type of the data adapter with the given class name. This method will return the same value that would be returned by calling getType() on a new instance of a data adapter of the appropriate type.

getSupportedOperations

public IOOperation[] getSupportedOperations(java.lang.String className)
Returns the supported operations of the data adapter with the given class name. This method will return the same value that would be returned by calling getName() on a new instance of a data adapter of the appropriate type.

adapterSupports

public boolean adapterSupports(java.lang.String className,
                               IOOperation op)
Returns a boolean indicating whether a data adapter supports a particular IOOperation.

getAdapterNames

public java.lang.String[] getAdapterNames()
Returns the class names of all installed adapters.

getAdapterNames

public java.lang.String[] getAdapterNames(IOOperation op)
Returns the class names of all installed adapters that support the given IOOperation. If the given operation is null, all data adapters will be returned.

getAdapterNames

public java.lang.String[] getAdapterNames(IOOperation op,
                                          boolean visualOnly)
Returns the class names of all installed adapters that support the given IOOperation. If visualOnly is true, only data adapters that implement the VisualDataAdapter interface will be returned.

adapterAtIndexSupports

protected boolean adapterAtIndexSupports(int index,
                                         IOOperation op)
Returns a boolean indicated whether the data adapter at the given index supports the given IOOperation. The index is an index into the array given by getAdapterNames(). The correct index for an adapter can be determined by calling getIndexOfAdapter(String)

getIndexOfAdapter

protected int getIndexOfAdapter(java.lang.String className)
Returns the index of the given adapter

removeDataAdapter

public void removeDataAdapter(java.lang.String className)
Uninstalls an adapter. This method does NOT unload the class definition from the JVM. It simply removes the adapter from the AdapterRegistry's list of available adapters.