edu.mit.jwi.data
Interface IDataSource<T>

Type Parameters:
T - the type of object represented in this data resource
All Superinterfaces:
IClosable, IHasLifecycle, IHasVersion, java.lang.Iterable<java.lang.String>
All Known Subinterfaces:
ILoadableDataSource<T>
All Known Implementing Classes:
BinarySearchWordnetFile, DirectAccessWordnetFile, WordnetFile

public interface IDataSource<T>
extends IHasVersion, java.lang.Iterable<java.lang.String>, IHasLifecycle

An object that mediate between an IDataSourceDictionary and the data that is contained in the dictionary data resources. Data resources are assigned a name (e.g., verb.data, for the data resource pertaining to verbs) and a content type. Data resources are assumed to be indexed by keys that can be passed into the getLine(String) method to find a particular piece of data in the resource. The String return can be parsed by the parser associated with the content type to produce a data object (e.g., an ISynset or IIndexWord object).

The iterator produced by this class should not support the Iterator.remove() operation; if that method is called, the iterator will throw an UnsupportedOperationException.

Since:
JWI 2.0.0
Version:
2.4.0
Author:
Mark A. Finlayson

Nested Class Summary
 
Nested classes/interfaces inherited from interface edu.mit.jwi.data.IHasLifecycle
IHasLifecycle.LifecycleState, IHasLifecycle.ObjectClosedException, IHasLifecycle.ObjectOpenException
 
Method Summary
 IContentType<T> getContentType()
          Returns the assigned content type of the resource that backs this object.
 java.lang.String getLine(java.lang.String key)
          Returns the line in the resource contains the data indexed by the specified key.
 java.lang.String getName()
          Returns a string representation of the name of this resource.
 java.util.Iterator<java.lang.String> iterator(java.lang.String key)
          Returns an iterator that will iterator over lines in the data resource, starting at the line specified by the given key.
 
Methods inherited from interface edu.mit.jwi.item.IHasVersion
getVersion
 
Methods inherited from interface java.lang.Iterable
iterator
 
Methods inherited from interface edu.mit.jwi.data.IHasLifecycle
isOpen, open
 
Methods inherited from interface edu.mit.jwi.data.IClosable
close
 

Method Detail

getName

java.lang.String getName()
Returns a string representation of the name of this resource. For file-based resources, this will usually be the filename.

Returns:
the name of this resource, neither null, empty, or all whitespace
Since:
JWI 2.0.0

getContentType

IContentType<T> getContentType()
Returns the assigned content type of the resource that backs this object.

Returns:
the assigned content type for this data source. Will not return null.
Since:
JWI 2.0.0

getLine

java.lang.String getLine(java.lang.String key)
Returns the line in the resource contains the data indexed by the specified key. If the file cannot find the key in its data resource, it returns null

Parameters:
key - the key which indexes the desired data
Returns:
the line indexed by the specified key in the resource
Throws:
java.lang.NullPointerException - if the specified key is null
Since:
JWI 2.0.0

iterator

java.util.Iterator<java.lang.String> iterator(java.lang.String key)
Returns an iterator that will iterator over lines in the data resource, starting at the line specified by the given key. If the key is null, this is the same as calling the plain Iterable.iterator() method. If no line starts with the pattern, the iterator's Iterator.hasNext() will return false. The iterator does not support the Iterator.remove() operation; if that method is called, the iterator will throw an UnsupportedOperationException.

Parameters:
key - the key at which the iterator should begin
Returns:
an iterator that will iterate over the file starting at the line indexed by the specified key
Since:
JWI 2.0.0


Copyright © 2007-2013 Massachusetts Institute of Technology. All Rights Reserved.