GATE
Version 3.1-2270

gate.creole.gazetteer
Class LinearDefinition

java.lang.Object
  extended by gate.util.AbstractFeatureBearer
      extended by gate.creole.AbstractResource
          extended by gate.creole.AbstractLanguageResource
              extended by gate.creole.gazetteer.LinearDefinition
All Implemented Interfaces:
LanguageResource, Resource, FeatureBearer, NameBearer, Serializable, Iterable, Collection, List

public class LinearDefinition
extends AbstractLanguageResource
implements List

Represents a Linear Definition [lists.def] file
The normal usage of the class will be * construct it * setURL * load * change * store

See Also:
Serialized Form

Field Summary
 
Fields inherited from class gate.creole.AbstractLanguageResource
dataStore, lrPersistentId
 
Fields inherited from class gate.creole.AbstractResource
name
 
Fields inherited from class gate.util.AbstractFeatureBearer
features
 
Constructor Summary
LinearDefinition()
           
 
Method Summary
 void add(int index, Object o)
           
 boolean add(Object o)
          adds a new node, only if its list is new and uniquely mapped to this node.
 boolean addAll(Collection c)
           
 boolean addAll(int index, Collection c)
           
 void clear()
           
 boolean contains(Object o)
           
 boolean containsAll(Collection c)
           
 boolean equals(Object o)
           
 Object get(int index)
           
 String getEncoding()
          Gets the encoding of the linear def
 Set getLanguages()
          Gets the set of all languages in this definition
 List getLists()
          Gets gazetteer lists of this definition.
 Map getListsByNode()
          Gets the lists by node map
 Set getMajors()
          Gets the set of all major types in this definition
 Set getMinors()
          Gets the set of all minor types in this definition
 List getNodes()
          get the nodes of the definition as a list
 Map getNodesByListNames()
          Gets a map of lists names vs nodes
 URL getURL()
          Gets the url of this linear definition
 int indexOf(Object o)
           
 boolean isEmpty()
           
 boolean isModified()
          Gets the value of the isModified flag.
 Iterator iterator()
           
 int lastIndexOf(Object o)
           
 ListIterator listIterator()
           
 ListIterator listIterator(int index)
           
 void load()
          Loads linear definition if url is set
 Map loadLists()
          Loads the gazetteer lists and maps them to the nodes
 GazetteerList loadSingleList(String listName)
          Loads a single gazetteer list given a name
 Object remove(int index)
           
 boolean remove(Object o)
           
 boolean removeAll(Collection c)
           
 boolean retainAll(Collection c)
           
 Object set(int index, Object element)
           
 void setEncoding(String encod)
          Sets the encoding of the linear def
 void setURL(URL aUrl)
          Sets the url of this linear definition
 int size()
           
 void store()
          Stores this to a definition file.
 List subList(int fromIndex, int toIndex)
           
 Object[] toArray()
           
 Object[] toArray(Object[] a)
           
 
Methods inherited from class gate.creole.AbstractLanguageResource
cleanup, getDataStore, getLRPersistenceId, getParent, setDataStore, setLRPersistenceId, setParent, sync
 
Methods inherited from class gate.creole.AbstractResource
checkParameterValues, getBeanInfo, getName, getParameterValue, getParameterValue, init, removeResourceListeners, setName, setParameterValue, setParameterValue, setParameterValues, setParameterValues, setResourceListeners
 
Methods inherited from class gate.util.AbstractFeatureBearer
getFeatures, setFeatures
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.List
hashCode
 
Methods inherited from interface gate.Resource
getParameterValue, init, setParameterValue, setParameterValues
 
Methods inherited from interface gate.util.FeatureBearer
getFeatures, setFeatures
 
Methods inherited from interface gate.util.NameBearer
getName, setName
 

Constructor Detail

LinearDefinition

public LinearDefinition()
Method Detail

setEncoding

public void setEncoding(String encod)
Sets the encoding of the linear def

Parameters:
encod - the encoding to be set

getEncoding

public String getEncoding()
Gets the encoding of the linear def

Returns:
the encoding of the list

loadLists

public Map loadLists()
              throws ResourceInstantiationException
Loads the gazetteer lists and maps them to the nodes

Returns:
a map of nodes vs GazetteerLists
Throws:
ResourceInstantiationException

loadSingleList

public GazetteerList loadSingleList(String listName)
                             throws ResourceInstantiationException
Loads a single gazetteer list given a name

Parameters:
listName - the name of the list to be loaded
Returns:
the loaded gazetteer list
Throws:
ResourceInstantiationException

getListsByNode

public Map getListsByNode()
Gets the lists by node map

Returns:
a map of nodes vs lists

getNodesByListNames

public Map getNodesByListNames()
Gets a map of lists names vs nodes

Returns:
a map of lists names vs nodes

isModified

public boolean isModified()
Gets the value of the isModified flag.

Specified by:
isModified in interface LanguageResource
Overrides:
isModified in class AbstractLanguageResource
Returns:
true if the definition has been modified

getURL

public URL getURL()
Gets the url of this linear definition

Returns:
the url of this linear definition

setURL

public void setURL(URL aUrl)
Sets the url of this linear definition

Parameters:
aUrl - the url of this linear definition

load

public void load()
          throws ResourceInstantiationException
Loads linear definition if url is set

Throws:
ResourceInstantiationException

store

public void store()
           throws ResourceInstantiationException
Stores this to a definition file.

Throws:
ResourceInstantiationException

getLists

public List getLists()
Gets gazetteer lists of this definition. note that a new list is created so the adding and removing of lists will not affect the internal members. Also there is no setLists method since the leading member of the class is nodes, and lists cannot be added individually without being associated with a node.

Returns:
a list of the gazetteer lists names

getNodes

public List getNodes()
get the nodes of the definition as a list

Returns:
the list of nodes

getMajors

public Set getMajors()
Gets the set of all major types in this definition

Returns:
the set of all major types present in this definition

getMinors

public Set getMinors()
Gets the set of all minor types in this definition

Returns:
the set of all minor types present in this definition

getLanguages

public Set getLanguages()
Gets the set of all languages in this definition

Returns:
the set of all languages present in this definition

addAll

public boolean addAll(int index,
                      Collection c)
Specified by:
addAll in interface List

get

public Object get(int index)
Specified by:
get in interface List

set

public Object set(int index,
                  Object element)
Specified by:
set in interface List

add

public void add(int index,
                Object o)
Specified by:
add in interface List

remove

public Object remove(int index)
Specified by:
remove in interface List

indexOf

public int indexOf(Object o)
Specified by:
indexOf in interface List

lastIndexOf

public int lastIndexOf(Object o)
Specified by:
lastIndexOf in interface List

listIterator

public ListIterator listIterator()
Specified by:
listIterator in interface List

listIterator

public ListIterator listIterator(int index)
Specified by:
listIterator in interface List

subList

public List subList(int fromIndex,
                    int toIndex)
Specified by:
subList in interface List

size

public int size()
Specified by:
size in interface Collection
Specified by:
size in interface List

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Collection
Specified by:
isEmpty in interface List

contains

public boolean contains(Object o)
Specified by:
contains in interface Collection
Specified by:
contains in interface List

iterator

public Iterator iterator()
Specified by:
iterator in interface Iterable
Specified by:
iterator in interface Collection
Specified by:
iterator in interface List

toArray

public Object[] toArray()
Specified by:
toArray in interface Collection
Specified by:
toArray in interface List

toArray

public Object[] toArray(Object[] a)
Specified by:
toArray in interface Collection
Specified by:
toArray in interface List

add

public boolean add(Object o)
adds a new node, only if its list is new and uniquely mapped to this node.

Specified by:
add in interface Collection
Specified by:
add in interface List
Parameters:
o - a node
Returns:
true if the list of node is not already mapped with another node.

remove

public boolean remove(Object o)
Specified by:
remove in interface Collection
Specified by:
remove in interface List

containsAll

public boolean containsAll(Collection c)
Specified by:
containsAll in interface Collection
Specified by:
containsAll in interface List

addAll

public boolean addAll(Collection c)
Specified by:
addAll in interface Collection
Specified by:
addAll in interface List

removeAll

public boolean removeAll(Collection c)
Specified by:
removeAll in interface Collection
Specified by:
removeAll in interface List

retainAll

public boolean retainAll(Collection c)
Specified by:
retainAll in interface Collection
Specified by:
retainAll in interface List

clear

public void clear()
Specified by:
clear in interface Collection
Specified by:
clear in interface List

equals

public boolean equals(Object o)
Specified by:
equals in interface Collection
Specified by:
equals in interface List
Overrides:
equals in class Object

GATE
Version 3.1-2270