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

java.lang.Object
  extended by edu.mit.jwi.data.DataType<T>
Type Parameters:
T - the type of object for the content type
All Implemented Interfaces:
IDataType<T>

public class DataType<T>
extends java.lang.Object
implements IDataType<T>

A concrete implementation of the IDataType interface. This class provides the data types necessary for Wordnet in the form of static fields. It is not implemented as an Enum so that clients may add their own content types by instantiating this class.

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

Field Summary
static DataType<ISynset> DATA
           
static DataType<IExceptionEntryProxy> EXCEPTION
           
static DataType<IIndexWord> INDEX
           
static DataType<ISenseEntry> SENSE
           
 
Constructor Summary
DataType(java.lang.String userFriendlyName, boolean hasVersion, ILineParser<T> parser, java.util.Collection<java.lang.String> hints)
          Constructs a new data type.
DataType(java.lang.String userFriendlyName, boolean hasVersion, ILineParser<T> parser, java.lang.String... hints)
          Constructs a new data type.
 
Method Summary
static boolean containsOneOf(java.lang.String target, java.util.Set<java.lang.String> patterns)
          Checks to see if one of the string patterns specified in the set of strings is found in the specified target string.
static java.io.File find(IDataType<?> type, POS pos, java.util.Collection<? extends java.io.File> files)
          Finds the first file that satisfies the naming constraints of both the data type and part of speech.
 ILineParser<T> getParser()
          Returns the line parser that can be used to process lines of data retrieved from an IDataSource file with this type.
 java.util.Set<java.lang.String> getResourceNameHints()
          Returns an immutable set of strings that can be used as keywords to identify resources that are of this type.
 boolean hasVersion()
          Indicates whether this content type usually has wordnet version information encoded in its header.
 java.lang.String toString()
           
static java.util.Collection<DataType<?>> values()
          Emulates the Enum.values() function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INDEX

public static final DataType<IIndexWord> INDEX

DATA

public static final DataType<ISynset> DATA

EXCEPTION

public static final DataType<IExceptionEntryProxy> EXCEPTION

SENSE

public static final DataType<ISenseEntry> SENSE
Constructor Detail

DataType

public DataType(java.lang.String userFriendlyName,
                boolean hasVersion,
                ILineParser<T> parser,
                java.lang.String... hints)
Constructs a new data type. This constructor takes the hints as an varargs array.

Parameters:
userFriendlyName - a user-friendly name, for easy identification of this data type; may be null
hasVersion - true if the comment header for this data type usually contains a version number
parser - the line parser for transforming lines from this data type into objects; may not be null
hints - a varargs array of resource name hints for identifying the resource that contains the data. may be null, but may not contain null
Throws:
java.lang.NullPointerException - if the specified parser is null
Since:
JWI 2.0.0

DataType

public DataType(java.lang.String userFriendlyName,
                boolean hasVersion,
                ILineParser<T> parser,
                java.util.Collection<java.lang.String> hints)
Constructs a new data type. This constructor takes the hints as an collection.

Parameters:
userFriendlyName - a user-friendly name, for easy identification of this data type; may be null
hasVersion - true if the comment header for this data type usually contains a version number
parser - the line parser for transforming lines from this data type into objects; may not be null
hints - a collection of resource name hints for identifying the resource that contains the data. May be null, but may not contain null
Throws:
java.lang.NullPointerException - if the specified parser is null
Since:
JWI 2.0.0
Method Detail

hasVersion

public boolean hasVersion()
Description copied from interface: IDataType
Indicates whether this content type usually has wordnet version information encoded in its header.

Specified by:
hasVersion in interface IDataType<T>
Returns:
true if the content file that underlies this content usually has wordnet version information in its comment header; false otherwise.

getResourceNameHints

public java.util.Set<java.lang.String> getResourceNameHints()
Description copied from interface: IDataType
Returns an immutable set of strings that can be used as keywords to identify resources that are of this type.

Specified by:
getResourceNameHints in interface IDataType<T>
Returns:
a set of resource name fragments

getParser

public ILineParser<T> getParser()
Description copied from interface: IDataType
Returns the line parser that can be used to process lines of data retrieved from an IDataSource file with this type.

Specified by:
getParser in interface IDataType<T>
Returns:
the line parser that can be used to process lines of data retrieved from an IDataSource file with this type.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

values

public static java.util.Collection<DataType<?>> values()
Emulates the Enum.values() function.

Returns:
all the static data type instances listed in the class, in the order they are declared.
Since:
JWI 2.0.0

find

public static java.io.File find(IDataType<?> type,
                                POS pos,
                                java.util.Collection<? extends java.io.File> files)
Finds the first file that satisfies the naming constraints of both the data type and part of speech.

Parameters:
type - the data type whose resource name hints should be used, may not be null
pos - the part of speech whose resource name hints should be used, may be null
files - the files to be search, may be empty but not null
Returns:
the file that matches both the pos and type naming conventions, or null if none is found.
Throws:
java.lang.NullPointerException - if the data type or file collection is null
Since:
JWI 2.2.0

containsOneOf

public static boolean containsOneOf(java.lang.String target,
                                    java.util.Set<java.lang.String> patterns)
Checks to see if one of the string patterns specified in the set of strings is found in the specified target string. If the pattern set is empty or null, returns true. If a pattern is found in the target string, returns true. Otherwise, returns false.

Parameters:
target - the string to be searched
patterns - the patterns to search for
Returns:
true if the target contains one of the patterns; false otherwise
Since:
JWI 2.2.0


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