public class Utility extends Object
Constructor and Description |
---|
Utility() |
Modifier and Type | Method and Description |
---|---|
static int |
countSubstringInstances(String haystack,
String needle)
Get the number of times that a substring occurs in a String
|
static String |
getAbsolutePath(String filePath)
Method to convert the file path to absolute, if relative
|
static String |
getDateTime()
Get the current date time.
|
static String |
getDirPath(String pathname)
Remove the filename/expression from the pathname and return base path
|
static String |
getFileDate() |
static String |
getHomeDirectory() |
static boolean |
getNodePropsBool(Properties nodeProps,
String key)
Utility method to get a boolean from a
Properties . |
static String |
getNodePropsString(Properties nodeProps,
String key,
boolean needed)
Utility method to get a String from a
Properties . |
static List<String> |
getValuesFromXML(File file,
String tagName,
String attributeName)
Utility method to extract values from an XML file.
|
static boolean |
isReportTime()
Determine if the current day is during the portion of the month when
reports are generated.
|
static File |
replaceStringInFile(String oldStr,
String newStr,
File in,
File out) |
public static String getDateTime()
public static String getFileDate()
public static String getHomeDirectory()
public static String getAbsolutePath(String filePath)
filePath
- Current path given through the command-linepublic static File replaceStringInFile(String oldStr, String newStr, File in, File out) throws IOException
IOException
public static List<String> getValuesFromXML(File file, String tagName, String attributeName) throws Exception
file
- tagName
- name of the tag we are looking forattributeName
- if applicable, else set to nullParserConfigurationException
SAXException
IOException
Exception
public static String getNodePropsString(Properties nodeProps, String key, boolean needed) throws ReportManagerException
Properties
.nodeProps
- The Properties containing the desired valuekey
- The key of the desired valueneeded
- Whether the value must be presentLogsManagerException
- If needed is true and the given key is not present or if the value is null or emptyReportManagerException
public static boolean getNodePropsBool(Properties nodeProps, String key) throws ReportManagerException
Properties
.nodeProps
- The Properties containing the desired
valuekey
- The key of the desired valueReportManagerException
- If the given key is not present or if
the value is null or emptypublic static String getDirPath(String pathname)
pathname
- public static int countSubstringInstances(String haystack, String needle)
haystack
- The string to search throughneedle
- The substring to for which we searchpublic static boolean isReportTime()
Copyright © 2010–2018 Planetary Data System. All rights reserved.