jpl.mipl.mdms.FileService.komodo.api
Class SaxDomain

java.lang.Object
  extended by jpl.mipl.mdms.FileService.komodo.api.Domain
      extended by jpl.mipl.mdms.FileService.komodo.api.SaxDomain

public class SaxDomain
extends Domain

SAX XML parsing implementation of Domain object

Version:
$Id: SaxDomain.java,v 1.25 2008/02/21 16:39:03 ntt Exp $
Author:
R. Pavlovsky {rich.pavlovsky@jpl.nasa.gov}

Field Summary
protected static String DEFGRP_KEY
           
protected static String GROUPS_KEY
           
protected static String SERVERS_KEY
           
protected static String TYPES_KEY
           
protected static String URI_KEY
           
 
Constructor Summary
SaxDomain(String uri)
          Constructor, location of domain file.
SaxDomain(URL url)
          Constructor, location of domain file.
 
Method Summary
protected  void _load()
          Private method to do the XML parsing and load the hashtable.
 String getDefaultGroup()
          Get the default server group specified in domain file.
 FileTypeInfo getFileType(String typeName)
          Deprecated. please use the getFileType(String groupName, String typeName) method
 FileTypeInfo getFileType(String groupName, String typeName)
          Returns the file type information object for input file type name parameter.
 LinkedList getFileTypeNames()
          Deprecated. doesn't respect server group namespace, use getFileTypeNames(String groupName) instead
 LinkedList getFileTypeNames(String groupName)
          Get a list of sorted file type names for a specified server group
 LinkedList getGroupNames()
          Get a list of sorted server group names
 ServerInfo getServerInfo(String serverName)
          Returns the server infomation object for input servername parameter.
 ServerInfo getServerInfo(String groupName, String serverName)
          Returns the server infomation object for input server name and group name parameters.
 ServerInfo getServerInfoByIndex(int index)
          Returns the server at the specified index, or null if index is out of bounds.
 LinkedList getServerInfoFromFileType(String groupName, String typeName)
          Method to return a LinkedList of ServerInfo objects for a given file type name and server group
 LinkedList getServerInfoFromFileType2(String groupName, String typeName)
          Method to return a LinkedList of ServerInfo objects for a given file type name and server group
 LinkedList getServerInfoFromGroup(String groupName)
          Method to return a LinkedList of ServerInfo objects for a given server group
 String getUri()
          Method to return the domain file's URI
 String toString()
          Utility method to output the Domain hash to a string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

URI_KEY

protected static final String URI_KEY
See Also:
Constant Field Values

GROUPS_KEY

protected static final String GROUPS_KEY
See Also:
Constant Field Values

SERVERS_KEY

protected static final String SERVERS_KEY
See Also:
Constant Field Values

TYPES_KEY

protected static final String TYPES_KEY
See Also:
Constant Field Values

DEFGRP_KEY

protected static final String DEFGRP_KEY
See Also:
Constant Field Values
Constructor Detail

SaxDomain

public SaxDomain(String uri)
          throws SessionException
Constructor, location of domain file. Parses XML and loads it into a hashtable. See class Javadoc comment for hashtable format.

Parameters:
uri - the full path to a domain file.
Throws:
SessionException - when other failures

SaxDomain

public SaxDomain(URL url)
          throws SessionException
Constructor, location of domain file. Parses XML and loads it into a hashtable. See class Javadoc comment for hashtable format.

Parameters:
url - URL location of domainFile
Throws:
SessionException - when session failure
Method Detail

_load

protected void _load()
              throws SessionException
Private method to do the XML parsing and load the hashtable. See class Javadoc entry for hashtable format.

Throws:
SessionException - when session failure

toString

public String toString()
Utility method to output the Domain hash to a string

Specified by:
toString in class Domain
Returns:
String contents of domain hash

getDefaultGroup

public String getDefaultGroup()
Get the default server group specified in domain file. Returns an empty string if default group not specified in domain file.

Specified by:
getDefaultGroup in class Domain
Returns:
default server group name

getGroupNames

public LinkedList getGroupNames()
Get a list of sorted server group names

Specified by:
getGroupNames in class Domain
Returns:
list of server group names

getFileTypeNames

public LinkedList getFileTypeNames()
                            throws SessionException
Deprecated. doesn't respect server group namespace, use getFileTypeNames(String groupName) instead

Get a list of sorted file type names, does not respect server group namespace.

Specified by:
getFileTypeNames in class Domain
Returns:
list of file type names
Throws:
SessionException - when operation fails

getFileTypeNames

public LinkedList getFileTypeNames(String groupName)
                            throws SessionException
Get a list of sorted file type names for a specified server group

Specified by:
getFileTypeNames in class Domain
Parameters:
groupName - the name of the server group
Returns:
list of file type names
Throws:
SessionException - when operation fails

getServerInfo

public ServerInfo getServerInfo(String serverName)
                         throws SessionException
Returns the server infomation object for input servername parameter. Returns the first serverName match found (regardless of server groups)! Please note that the same server name can be defined in multiple server groups. Returns the first server defined in domain structure if serverName is null. Throws session exception if a match is not found in domain hash.

Specified by:
getServerInfo in class Domain
Parameters:
serverName - the server name
Returns:
the server info object reference
Throws:
SessionException - if match not found

getServerInfo

public ServerInfo getServerInfo(String groupName,
                                String serverName)
                         throws SessionException
Returns the server infomation object for input server name and group name parameters. If servername is null, returns the first server name match found (regardless of server groups)! Please note that the same server name can be defined in multiple server groups. Returns the first servername match (regardless of server groups) if group name is null. Throws session exception if a match is not found in domain hash.

Specified by:
getServerInfo in class Domain
Parameters:
serverName - the server name
groupName - the server group name
Returns:
the server info object reference
Throws:
SessionException - if match not found

getServerInfoByIndex

public ServerInfo getServerInfoByIndex(int index)
Returns the server at the specified index, or null if index is out of bounds.

Specified by:
getServerInfoByIndex in class Domain
Parameters:
index - the index entry to the server list
Returns:
the server info object reference

getServerInfoFromFileType

public LinkedList getServerInfoFromFileType(String groupName,
                                            String typeName)
                                     throws SessionException
Method to return a LinkedList of ServerInfo objects for a given file type name and server group

Specified by:
getServerInfoFromFileType in class Domain
Parameters:
groupName - the server group name
typeName - the file type name
Returns:
LinkedList of server info objects
Throws:
SessionException - when operation fails

getServerInfoFromGroup

public LinkedList getServerInfoFromGroup(String groupName)
                                  throws SessionException
Method to return a LinkedList of ServerInfo objects for a given server group

Specified by:
getServerInfoFromGroup in class Domain
Parameters:
groupName - the server group name
Returns:
LinkedList of server info objects
Throws:
SessionException - when operation fails

getServerInfoFromFileType2

public LinkedList getServerInfoFromFileType2(String groupName,
                                             String typeName)
                                      throws SessionException
Method to return a LinkedList of ServerInfo objects for a given file type name and server group

Parameters:
groupName - the server group name
typeName - the file type name
Returns:
LinkedList of server info objects
Throws:
SessionException - when operation fails

getFileType

public FileTypeInfo getFileType(String typeName)
                         throws SessionException
Deprecated. please use the getFileType(String groupName, String typeName) method

Returns the file type information object for input file type name parameter. If type name is null, returns the first type name found (regardless of server groups)! Please note that the same file type name can be defined in multiple server groups. Returns the first type name match (regardless of server groups) if group name is null. Throws session exception if a match is not found in domain hash.

Specified by:
getFileType in class Domain
Parameters:
typeName - the file type name
Returns:
the file type info object reference
Throws:
SessionException - if match is not found

getFileType

public FileTypeInfo getFileType(String groupName,
                                String typeName)
                         throws SessionException
Returns the file type information object for input file type name parameter. If the group is specified, then a filetype info object is only returned if that group contains that filetype. If group name is null, checks if filetype is defined for the default group. If not found, it checks all other groups and makes the following decision. If single group matches, then that group is returned. If multiple groups match, then method throws an exception with ambiguity message. Please note that the same file type name can be defined in multiple server groups. Throws session exception if a match is not found in domain hash.

Specified by:
getFileType in class Domain
Parameters:
groupName - the server group name
typeName - the file type name
Returns:
the file type object
Throws:
SessionException - if unique match is not found

getUri

public String getUri()
Method to return the domain file's URI

Returns:
the domain file URI