gov.nih.nlm.mms.browser
Class RRFBrowsableInputStream

java.lang.Object
  extended by gov.nih.nlm.mms.browser.RRFBrowsableInputStream
All Implemented Interfaces:
BrowsableInputStream, LocalNullValueSupport

public class RRFBrowsableInputStream
extends Object
implements BrowsableInputStream, LocalNullValueSupport

Rich Release Format implementation of BrowsableInputStream. For this class to be usable the directory must be set with setDirectory(String).


Constructor Summary
RRFBrowsableInputStream()
          Constructor.
 
Method Summary
 void buildIndexes(ProgressMonitor pm)
          Builds the indexes in the RRFBrowsableInputStream.
 boolean buildIndexesNeeded()
          Indicates if indexes in the RRFBrowsableInputStream need to be built.
 void close()
          Closes the RRFBrowsableInputStream.
 boolean containsConcept(String cui)
          Indicates if the RRFBrowsableInputStream contains the concept specified by the CUI.
 int countChildren(Context context)
          Returns the number of children for the given Context.
 int countSiblings(Context context)
          Returns the number of siblings for the given Context.
 boolean directoryContainsExpectedData()
          Indicates if directory of RRFBrowsableInputStream contains RRF data.
 Atom[] findAtomsByCodeSab(String code, Set sources)
          Looks up the given code in the CODE_SAB_MRCONSO.x index file and returns the Atom[] of Atoms that have the given code and that are in any of the given Sources.
 Context[] findChildren(Context context, SearchOptions options)
          Returns a Context[] of children for the given context.
 Context[] findSiblings(Context context, SearchOptions options)
          Returns a Context[] of siblings for the given context.
 Set findWordMatches(String word, Language language)
          Finds WordSearchResults of Concepts with Strings containing the specified word.
 Color getColor()
          Returns the name of the color associated with this input format.
 String getDirectory()
          Gets directory of RRFBrowsableInputStream.
 String getName()
          Returns the name of the Input Format.
 String getNullValue()
          Returns the null value.
 List getPrecedenceOrder()
          Gets the list of source TTYs in precedence order.
 String[] getPreexpandedRawFiles()
          Returns list of file names that should be preexpanded to show user initial content when concepts are first opened in browser.
 Map getRawConceptWithLinks(String cui, LinkGenerator link_gen)
          Returns a Map that has concept data RRF filename String objects as keys and have String[] values which are the lines in the file matching the specified CUI.
 Map getRawHistoryData(String cui)
          Returns a Map that has history filename String objects as keys and have String[] values which are the lines of the file that provide historical information for the specified CUI.
 Map getRawMetadata()
          Returns a Map that has metadata filename String objects as keys and have String[] values which are the lines of the file that are relevant to the query.
 String getReleaseVersion()
          Returns the release version
 List getSourceList()
          Returns the List of included sources.
 int getWordFrequency(String word, Language language)
          Gets number of strings in which a word appears.
 boolean hasChildren(Context context)
          Indicates if given Context has children.
 boolean hasSiblings(Context context)
          Indicates if the given Context has siblings.
 void initializeMetadata()
          Initializes metadata from MRDOC.RRF and MRSAB.RRF files.
protected  boolean initializeMetadataNeeded()
          Indicates if metadata classes need to be initialized.
 boolean isEmptyValue(String token)
          Indicates whether or not the specified token is null or contains a null value as defined by being either zero length or a value equal to the null value.
 void open()
          Opens the RRFBrowsableInputStream.
 Atom readAtom(String aui, AtomDataSelector selector)
          Looks up the given AUI in the index file and returns the Atom that contains the given AUI.
 Concept readConcept(String cui, ConceptDataSelector selector)
          Populates a Concept with the amount of information specified by a ConceptDataSelector.
 ReleaseMetadata readReleaseMetadata()
          Returns the ReleaseMetadata containing data from MRSAB.RRF, MRCUI.RRF, MRAUI.RRF, and MRDOC.RRF.
 void setDirectory(String newDirectory)
          Sets directory of RRFBrowsableInputStream.
 void setNullValue(String null_value)
          Sets the null value to use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RRFBrowsableInputStream

public RRFBrowsableInputStream()
Constructor.

Method Detail

setNullValue

public void setNullValue(String null_value)
Sets the null value to use. This is needed if release.dat specifies some non-standard null value char sequence.

Specified by:
setNullValue in interface LocalNullValueSupport
Parameters:
null_value - the new null string value

getNullValue

public String getNullValue()
Returns the null value. This is needed if release.dat specifies some non-standard null value char sequence.

Specified by:
getNullValue in interface LocalNullValueSupport
Returns:
the string value for "null"

isEmptyValue

public boolean isEmptyValue(String token)
Indicates whether or not the specified token is null or contains a null value as defined by being either zero length or a value equal to the null value.

Specified by:
isEmptyValue in interface LocalNullValueSupport

getDirectory

public String getDirectory()
Gets directory of RRFBrowsableInputStream.

Specified by:
getDirectory in interface BrowsableInputStream
Returns:
directory of RRFBrowsableInputStream.

setDirectory

public void setDirectory(String newDirectory)
Sets directory of RRFBrowsableInputStream.

Specified by:
setDirectory in interface BrowsableInputStream
Parameters:
newDirectory - directory of RRFBrowsableInputStream

directoryContainsExpectedData

public boolean directoryContainsExpectedData()
Indicates if directory of RRFBrowsableInputStream contains RRF data.

Specified by:
directoryContainsExpectedData in interface BrowsableInputStream
Returns:
true if the directory set by setDirectory(String) contains RRF data, otherwise false.

open

public void open()
          throws IOException
Opens the RRFBrowsableInputStream.

Specified by:
open in interface BrowsableInputStream
Throws:
IOException - if there is a problem opening the RRFBrowsableInputStream.

close

public void close()
           throws IOException
Closes the RRFBrowsableInputStream.

Specified by:
close in interface BrowsableInputStream
Throws:
IOException - if there is a problem closing the RRFBrowsableInputStream.

initializeMetadataNeeded

protected boolean initializeMetadataNeeded()
Indicates if metadata classes need to be initialized.

Returns:
true if the metadata classes need to be initialized; false otherwise.
See Also:
initializeMetadata()

initializeMetadata

public void initializeMetadata()
                        throws IOException
Initializes metadata from MRDOC.RRF and MRSAB.RRF files. The following metadata classes are initialized:

Specified by:
initializeMetadata in interface BrowsableInputStream
Throws:
IOException

readReleaseMetadata

public ReleaseMetadata readReleaseMetadata()
                                    throws IOException
Returns the ReleaseMetadata containing data from MRSAB.RRF, MRCUI.RRF, MRAUI.RRF, and MRDOC.RRF.

Specified by:
readReleaseMetadata in interface BrowsableInputStream
Returns:
the ReleaseMetadata
Throws:
IOException - if the files could not be read.

buildIndexesNeeded

public boolean buildIndexesNeeded()
Indicates if indexes in the RRFBrowsableInputStream need to be built.

Specified by:
buildIndexesNeeded in interface BrowsableInputStream
Returns:
true if indexes needed to be built; false otherwise.

buildIndexes

public void buildIndexes(ProgressMonitor pm)
                  throws IOException
Builds the indexes in the RRFBrowsableInputStream.

Specified by:
buildIndexes in interface BrowsableInputStream
Parameters:
pm - ProgressMonitor for displaying progress of the operation
Throws:
IOException

getPrecedenceOrder

public List getPrecedenceOrder()
Gets the list of source TTYs in precedence order.

Specified by:
getPrecedenceOrder in interface BrowsableInputStream
Returns:
List of source TTYs in precedence order.

getSourceList

public List getSourceList()
Returns the List of included sources.

Specified by:
getSourceList in interface BrowsableInputStream
Returns:
included source List.

getName

public String getName()
Returns the name of the Input Format.

Specified by:
getName in interface BrowsableInputStream
Returns:
input format name

getColor

public Color getColor()
Returns the name of the color associated with this input format.

Specified by:
getColor in interface BrowsableInputStream
Returns:
input format color

getReleaseVersion

public String getReleaseVersion()
Returns the release version

Specified by:
getReleaseVersion in interface BrowsableInputStream
Returns:
release version

readConcept

public Concept readConcept(String cui,
                           ConceptDataSelector selector)
                    throws IOException
Populates a Concept with the amount of information specified by a ConceptDataSelector.

Specified by:
readConcept in interface BrowsableInputStream
Parameters:
cui - CUI (concept unique identifier) of the Concept desired
selector - ConceptDataSelector
Returns:
a populated Concept according to the specified ConceptDataSelector.
Throws:
IOException

readAtom

public Atom readAtom(String aui,
                     AtomDataSelector selector)
              throws IOException
Looks up the given AUI in the index file and returns the Atom that contains the given AUI.

Specified by:
readAtom in interface BrowsableInputStream
Parameters:
aui - AUI to be searched for
selector - AtomDataSelector specifying how to populate the Atom
Returns:
the Atom containing the AUI, populated according to the AtomDataSelector.
Throws:
IOException

getRawConceptWithLinks

public Map getRawConceptWithLinks(String cui,
                                  LinkGenerator link_gen)
                           throws IOException
Returns a Map that has concept data RRF filename String objects as keys and have String[] values which are the lines in the file matching the specified CUI.

Specified by:
getRawConceptWithLinks in interface BrowsableInputStream
Parameters:
cui - UMLS CUI
link_gen - LinkGenerator used to insert hyperlinks to referenced CUIs and AUIs
Returns:
a Map from each RRF file name to an array of the lines in that file matching the specified CUI.
Throws:
IOException

getRawHistoryData

public Map getRawHistoryData(String cui)
                      throws IOException
Returns a Map that has history filename String objects as keys and have String[] values which are the lines of the file that provide historical information for the specified CUI.

Specified by:
getRawHistoryData in interface BrowsableInputStream
Parameters:
cui - UMLS CUI
Returns:
a Map that has history filename String objects as keys and have String[] values which are the lines of the file that provide historical information for the specified CUI
Throws:
IOException

getRawMetadata

public Map getRawMetadata()
                   throws IOException
Returns a Map that has metadata filename String objects as keys and have String[] values which are the lines of the file that are relevant to the query.

Specified by:
getRawMetadata in interface BrowsableInputStream
Returns:
a Map that has metadata filename String objects as keys and have String[] values which are the lines of the file that are relevant to the query.
Throws:
IOException

containsConcept

public boolean containsConcept(String cui)
                        throws IOException
Indicates if the RRFBrowsableInputStream contains the concept specified by the CUI.

Specified by:
containsConcept in interface BrowsableInputStream
Parameters:
cui - CUI of the concept in question
Returns:
true if the data set contains the concept specified by the CUI.
Throws:
IOException

countSiblings

public int countSiblings(Context context)
                  throws IOException
Description copied from interface: BrowsableInputStream
Returns the number of siblings for the given Context.

Specified by:
countSiblings in interface BrowsableInputStream
Returns:
number of siblings
Throws:
IOException

hasSiblings

public boolean hasSiblings(Context context)
                    throws IOException
Description copied from interface: BrowsableInputStream
Indicates if the given Context has siblings.

Specified by:
hasSiblings in interface BrowsableInputStream
Returns:
true if context has siblings false otherwise
Throws:
IOException

findSiblings

public Context[] findSiblings(Context context,
                              SearchOptions options)
                       throws IOException
Description copied from interface: BrowsableInputStream
Returns a Context[] of siblings for the given context.

Specified by:
findSiblings in interface BrowsableInputStream
options - SearchOptions specify parameters
Returns:
array of siblings
Throws:
IOException

countChildren

public int countChildren(Context context)
                  throws IOException
Description copied from interface: BrowsableInputStream
Returns the number of children for the given Context.

Specified by:
countChildren in interface BrowsableInputStream
Returns:
count of children
Throws:
IOException

hasChildren

public boolean hasChildren(Context context)
                    throws IOException
Description copied from interface: BrowsableInputStream
Indicates if given Context has children.

Specified by:
hasChildren in interface BrowsableInputStream
Returns:
true if context has children false otherwise
Throws:
IOException

findChildren

public Context[] findChildren(Context context,
                              SearchOptions options)
                       throws IOException
Description copied from interface: BrowsableInputStream
Returns a Context[] of children for the given context.

Specified by:
findChildren in interface BrowsableInputStream
options - SearchOptions specify parameters
Returns:
Context[]
Throws:
IOException

findWordMatches

public Set findWordMatches(String word,
                           Language language)
                    throws IOException,
                           InterruptedException
Finds WordSearchResults of Concepts with Strings containing the specified word.

Specified by:
findWordMatches in interface BrowsableInputStream
Parameters:
word - search word or partial search word with wild card '*' at end
language - Language of strings to be found
Returns:
Set of WordSearchResults consisting of matches on the specified word.
Throws:
IOException
InterruptedException

getWordFrequency

public int getWordFrequency(String word,
                            Language language)
                     throws IOException
Gets number of strings in which a word appears.

Specified by:
getWordFrequency in interface BrowsableInputStream
Parameters:
word - word or partial word followed by a wild card character '*'.
language - Language of strings to search
Returns:
number of strings in which a word appears.
Throws:
IOException

findAtomsByCodeSab

public Atom[] findAtomsByCodeSab(String code,
                                 Set sources)
                          throws IOException
Looks up the given code in the CODE_SAB_MRCONSO.x index file and returns the Atom[] of Atoms that have the given code and that are in any of the given Sources.

Specified by:
findAtomsByCodeSab in interface BrowsableInputStream
Parameters:
code - to be searched for
sources - Set of sources that returned Atoms may belong to
Returns:
Atom[] of Atoms with the given code and in one of the given sources
Throws:
IOException

getPreexpandedRawFiles

public String[] getPreexpandedRawFiles()
Returns list of file names that should be preexpanded to show user initial content when concepts are first opened in browser.

Specified by:
getPreexpandedRawFiles in interface BrowsableInputStream
Returns:
list of files whose data should be preexpanded


Copyright ©2005