gov.nasa.pds.report.util
Class Utility

java.lang.Object
  extended by gov.nasa.pds.report.util.Utility

public class Utility
extends Object

Version:
$Revision$
Author:
jpadams

Constructor Summary
Utility()
           
 
Method Summary
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 List<String> getLocalFileList(String path)
           
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 File replaceStringInFile(String oldStr, String newStr, File in, File out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utility

public Utility()
Method Detail

getDateTime

public static String getDateTime()
Get the current date time.

Returns:
A date time.

getFileDate

public static String getFileDate()

getLocalFileList

public static List<String> getLocalFileList(String path)

getHomeDirectory

public static String getHomeDirectory()

getAbsolutePath

public static String getAbsolutePath(String filePath)
Method to convert the file path to absolute, if relative

Parameters:
filePath - Current path given through the command-line
Returns:
the absolute path from the input file path

replaceStringInFile

public static File replaceStringInFile(String oldStr,
                                       String newStr,
                                       File in,
                                       File out)
                                throws IOException
Throws:
IOException

getValuesFromXML

public static List<String> getValuesFromXML(File file,
                                            String tagName,
                                            String attributeName)
                                     throws Exception
Utility method to extract values from an XML file.

Parameters:
file -
tagName - name of the tag we are looking for
attributeName - if applicable, else set to null
Returns:
Throws:
ParserConfigurationException
SAXException
IOException
Exception

getNodePropsString

public static String getNodePropsString(Properties nodeProps,
                                        String key,
                                        boolean needed)
                                 throws ReportManagerException
Utility method to get a String from a Properties.

Parameters:
nodeProps - The Properties containing the desired value
key - The key of the desired value
needed - Whether the value must be present
Returns:
The desired value in the form of a String
Throws:
LogsManagerException - If needed is true and the given key is not present or if the value is null or empty
ReportManagerException

getNodePropsBool

public static boolean getNodePropsBool(Properties nodeProps,
                                       String key)
                                throws ReportManagerException
Utility method to get a boolean from a Properties.

Parameters:
nodeProps - The Properties containing the desired value
key - The key of the desired value
Returns:
The desired value in the form of a boolean
Throws:
ReportManagerException - If the given key is not present or if the value is null or empty

getDirPath

public static String getDirPath(String pathname)
Remove the filename/expression from the pathname and return base path

Parameters:
pathname -
Returns:
A String of the path of the directory containing the file

countSubstringInstances

public static int countSubstringInstances(String haystack,
                                          String needle)
Get the number of times that a substring occurs in a String

Parameters:
haystack - The string to search through
needle - The substring to for which we search
Returns:
The number of times that the substring occurs within the String


Copyright © 2010–2015 Planetary Data System. All rights reserved.