Class Util
- java.lang.Object
-
- org.glassfish.appclient.client.acc.Util
-
public class Util extends Object
Utility methods- Author:
- tjquinn
-
-
Constructor Summary
Constructors Constructor Description Util()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ArchiveFactory
getArchiveFactory()
static ArchivistFactory
getArchivistFactory()
static URI
getURI(File f)
static URI
getURI(String s)
static String
replaceTokens(String s, Properties values)
Searches for placeholders of the form ${token-name} in the input String, retrieves the property with name token-name from the Properties object, and (if found) replaces the token in the input string with the property value.static String
toXMLEscaped(String content)
static File
verifyFilePath(String filePath)
Returns a File for the specified path if the file exists and is readable.static File
writeTextToTempFile(String content, String prefix, String suffix, boolean retainTempFiles)
Writes the provided text to a temporary file marked for deletion on exit.
-
-
-
Method Detail
-
verifyFilePath
public static File verifyFilePath(String filePath) throws FileNotFoundException, IOException
Returns a File for the specified path if the file exists and is readable.- Parameters:
filePath
-- Returns:
- Throws:
FileNotFoundException
IOException
-
getArchiveFactory
public static ArchiveFactory getArchiveFactory()
-
getArchivistFactory
public static ArchivistFactory getArchivistFactory()
-
getURI
public static URI getURI(String s) throws URISyntaxException
- Throws:
URISyntaxException
-
getURI
public static URI getURI(File f) throws URISyntaxException
- Throws:
URISyntaxException
-
writeTextToTempFile
public static File writeTextToTempFile(String content, String prefix, String suffix, boolean retainTempFiles) throws IOException, FileNotFoundException
Writes the provided text to a temporary file marked for deletion on exit.- Parameters:
content
- the content to be writtenprefix
- for the temp file, conforming to the File.createTempFile requirementssuffix
- for the temp file- Returns:
- File object for the newly-created temp file
- Throws:
IOException
- for any errors writing the temporary fileFileNotFoundException
- if the temp file cannot be opened for any reason
-
replaceTokens
public static String replaceTokens(String s, Properties values)
Searches for placeholders of the form ${token-name} in the input String, retrieves the property with name token-name from the Properties object, and (if found) replaces the token in the input string with the property value.- Parameters:
s
- String possibly containing tokensvalues
- Properties object containing name/value pairs for substitution- Returns:
- the original string with tokens substituted using their values from the Properties object
-
-