gov.llnl.babel.symbols
Class SymbolUtilities

java.lang.Object
  extended by gov.llnl.babel.symbols.SymbolUtilities

public class SymbolUtilities
extends java.lang.Object

Utility class SymbolUtilities is a collection of common, simple symbol manipulation functions. All methods are declared as static.


Method Summary
static java.lang.String getOutermostPackage(java.lang.String fqn)
          Return the outermost package prefix for the name (everything up to but not including the first ".").
static java.lang.String getParentPackage(java.lang.String fqn)
          Return the parent package for the name (everything up to but not including the last ".".
static Version getParentVersion(java.lang.String fqn, Context context)
          Return the version associated with the parent package.
static java.lang.String getSymbolName(java.lang.String full_name, java.lang.String pkg)
          Return the short name of the string holding the fully qualified name if it is in the specified package; otherwise, return the fully qualified name.
static java.lang.String getSymbolName(SymbolID fid, SymbolID sid)
          Return the short name of the first symbol if it is in the same package as the second symbol; otherwise, return its long name.
static Version getVersion(Context context, java.lang.String name)
          Return the version of the symbol.
static java.lang.String getVersionString(java.lang.String vers)
          Return the version string (i.e., "version " followed by the number) or null if the version is exactly "0" based on the specified version string.
static java.lang.String getVersionString(SymbolID id)
          Return the version string (i.e., " version " followed by the number) or null if the version is exactly "0" for the specified symbol.
static boolean hasParentPackage(java.lang.String fqn)
          Return true if the symbol is at the highest level (i.e., has no parent package); otherwise, return false.
static boolean hasParentPackage(SymbolID id)
          Return true if the symbol is not at the highest level (i.e., has parent package); otherwise, return false.
static boolean isBase(SymbolID id)
          Return true if the specified symbol is one of the base sidl symbols; otherwise, return false.
static boolean isBaseException(SymbolID id)
          Return true if the specified symbol is one of the base sidl exception symbols; otherwise, return false.
static boolean sameVersionAsParent(Context context, java.lang.String fqn)
          Return true if the symbol has a parent with the same version number; otherwise, return false.
static boolean sameVersionAsParent(Context context, SymbolID id)
          Return true if the symbol has a parent with the same version number; otherwise, return false.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getOutermostPackage

public static java.lang.String getOutermostPackage(java.lang.String fqn)
Return the outermost package prefix for the name (everything up to but not including the first ".").


getParentPackage

public static java.lang.String getParentPackage(java.lang.String fqn)
Return the parent package for the name (everything up to but not including the last ".". If the name does not contain a parent, then null is returned.


hasParentPackage

public static boolean hasParentPackage(SymbolID id)
Return true if the symbol is not at the highest level (i.e., has parent package); otherwise, return false.

Parameters:
id - the symbol id whose parentage is being checked
Returns:
a boolean indicating if the symbol has a parent package or not

hasParentPackage

public static boolean hasParentPackage(java.lang.String fqn)
Return true if the symbol is at the highest level (i.e., has no parent package); otherwise, return false.

Parameters:
fqn - the fully qualified name of the symbol whose parentage is being checked
Returns:
a boolean indicating if the symbol has a parent package or not

sameVersionAsParent

public static boolean sameVersionAsParent(Context context,
                                          SymbolID id)
Return true if the symbol has a parent with the same version number; otherwise, return false.

Parameters:
id - the symbol id of the symbol being checked
Returns:
a boolean indicating if the symbol has a parent with same version

sameVersionAsParent

public static boolean sameVersionAsParent(Context context,
                                          java.lang.String fqn)
Return true if the symbol has a parent with the same version number; otherwise, return false.

Parameters:
fqn - the fully qualified name of the symbol being checked
Returns:
a boolean indicating if the symbol has a parent with same version

getVersion

public static Version getVersion(Context context,
                                 java.lang.String name)
Return the version of the symbol.


getParentVersion

public static Version getParentVersion(java.lang.String fqn,
                                       Context context)
Return the version associated with the parent package.

Parameters:
fqn - the fully qualified name of the symbol being checked
Returns:
the version associated with its parent package, if any

isBaseException

public static boolean isBaseException(SymbolID id)
Return true if the specified symbol is one of the base sidl exception symbols; otherwise, return false.

Parameters:
id - the symbol id of the symbol being checked
Returns:
a boolean indicating if the symbol is a base exception symbol

isBase

public static boolean isBase(SymbolID id)
Return true if the specified symbol is one of the base sidl symbols; otherwise, return false.

Parameters:
id - the symbol id of the symbol being checked
Returns:
a boolean indicating if the symbol is a base sidl symbol

getSymbolName

public static java.lang.String getSymbolName(SymbolID fid,
                                             SymbolID sid)
Return the short name of the first symbol if it is in the same package as the second symbol; otherwise, return its long name.

Parameters:
fid - the symbol id of the first symbol being checked.
sid - the symbol id of the second symbol being checked.

getSymbolName

public static java.lang.String getSymbolName(java.lang.String full_name,
                                             java.lang.String pkg)
Return the short name of the string holding the fully qualified name if it is in the specified package; otherwise, return the fully qualified name. Returns null if either parameters are null.

Parameters:
full_name - the fully qualified name being checked
pkg - the parent package name being used for comparison

getVersionString

public static java.lang.String getVersionString(java.lang.String vers)
Return the version string (i.e., "version " followed by the number) or null if the version is exactly "0" based on the specified version string.

Parameters:
vers - the symbol whose version string is to be built
Returns:
the expanded version string

getVersionString

public static java.lang.String getVersionString(SymbolID id)
Return the version string (i.e., " version " followed by the number) or null if the version is exactly "0" for the specified symbol.

Parameters:
id - the version whose expanded version string is to be built
Returns:
the expanded version string