JTwain v9 - Lab Asprise! All Rights Reserved.

com.asprise.util.jtwain
Class SourceManager

java.lang.Object
  extended bycom.asprise.util.jtwain.SourceManager

public class SourceManager
extends Object

The SourceManager class represents a TWAIN Source Manager. There is one and only one Data Source Manager.

See Also:
Source

Method Summary
 void closeSource()
          Closes the current active source.
static void closeSourceManager()
          Closes the source manager.
 Source[] getAllSources()
          Queries all the available sources.
 Source getCurrentSource()
          Gets the current active source.
 Source getDefaultSource()
          Gets the default data source.
 String getJTwainDLLVersion()
          Returns the version of JTwain native DLL used.
static String getLibraryPath()
          Get the DLL library path.
 int getState()
          Gets the state of the source.
static SourceManager instance()
          Gets the singleton instance of SourceManager.
 boolean isTwainAvailable()
          Checks whether the system supports Twain.
 void openSource(Source source)
          Opens the target data source.
 Source selectSource(Source source)
          Selects a Source and a Source as the current active source.
 Source selectSourceByName(String sourceName)
          Selects the source with the specified name as the current active source.
 Source selectSourceUI()
          Displays a dialog to let the user select a data source.
static void setLibraryPath(String libraryPath)
          Set the DLL library path.
static void unloadSourceManager()
          Unloads source manager.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

instance

public static SourceManager instance()
                              throws JTwainException
Gets the singleton instance of SourceManager.

Returns:
the unique instance of SourceManager
Throws:
JTwainException

isTwainAvailable

public boolean isTwainAvailable()
Checks whether the system supports Twain. Status of source manager will not be changed.

Returns:
true if the system supports Twain; false otherwise.

getJTwainDLLVersion

public String getJTwainDLLVersion()
Returns the version of JTwain native DLL used.

Returns:

getAllSources

public Source[] getAllSources()
Queries all the available sources. Source manager will be opened if it has not been opened yet.

Returns:
an array contains all the Sources.

getDefaultSource

public Source getDefaultSource()
Gets the default data source. Source manager will be opened if it has not been opened yet.

Returns:
the default data source. null if no source available.

openSource

public void openSource(Source source)
                throws JTwainException
Opens the target data source. Any previously opened source will be closed

Parameters:
source - the target source to be opened
Throws:
JTwainException

getCurrentSource

public Source getCurrentSource()
Gets the current active source.

Returns:
the current active source; null if there is no source opened.

getState

public int getState()
             throws JTwainException
Gets the state of the source.

Returns:
the state of the source. Possible values:
  • 1 - Pre-Session
  • 2 - Source Manager Loaded
  • 3 - Source Manager Open
  • 4 - Source Open
  • 5 - Source Enabled
  • 6 - Transfer Ready
  • 7 - Transferring
Throws:
JTwainException

closeSource

public void closeSource()
                 throws JTwainException
Closes the current active source.

Throws:
JTwainException

closeSourceManager

public static void closeSourceManager()
Closes the source manager.


unloadSourceManager

public static void unloadSourceManager()
Unloads source manager.


selectSourceUI

public Source selectSourceUI()
Displays a dialog to let the user select a data source. Source manager will be opened if it has not been opened yet.

Returns:
the selected data source; null if the user presses CANCEL button.

selectSource

public Source selectSource(Source source)
Selects a Source and a Source as the current active source. There can only be one active source at any time. Source manager will be opened if it has not been opened yet.

Parameters:
source - the Source to be select. null argument results source selection dialog.
Returns:
a Source with full details, i.e., complete profile identity.

selectSourceByName

public Source selectSourceByName(String sourceName)
Selects the source with the specified name as the current active source. Use getAllSources() to query sources and their names. There can only be one active source at any time. Source manager will be opened if it has not been opened yet.

Parameters:
sourceName - the name of the Source to be select. null argument results source selection dialog.
Returns:
a Source with full details, i.e., complete profile identity.
See Also:
getAllSources()

setLibraryPath

public static void setLibraryPath(String libraryPath)
Set the DLL library path. The default library path is null, in which case the system will load the DLL library from default locations, such as system directory.

Parameters:
libraryPath - path of the DLL library to be loaded; set to null to let the system load the library by automatic search.

getLibraryPath

public static String getLibraryPath()
Get the DLL library path.

Returns:
the library path. null if no library path has been set yet.

JTwain v9 - Lab Asprise! All Rights Reserved.