public class DefaultSimpleTreebank extends AbstractTreebank implements Treebank
Modifier and Type | Field and Description |
---|---|
protected java.util.List<SentenceData> |
buffer |
protected boolean |
editable |
protected Grammar |
grammar |
protected boolean |
loaded |
protected java.util.concurrent.atomic.AtomicBoolean |
loading |
protected TreebankMetaData |
metaData |
protected SentenceDataReader |
reader |
static java.lang.String |
READER_EXTENSION_PROPERTY |
static java.lang.String |
READER_PROPERTY_PREFIX |
protected org.java.plugin.registry.Extension |
readerExtension |
changeListeners, eventSource, location, name, properties
Constructor and Description |
---|
DefaultSimpleTreebank() |
Modifier and Type | Method and Description |
---|---|
void |
free()
|
SentenceData |
get(int index,
DataType type)
Synchronously fetches the
SentenceData object
for the specified index. |
SentenceData |
get(int index,
DataType type,
AvailabilityObserver observer)
Asynchronously fetches the
SentenceData object
for the specified index. |
de.ims.icarus.util.data.ContentType |
getContentType() |
TreebankMetaData |
getMetaData() |
org.java.plugin.registry.Extension |
getReader() |
SentenceDataReader |
getSentenceDataReader() |
boolean |
isEditable() |
boolean |
isLoaded() |
boolean |
isLoading() |
void |
load()
Loads this
Treebank . |
void |
loadState(TreebankDescriptor descriptor) |
void |
remove(int index,
DataType type)
Removes from this
Treebank the data stored at the
specified index that is associated with the given
type . |
void |
saveState(TreebankDescriptor descriptor) |
void |
set(SentenceData item,
int index,
DataType type)
Replaces
|
void |
setEditable(boolean editable) |
void |
setLocation(de.ims.icarus.util.location.Location location)
Sets the new
Location to be used for this
Treebank . |
void |
setReader(org.java.plugin.registry.Extension readerExtension) |
int |
size() |
boolean |
supportsType(DataType type) |
addChangeListener, addListener, destroy, fireChangeEvent, get, getDescription, getIcon, getId, getLocation, getName, getOwner, getProperties, getProperty, isDestroyed, removeChangeListener, removeListener, removeListener, setName, setProperty, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addListener, destroy, getLocation, getProperties, getProperty, isDestroyed, removeListener, removeListener, setName, setProperty
public static final java.lang.String READER_EXTENSION_PROPERTY
public static final java.lang.String READER_PROPERTY_PREFIX
protected java.util.List<SentenceData> buffer
protected boolean editable
protected Grammar grammar
protected final java.util.concurrent.atomic.AtomicBoolean loading
protected boolean loaded
protected transient SentenceDataReader reader
protected org.java.plugin.registry.Extension readerExtension
protected TreebankMetaData metaData
public void saveState(TreebankDescriptor descriptor)
saveState
in interface Treebank
saveState
in class AbstractTreebank
Treebank.saveState(de.ims.icarus.language.treebank.TreebankDescriptor)
public void loadState(TreebankDescriptor descriptor)
loadState
in interface Treebank
loadState
in class AbstractTreebank
Treebank.loadState(de.ims.icarus.language.treebank.TreebankDescriptor)
public void setLocation(de.ims.icarus.util.location.Location location)
AbstractTreebank
Location
to be used for this
Treebank
. Subsequent calls to #isLoaded()
will return false
at least until the first call
to #load()
is performedsetLocation
in interface Treebank
setLocation
in class AbstractTreebank
location
- the new Location
to be usedpublic void setReader(org.java.plugin.registry.Extension readerExtension)
public org.java.plugin.registry.Extension getReader()
public SentenceDataReader getSentenceDataReader()
public boolean isEditable()
isEditable
in interface Treebank
isEditable
in class AbstractTreebank
Treebank.isEditable()
public void setEditable(boolean editable)
public void set(SentenceData item, int index, DataType type)
Treebank
set
in interface Treebank
set
in class AbstractTreebank
Treebank.set(de.ims.icarus.language.SentenceData, int, de.ims.icarus.language.DataType)
public void remove(int index, DataType type)
Treebank
Treebank
the data stored at the
specified index
that is associated with the given
type
. The exact behavior in case of the type
argument being null
is implementation specific. The general
advice is to remove all data stored for that index, but implementations
might decide to ignore calls without a valid DataType
parameter.
In addition an implementation can remove all data for that index if
data of some important type was removed. I.e. a typical Treebank
representing parse or other annotation results created by an automated
process would drop an entire index when data of the type
is removed.remove
in interface Treebank
remove
in class AbstractTreebank
Treebank.remove(int, de.ims.icarus.language.DataType)
public boolean isLoaded()
isLoaded
in interface de.ims.icarus.io.Loadable
isLoaded
in interface Treebank
Treebank.isLoaded()
public boolean isLoading()
isLoading
in interface de.ims.icarus.io.Loadable
Loadable.isLoading()
public void load() throws java.lang.Exception
Treebank
Treebank
. In a typical synchronous
implementation this method will cover the entire
loading process and return once all data is loaded.
For asynchronous implementations this method returns
immediately and actual loading is done in a background
thread.load
in interface de.ims.icarus.io.Loadable
load
in interface Treebank
java.lang.Exception
- if the loading failedTreebank.load()
public int size()
size
in interface de.ims.icarus.util.data.DataList<SentenceData>
DataList.size()
public void free()
Treebank
free
in interface de.ims.icarus.io.Loadable
free
in interface Treebank
free
in class AbstractTreebank
Treebank.free()
public de.ims.icarus.util.data.ContentType getContentType()
getContentType
in interface de.ims.icarus.util.data.DataContainer
getContentType
in interface de.ims.icarus.util.data.DataList<SentenceData>
de.ims.icarus.language.treebank.Treebank#getEntryClass()
public TreebankMetaData getMetaData()
getMetaData
in interface Treebank
Treebank.getMetaData()
public boolean supportsType(DataType type)
supportsType
in interface SentenceDataList
SentenceDataList.supportsType(de.ims.icarus.language.DataType)
public SentenceData get(int index, DataType type)
SentenceDataList
SentenceData
object
for the specified index. If this list
supports
asynchronous loading of elements then this method may
return null
if the desired index
is not
available.get
in interface SentenceDataList
index
- the index of interestSentenceData
object at position index
within this list
SentenceDataList.get(int, de.ims.icarus.language.DataType)
public SentenceData get(int index, DataType type, AvailabilityObserver observer)
SentenceDataList
SentenceData
object
for the specified index.
This method might return null
and use the optional
AvailabilityObserver
to notify about a successful loading
of the desired data later. Implementations should only
store a weak reference to the provided observer
since
the calling code might decide to release the AvailabilityObserver
object and its associated resources while the loading is
still in progress. Therefore exclusive ownership of this object
should be left to the original code that created it.
get
in interface SentenceDataList
index
- the index of interesttype
- the type to fetch an entry forobserver
- the AvailabilityObserver
to be notified
when the asynchronous loading of the desired SentenceData
is finishedSentenceDataList.get(int, de.ims.icarus.language.DataType, de.ims.icarus.language.AvailabilityObserver)