edu.mit.jwi.data
Interface IDataProvider

All Superinterfaces:
IClosable, IHasCharset, IHasLifecycle, IHasVersion
All Known Implementing Classes:
FileProvider

public interface IDataProvider
extends IHasVersion, IHasLifecycle, IHasCharset

Objects that implement this interface manage access to data source objects. Before the provider can be used, a client must call setSource(URL) (or call the appropriate constructor) followed by IHasLifecycle.open(). Otherwise, the provider will throw an exception.

Since:
JWI 1.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
 java.net.URL getSource()
          Returns the URL that points to the resource location; should never return null.
<T> IDataSource<T>
getSource(IContentType<T> type)
          Returns a data source object for the specified content type, if one is available; otherwise returns null.
 java.util.Set<? extends IContentType<?>> getTypes()
          Returns a set containing all the content types this provider looks for at the resource location.
<T> IContentType<T>
resolveContentType(IDataType<T> dt, POS pos)
          Returns the first content type, if any, that matches the specified data type and pos object.
 void setCharset(java.nio.charset.Charset charset)
          Sets the character set associated with this dictionary.
 void setSource(java.net.URL url)
          This method is used to set the source URL from which the provider accesses the data from which it instantiates data sources.
 
Methods inherited from interface edu.mit.jwi.item.IHasVersion
getVersion
 
Methods inherited from interface edu.mit.jwi.data.IHasLifecycle
isOpen, open
 
Methods inherited from interface edu.mit.jwi.data.IClosable
close
 
Methods inherited from interface edu.mit.jwi.data.IHasCharset
getCharset
 

Method Detail

setSource

void setSource(java.net.URL url)
This method is used to set the source URL from which the provider accesses the data from which it instantiates data sources. The data at the specified location may be in an implementation-specific format. If the provider is currently open, this method throws an IllegalStateException.

Parameters:
url - the location of the data, may not be null
Throws:
java.lang.IllegalStateException - if the provider is currently open
java.lang.NullPointerException - if the specified URL is null.
Since:
JWI 1.0

getSource

java.net.URL getSource()
Returns the URL that points to the resource location; should never return null.

Returns:
theURL that points to the resource location; must not be null
Since:
JWI 1.0

setCharset

void setCharset(java.nio.charset.Charset charset)
Sets the character set associated with this dictionary. The character set may be null.

Parameters:
charset - the possibly null character set to use when decoding files.
Throws:
java.lang.IllegalStateException - if the provider is currently open
Since:
JWI 2.3.4

getTypes

java.util.Set<? extends IContentType<?>> getTypes()
Returns a set containing all the content types this provider looks for at the resource location. The returned collection may be unmodifiable, or may be a copy of an internal array; in any event modification of the returned collection should not affect the set of types used by the provider.

Returns:
a non-null, non-empty set of content types for this provider
Since:
JWI 2.2.0

resolveContentType

<T> IContentType<T> resolveContentType(IDataType<T> dt,
                                       POS pos)
Returns the first content type, if any, that matches the specified data type and pos object. Either parameter may be null.

Parameters:
dt - the data type, possibly null, of the desired content type
pos - the part of speech, possibly null, of the desired content type
Returns:
the first content type that matches the specified data type and part of speech.
Since:
JWI 2.3.4

getSource

<T> IDataSource<T> getSource(IContentType<T> type)
Returns a data source object for the specified content type, if one is available; otherwise returns null.

Type Parameters:
T - the content type of the data source
Parameters:
type - the content type of the data source to be retrieved
Returns:
the data source for the specified content type, or null if this provider has no such data source
Throws:
java.lang.NullPointerException - if the type is null
ObjectClosedException - if the provider is not open when this call is made
Since:
JWI 2.0.0


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