|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectFileUtils
public class FileUtils
Provides file-related utilities to be called by XSLT stylesheets through Saxon's extension function mechanism.
Field Summary | |
---|---|
private static HashMap |
dateFormatCache
Used to avoid recreating SimpleDateFormat objects all the time |
private static ThreadLocal<ArrayList<File>> |
tempFiles
Used to track temp files, per thread |
Constructor Summary | |
---|---|
FileUtils()
|
Method Summary | |
---|---|
static String |
createTempFile(XPathContext context,
String prefix,
String suffix)
Generates a temporary file in the default temporary-file directory, using the given prefix and suffix to generate the name. |
static String |
curDateTime(XPathContext context,
String formatStr)
Gets the current date and time. |
static void |
deleteTempFiles()
Deletes all temporary files created by the current thread using createTempFile(net.sf.saxon.expr.XPathContext, java.lang.String, java.lang.String) . |
static boolean |
exists(XPathContext context,
String filePath)
Checks whether a file with the given path exists (that is, if it can be read.) |
private static SimpleDateFormat |
getDateFormat(String formatStr)
Get a SimpleDateFormatter for the given format string. |
static String |
lastModified(XPathContext context,
String filePath,
String formatStr)
Gets the last-modified time of the file with the given path exists (that is, if it can be read.) |
static long |
length(XPathContext context,
String filePath)
Gets the size in bytes of the file with the given path (that is, if it can be read.) |
static DocumentInfo |
readHTMLPage(XPathContext context,
String urlStr)
Reads in an HTML page (specified by URL), and uses JTidy to make it into XML that can be subsequently processed by a stylesheet. |
static DocumentInfo |
readXMLStub(XPathContext context,
String filePath)
Reads in the first part of an XML file, stopping at the first close-element marker. |
private static File |
resolveFile(XPathContext context,
String filePath)
Resolve the location of a file given the stylesheet context. |
static String |
resolvePath(XPathContext context,
String filePath)
Resolve the location of a file given the stylesheet context. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static HashMap dateFormatCache
private static ThreadLocal<ArrayList<File>> tempFiles
Constructor Detail |
---|
public FileUtils()
Method Detail |
---|
public static boolean exists(XPathContext context, String filePath)
context
- Context used to figure out which stylesheet is calling
the function.filePath
- Path to the file in question
public static String lastModified(XPathContext context, String filePath, String formatStr)
context
- Context used to figure out which stylesheet is calling
the function.filePath
- Path to the file in questionformatStr
- A simple format string; see SimpleDateFormat
.
public static long length(XPathContext context, String filePath)
context
- Context used to figure out which stylesheet is calling
the function.filePath
- Path to the file in question
private static File resolveFile(XPathContext context, String filePath)
public static String resolvePath(XPathContext context, String filePath)
public static String curDateTime(XPathContext context, String formatStr)
context
- Context used to figure out which stylesheet is calling
the function.formatStr
- A simple format string; see SimpleDateFormat
.
private static SimpleDateFormat getDateFormat(String formatStr)
formatStr
- is the format string to use
public static String createTempFile(XPathContext context, String prefix, String suffix) throws IOException
context
- Context used to figure out which stylesheet is calling
the function.prefix
- Prefix for the resulting file name.suffix
- Suffix for the resulting file name.
IOException
public static void deleteTempFiles()
createTempFile(net.sf.saxon.expr.XPathContext, java.lang.String, java.lang.String)
.
public static DocumentInfo readXMLStub(XPathContext context, String filePath) throws IOException, XPathException
IOException
- if the file can't be read
XPathException
- if the document cannot be parsedpublic static DocumentInfo readHTMLPage(XPathContext context, String urlStr) throws IOException, XPathException
IOException
- if the file can't be read
XPathException
- if the document cannot be parsed
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |