gov.nih.nlm.mms.browser
Class BrowserState

java.lang.Object
  extended by gov.nih.nlm.mms.browser.BrowserState

public class BrowserState
extends Object

Data repository for historical information on past opened directories and viewed concepts.

Author:
Deborah Shapiro (dshapiro@apelon.com)

Constructor Summary
BrowserState()
          Constructor.
 
Method Summary
 void addDirectory(String dir, ConceptList cl)
          Adds a directory path to the history list of opened directories.
 void addProperties(Configurable f, Properties props)
          Adds the Properties for a given Configurable.
static boolean browserStateExists()
          Indicates whether or not a BrowserState already exists.
static void clearBrowserState()
          Recreates the singleton browser state object.
static void deleteBrowserStates()
          Delete all BrowserStates in the config directory except for the given one.
 BrowserRestrictor getBrowserRestrictor()
          Returns the current BrowserRestrictor.
 BrowserRestrictor getBrowserRestrictor(String br_name)
          Returns the given BrowserRestrictor initialized with the properties saved in the BrowserState.
static BrowserState getBrowserState()
          Returns the singleton reference to the BrowserState.
static BrowserState getBrowserState(File file)
          Returns the singleton reference to the BrowserState.
static File getBrowserStateDirectory()
          Returns the directory where browser state files will be managed.
 ConceptList getConceptListForDirectory(String dir)
          Returns the ConceptList associated with the given directory.
static File getCurrentBrowserStateFile()
          Returns the most recent previously saved BrowserState
 ConceptList getCurrentConceptList()
          Returns the list of viewed concepts in the currently opened directory.
 String getCurrentDirectory()
          Returns the current subset directory.
 String[] getDirectoryHistory()
          Returns the last five opened directories.
 Map getDirectoryToConceptListMap()
          Returns the map of directories to their ConceptLists.
 String getFontFamily()
          Returns the current font family.
 int getFontPointSize()
          Returns the current font point size.
 Properties getProperties(Configurable f)
          Returns the Properties for the given Configurable.
static File newBrowserStateFile()
          Creates and returns a new browser state file.
static File saveBrowserState()
          Saves the BrowserState to a new file.
static void saveBrowserState(File file)
          Saves the BrowserState to the given File.
 void setBrowserRestrictor(BrowserRestrictor br)
          Sets the selected BrowserRestrictor.
 void setDirectoryHistory(String[] history)
          Resets the directory history to that given.
 void setDirectoryToConceptListMap(Map<String,ConceptList> map)
          Resets the Map of directories to their ConceptLists.
 void setFontFamily(String font_family)
          Resets the font family to that given.
 void setFontPointSize(int font_point_size)
          Resets the font point size to that given.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BrowserState

public BrowserState()
Constructor.

Method Detail

getBrowserState

public static BrowserState getBrowserState()
Returns the singleton reference to the BrowserState.

Returns:
the singleton reference to the BrowserState

clearBrowserState

public static void clearBrowserState()
Recreates the singleton browser state object.


getBrowserState

public static BrowserState getBrowserState(File file)
                                    throws Exception
Returns the singleton reference to the BrowserState.

Parameters:
file - where BrowserState was written
Returns:
the singleton reference to the BrowserState
Throws:
Exception

getBrowserStateDirectory

public static File getBrowserStateDirectory()
                                     throws IOException
Returns the directory where browser state files will be managed.

Returns:
the directory where browser state files will be managed
Throws:
IOException

newBrowserStateFile

public static File newBrowserStateFile()
                                throws Exception
Creates and returns a new browser state file.

Returns:
a new browser state file
Throws:
Exception

saveBrowserState

public static File saveBrowserState()
                             throws Exception
Saves the BrowserState to a new file.

Throws:
Exception

saveBrowserState

public static void saveBrowserState(File file)
                             throws Exception
Saves the BrowserState to the given File.

Parameters:
file - File
Throws:
Exception

browserStateExists

public static boolean browserStateExists()
                                  throws IOException
Indicates whether or not a BrowserState already exists.

Returns:
true if a BrowserState exists false otherwise
Throws:
IOException

deleteBrowserStates

public static void deleteBrowserStates()
                                throws IOException
Delete all BrowserStates in the config directory except for the given one.

Parameters:
this_browser_state - BrowserState
Throws:
IOException

getCurrentBrowserStateFile

public static File getCurrentBrowserStateFile()
                                       throws IOException
Returns the most recent previously saved BrowserState

Returns:
File where the BrowserState is saved
Throws:
IOException

getDirectoryHistory

public String[] getDirectoryHistory()
Returns the last five opened directories.

Returns:
String[] of directory paths

setDirectoryHistory

public void setDirectoryHistory(String[] history)
Resets the directory history to that given.

Parameters:
history - String[]

getDirectoryToConceptListMap

public Map getDirectoryToConceptListMap()
Returns the map of directories to their ConceptLists.

Returns:
Map

setDirectoryToConceptListMap

public void setDirectoryToConceptListMap(Map<String,ConceptList> map)
Resets the Map of directories to their ConceptLists.

Parameters:
map - Map

getConceptListForDirectory

public ConceptList getConceptListForDirectory(String dir)
Returns the ConceptList associated with the given directory.

Parameters:
dir - subset directory of interest
Returns:
associated ConceptList

getCurrentDirectory

public String getCurrentDirectory()
Returns the current subset directory.

Returns:
String path to subset directory

getCurrentConceptList

public ConceptList getCurrentConceptList()
Returns the list of viewed concepts in the currently opened directory.

Returns:
Concept[] list of concepts

addDirectory

public void addDirectory(String dir,
                         ConceptList cl)
Adds a directory path to the history list of opened directories.

Parameters:
dir - String
cl - ConceptList

getFontPointSize

public int getFontPointSize()
Returns the current font point size.

Returns:
int font point size

setFontPointSize

public void setFontPointSize(int font_point_size)
Resets the font point size to that given.

Parameters:
font_point_size - int

getFontFamily

public String getFontFamily()
Returns the current font family.

Returns:
String font family

setFontFamily

public void setFontFamily(String font_family)
Resets the font family to that given.

Parameters:
font_family - String

addProperties

public void addProperties(Configurable f,
                          Properties props)
Adds the Properties for a given Configurable.

Parameters:
f - Configurable
props - Properties

getProperties

public Properties getProperties(Configurable f)
Returns the Properties for the given Configurable.

Parameters:
f - Configurable
Returns:
Properties

setBrowserRestrictor

public void setBrowserRestrictor(BrowserRestrictor br)
Sets the selected BrowserRestrictor.

Parameters:
br - BrowserRestrictor

getBrowserRestrictor

public BrowserRestrictor getBrowserRestrictor()
                                       throws IllegalAccessException,
                                              ClassNotFoundException,
                                              InstantiationException
Returns the current BrowserRestrictor.

Returns:
BrowserRestrictor
Throws:
IllegalAccessException
ClassNotFoundException
InstantiationException

getBrowserRestrictor

public BrowserRestrictor getBrowserRestrictor(String br_name)
                                       throws IllegalAccessException,
                                              ClassNotFoundException,
                                              InstantiationException
Returns the given BrowserRestrictor initialized with the properties saved in the BrowserState.

Returns:
BrowserRestrictor
Throws:
IllegalAccessException
ClassNotFoundException
InstantiationException


Copyright ©2005