edu.mit.jwi.data
Class DirectAccessWordnetFile<T>

java.lang.Object
  extended by edu.mit.jwi.data.WordnetFile<T>
      extended by edu.mit.jwi.data.DirectAccessWordnetFile<T>
Type Parameters:
T - the type of object represented in this data resource
All Implemented Interfaces:
IClosable, IDataSource<T>, IHasLifecycle, ILoadable, ILoadableDataSource<T>, IHasVersion, java.lang.Iterable<java.lang.String>

public class DirectAccessWordnetFile<T>
extends WordnetFile<T>

Concrete implementation of a wordnet file data source. This particular implementation is for files on disk, and directly accesses the appropriate byte offset in the file to find requested lines. It is appropriate for Wordnet data files.

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

Nested Class Summary
 class DirectAccessWordnetFile.DirectLineIterator
          Used to iterate over lines in a file.
 
Nested classes/interfaces inherited from class edu.mit.jwi.data.WordnetFile
WordnetFile.LineIterator
 
Nested classes/interfaces inherited from interface edu.mit.jwi.data.IHasLifecycle
IHasLifecycle.LifecycleState, IHasLifecycle.ObjectClosedException, IHasLifecycle.ObjectOpenException
 
Constructor Summary
DirectAccessWordnetFile(java.io.File file, IContentType<T> contentType)
          Constructs a new direct access wordnet file, on the specified file with the specified content type.
 
Method Summary
 java.lang.String getLine(java.lang.String key)
          Returns the line in the resource contains the data indexed by the specified key.
 WordnetFile.LineIterator makeIterator(java.nio.ByteBuffer buffer, java.lang.String key)
          Constructs an iterator that can be used to iterate over the specified ByteBuffer, starting from the specified key.
 
Methods inherited from class edu.mit.jwi.data.WordnetFile
close, equals, getBuffer, getContentType, getFile, getLine, getLine, getName, getVersion, hashCode, isLoaded, isOpen, iterator, iterator, load, load, open, rewindToLineStart
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DirectAccessWordnetFile

public DirectAccessWordnetFile(java.io.File file,
                               IContentType<T> contentType)
Constructs a new direct access wordnet file, on the specified file with the specified content type.

Parameters:
file - the file which backs this wordnet file; may not be null
contentType - the content type for this file; may not be null
Throws:
{@link - NullPointerException} if either the file or content type is null
Since:
JWI 2.0.0
Method Detail

getLine

public java.lang.String getLine(java.lang.String key)
Description copied from interface: IDataSource
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

makeIterator

public WordnetFile.LineIterator makeIterator(java.nio.ByteBuffer buffer,
                                             java.lang.String key)
Description copied from class: WordnetFile
Constructs an iterator that can be used to iterate over the specified ByteBuffer, starting from the specified key.

Specified by:
makeIterator in class WordnetFile<T>
Parameters:
buffer - the buffer over which the iterator will iterate, should not be null
key - the key at which the iterator should begin, should not be null
Returns:
an iterator that can be used to iterate over the lines of the ByteBuffer


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