|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.duke.cs.banjo.utility.StringUtil
Contains a collection of general purpose string-related code.
Details:
Change History:
Created on Apr 2, 2004
10/13/2005 (v2.0) hjs Added formatDecimalDisplay method for more robust display of decimal numbers (formatting)
hjs (v2.1) Add methods for generating "subordinate" file names when dealing with output from multiple threads.
Field Summary | |
private static java.lang.String |
cachedTimeStamp
|
private static int |
MILLISECSPERDAY
|
private static int |
MILLISECSPERHOUR
|
private static int |
MILLISECSPERMINUTE
|
private static int |
MILLISECSPERSECOND
|
private static Settings |
processData
|
Constructor Summary | |
(package private) |
StringUtil()
(Empty) constructor for static StringUtil class. |
Method Summary | |
static java.lang.String |
arrayAsString(int[] _intArray)
Utility method (debug/test): Trivial helper function for quick trace output. |
static java.lang.String |
compileMemoryInfo(java.lang.String _info)
Composes a basic string that details the memory use of the application at the current moment. |
static java.lang.String |
composeErrorMessage(SettingItem _settingItem1,
SettingItem _settingItem2,
java.lang.String _strCondition)
Composes an error message that resulted from a comparison between 2 setting items. |
static java.lang.String |
composeErrorMessage(SettingItem _settingItem,
java.lang.String _strCondition)
Composes an error message that resulted from a comparison between 2 setting items. |
static java.lang.String |
fillSpaces(java.lang.String _startString,
int _fillLength)
Utility method: Fills in blank spaces for creating formatted output. |
static java.lang.String |
fillSpacesLeft(java.lang.String _startString,
int _fillLength)
Utility method: Fills in blank spaces for creating formatted output, to the left of the supplied string. |
static java.lang.String |
formatDecimalDisplay(double _numberToFormat,
java.lang.String _formatToApply)
Utility function for applying formatting to numbers. |
static java.lang.StringBuffer |
formatElapsedTime(double _elapsedTime,
int _decimalsToDisplay,
int _formatFlag)
Applies formatting to the elapsed time, based on supplied parameters. |
static java.lang.StringBuffer |
formatRightLeftJustified(java.lang.String _prefix,
java.lang.String _displayItem,
java.lang.String _displayItemValue,
java.lang.String _separator,
int _lineLength)
Utility method: Creates a line of text that is both left and right justified. |
static java.lang.StringBuffer |
getBanjoSignature()
Compiles the setting values that we group as the "Banjo signature". |
static java.lang.String |
getClassName(java.lang.Object _someObj)
Utility method: Returns the name of the class where this method is called from. |
static java.lang.StringBuffer |
getJobSignature(Settings _processData)
Compiles the setting values that we group as the "job signature". |
static java.lang.String |
getReportFileNameMT(java.lang.String _reportFileName,
java.lang.String _prefix,
int _threadIndex)
Generates the report file name for a given thread in the multi-threaded scenario. |
static java.lang.String |
listNodes(int[][] _nodeList)
Utility function for listing a node list (parent list), in the form array[variableIndex][lagIndex]. |
static java.lang.StringBuffer |
listSettings(java.util.Properties _settingsToList)
Utility method (debug/test): Compiles a list of the supplied properties. |
static java.lang.String |
removeTrailingComment(java.lang.String _stringToProcess)
Utility method: Removes comments at the end of a line of text. |
static void |
setProcessData(Settings _processData)
Provides access to the (main) settings. |
static java.lang.String |
timeStamp(Settings _processData,
java.lang.String _settingName,
java.lang.String _timeStampFormat,
java.lang.String _defaultTimeStampFormat)
Composes a basic string that is a time stamp based on the supplied format. |
private static boolean |
validateRequiredData()
Validates the settings values required for the string util. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final int MILLISECSPERSECOND
private static final int MILLISECSPERMINUTE
private static final int MILLISECSPERHOUR
private static final int MILLISECSPERDAY
private static Settings processData
private static java.lang.String cachedTimeStamp
Constructor Detail |
StringUtil()
Method Detail |
public static void setProcessData(Settings _processData) throws java.lang.Exception
_processData
- The settings.
java.lang.Exception
private static boolean validateRequiredData() throws java.lang.Exception
java.lang.Exception
public static java.lang.String fillSpaces(java.lang.String _startString, int _fillLength)
_startString
- The string that is to be filled up with spaces, up to the
specified length._fillLength
- The length to which the string is to be filled.
public static java.lang.String fillSpacesLeft(java.lang.String _startString, int _fillLength)
_startString
- The string that is to be filled up with spaces, up to the
specified length._fillLength
- The length to which the string is to be filled.
public static java.lang.String removeTrailingComment(java.lang.String _stringToProcess)
_stringToProcess
- The string that may contain a comment at the end (comments
are indicated by a # symbol)
public static java.lang.StringBuffer formatRightLeftJustified(java.lang.String _prefix, java.lang.String _displayItem, java.lang.String _displayItemValue, java.lang.String _separator, int _lineLength)
_prefix
- An optional prefix to the display Item._displayItem
- The display Item to be left-hand justified._displayItemValue
- The display Item value that is to be left-hand justified._separator
- A optional separator string for splitting the text._lineLength
- The length of the text line to be returned.
public static java.lang.StringBuffer listSettings(java.util.Properties _settingsToList)
_settingsToList
- Properties to be listed.
public static java.lang.String getClassName(java.lang.Object _someObj)
_someObj
- Object for which we want its class name.
public static java.lang.String arrayAsString(int[] _intArray)
_intArray
- An array of integers.
public static java.lang.StringBuffer getBanjoSignature()
public static java.lang.StringBuffer getJobSignature(Settings _processData)
_processData
- The (main) settings, giving access to the settings and their
values that make up the "job signature' (project, user, dataset, notes).
public static java.lang.String getReportFileNameMT(java.lang.String _reportFileName, java.lang.String _prefix, int _threadIndex)
_reportFileName
- The base part of the report file name (i.e., the one
used by the main thread_prefix
- The prefix to add to file name. In case this string contains
a token for the thread index (ID), we replace the token with
the supplied ID._threadIndex
- The index of the thread that makes the request
public static java.lang.StringBuffer formatElapsedTime(double _elapsedTime, int _decimalsToDisplay, int _formatFlag)
_elapsedTime
- The time to format (expected to be in milliseconds)._decimalsToDisplay
- The number of decimals to format the time with._formatFlag
- The format to apply to the supplied time (plain number with
qualifier, or in special d:h:m:s format).
public static java.lang.String formatDecimalDisplay(double _numberToFormat, java.lang.String _formatToApply)
_numberToFormat
- The number to format with the _formatToApply._formatToApply
- The format to apply to the supplied number
public static java.lang.String listNodes(int[][] _nodeList)
_nodeList
- The list of nodes to be listed.
public static java.lang.String composeErrorMessage(SettingItem _settingItem, java.lang.String _strCondition)
_settingItem
- The setting item._strCondition
- The condition string that the setting item needs to satisfy.
public static java.lang.String composeErrorMessage(SettingItem _settingItem1, SettingItem _settingItem2, java.lang.String _strCondition)
_settingItem1
- The first setting item._settingItem2
- The second setting item._strCondition
- The condition string that the second setting item needs
to satisfy in relation to the first setting item.
public static java.lang.String timeStamp(Settings _processData, java.lang.String _settingName, java.lang.String _timeStampFormat, java.lang.String _defaultTimeStampFormat)
_processData
- The underlying (main) settings object, for placing any errorItems._settingName
- The name of the setting._timeStampFormat
- The time stamp format to be applied in creating a time stamp._defaultTimeStampFormat
- The default time stamp format to be used if the
supplie _timeStampFormat is not a valid one.
public static java.lang.String compileMemoryInfo(java.lang.String _info)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |