gate
Class Gate

java.lang.Object
  |
  +--gate.Gate

public class Gate
extends Object

The class is responsible for initialising the GATE libraries, and providing access to singleton utility objects, such as the GATE class loader, CREOLE register and so on.


Field Summary
private static String[] builtinCreoleDirectoryUrls
          The list of builtin URLs to search for CREOLE resources.
private static GateClassLoader classLoader
          Class loader used e.g.
private static CreoleRegister creoleRegister
          The CREOLE register.
private static DataStoreRegister dataStoreRegister
          The DataStore register
private static boolean DEBUG
          Debug flag
private static boolean localWebServer
          Flag controlling whether we should try to access a web server on localhost, e.g.
protected static String MIN_JDK_VERSION
          Minimum version of JDK we support
private static boolean netConnected
          Flag controlling whether we should try to access the net, e.g.
private static URL urlBase
          The URL base for GATE files, e.g.
 
Constructor Summary
Gate()
           
 
Method Summary
static void addCreoleListener(CreoleListener l)
          Registers a CreoleListener with the Gate system
static boolean getApplicationAttribute(FeatureMap fm)
          Returns the value for the APPLICATION attribute of a feature map
static GateClassLoader getClassLoader()
          Get the GATE class loader.
static CreoleRegister getCreoleRegister()
          Get the CREOLE register.
static DataStoreRegister getDataStoreRegister()
          Get the DataStore register.
static boolean getHiddenAttribute(FeatureMap fm)
          Returns the value for the HIDDEN attribute of a feature map
static String getMinJdkVersion()
          Get the minimum supported version of the JDK
static String getName(FeatureMap fm)
          Gets the NAME attribute feature map.
static URL getUrl()
          Get a URL that points to either an HTTP server or a file system that contains GATE files (such as test cases).
static URL getUrl(String path)
          Get a URL that points to either an HTTP server or a file system that contains GATE files (such as test cases).
static void init()
          Initialisation - must be called by all clients before using any other parts of the library.
static void initConfigData()
          Reads config data (gate.xml files).
static void initCreoleRegister()
          Initialise the CREOLE register.
static void initDataStoreRegister()
          Initialise the DataStore register.
static boolean isLocalWebServer()
          Should we assume there's a local web server?
static boolean isNetConnected()
          Should we assume we're connected to the net?
static String locateGateFiles()
          Find the location of the GATE binaries (and resources) in the local file system.
static void setApplicationAttribute(FeatureMap fm, boolean isApplication)
          Sets the value for the APPLICATION attribute of a feature map
static void setHiddenAttribute(FeatureMap fm, boolean hidden)
          Sets the value for the HIDDEN attribute of a feature map
static void setLocalWebServer(boolean b)
          Tell GATE whether to assume there's a local web server.
static void setName(FeatureMap fm, String name)
          Sets the NAME attribute in a feature map.
static void setNetConnected(boolean b)
          Tell GATE whether to assume we're connected to the net.
static void setUrlBase(URL urlBase)
          Set the URL base for GATE files, e.g.
protected static boolean tryFileSystem()
          Try to find GATE files in the local file system
static boolean tryNetServer(String hostName, int serverPort, String path)
          Try to contact a network server.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

DEBUG

private static final boolean DEBUG
Debug flag

builtinCreoleDirectoryUrls

private static String[] builtinCreoleDirectoryUrls
The list of builtin URLs to search for CREOLE resources.

MIN_JDK_VERSION

protected static final String MIN_JDK_VERSION
Minimum version of JDK we support

netConnected

private static boolean netConnected
Flag controlling whether we should try to access the net, e.g. when setting up a base URL.

localWebServer

private static boolean localWebServer
Flag controlling whether we should try to access a web server on localhost, e.g. when setting up a base URL. Has to be called before init().

urlBase

private static URL urlBase
The URL base for GATE files, e.g. http://gate.ac.uk/.

classLoader

private static GateClassLoader classLoader
Class loader used e.g. for loading CREOLE modules, of compiling JAPE rule RHSs.

creoleRegister

private static CreoleRegister creoleRegister
The CREOLE register.

dataStoreRegister

private static DataStoreRegister dataStoreRegister
The DataStore register
Constructor Detail

Gate

public Gate()
Method Detail

getMinJdkVersion

public static String getMinJdkVersion()
Get the minimum supported version of the JDK

init

public static void init()
                 throws GateException
Initialisation - must be called by all clients before using any other parts of the library. Also initialises the CREOLE register and reads config data (gate.xml files).
See Also:
initCreoleRegister()

initCreoleRegister

public static void initCreoleRegister()
                               throws GateException
Initialise the CREOLE register.

initDataStoreRegister

public static void initDataStoreRegister()
Initialise the DataStore register.

initConfigData

public static void initConfigData()
                           throws GateException
Reads config data (gate.xml files).

getUrl

public static URL getUrl()
                  throws GateException
Get a URL that points to either an HTTP server or a file system that contains GATE files (such as test cases). The following locations are tried in sequence: In each case we assume that a Web server will be running on port 80, and that if we can open a socket to that port then the server is running. (This is a bit of a strong assumption, but this URL is used largely by the test suite, so we're not betting anything too critical on it.)

Note that the value returned will only be calculated when the existing value recorded by this class is null (which will be the case when neither setUrlBase nor getUrlBase have been called, or if setUrlBase(null) has been called).


getUrl

public static URL getUrl(String path)
                  throws GateException
Get a URL that points to either an HTTP server or a file system that contains GATE files (such as test cases). Calls getUrl() then adds the path parameter to the result.
Parameters:
path - a path to add to the base URL.
See Also:
getUrl()

isNetConnected

public static boolean isNetConnected()
Should we assume we're connected to the net?

setNetConnected

public static void setNetConnected(boolean b)
Tell GATE whether to assume we're connected to the net. Has to be called before init().

isLocalWebServer

public static boolean isLocalWebServer()
Should we assume there's a local web server?

setLocalWebServer

public static void setLocalWebServer(boolean b)
Tell GATE whether to assume there's a local web server.

tryNetServer

public static boolean tryNetServer(String hostName,
                                   int serverPort,
                                   String path)
                            throws MalformedURLException
Try to contact a network server. When sucessfull sets urlBase to an HTTP URL for the server.
Parameters:
hostName - the name of the host to try and connect to
serverPort - the port to try and connect to
path - a path to append to the URL when we make a successfull connection. E.g. for host xyz, port 80, path /thing, the resultant URL would be http://xyz:80/thing.

tryFileSystem

protected static boolean tryFileSystem()
                                throws MalformedURLException
Try to find GATE files in the local file system

locateGateFiles

public static String locateGateFiles()
Find the location of the GATE binaries (and resources) in the local file system.

getHiddenAttribute

public static boolean getHiddenAttribute(FeatureMap fm)
Returns the value for the HIDDEN attribute of a feature map

setHiddenAttribute

public static void setHiddenAttribute(FeatureMap fm,
                                      boolean hidden)
Sets the value for the HIDDEN attribute of a feature map

getApplicationAttribute

public static boolean getApplicationAttribute(FeatureMap fm)
Returns the value for the APPLICATION attribute of a feature map

setApplicationAttribute

public static void setApplicationAttribute(FeatureMap fm,
                                           boolean isApplication)
Sets the value for the APPLICATION attribute of a feature map

getName

public static String getName(FeatureMap fm)
Gets the NAME attribute feature map.

setName

public static void setName(FeatureMap fm,
                           String name)
Sets the NAME attribute in a feature map.

addCreoleListener

public static void addCreoleListener(CreoleListener l)
Registers a CreoleListener with the Gate system

setUrlBase

public static void setUrlBase(URL urlBase)
Set the URL base for GATE files, e.g. http://gate.ac.uk/.

getClassLoader

public static GateClassLoader getClassLoader()
Get the GATE class loader.

getCreoleRegister

public static CreoleRegister getCreoleRegister()
Get the CREOLE register.

getDataStoreRegister

public static DataStoreRegister getDataStoreRegister()
Get the DataStore register.