|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.ejen.ext.FileUtil
File utility (static methods).
Usage (XSL stylesheet) |
---|
<?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" ... xmlns:fiu="org.ejen.ext.FileUtil" exclude-result-prefixes="fiu ..." version="1.0"> <xsl:output method="xml" encoding="iso-8859-1"/> <xsl:template match="ejen"> <xsl:copy-of select="fiu: |
Field Summary | |
static String |
S_FALSE
|
static String |
S_TRUE
|
Constructor Summary | |
protected |
FileUtil()
Protected constructor (prevents instanciation). |
Method Summary | |
protected static void |
appendFiles(Document doc,
NodeSet ns,
File[] files,
FileFilter ff,
boolean rec)
Creates "file" Nodes and adds them to a NodeSet. |
static NodeSet |
listFiles(ExpressionContext context,
String path)
Returns a NodeSet that contains files list for a given directory. |
static NodeSet |
listFiles(ExpressionContext context,
String path,
String filter)
Returns a NodeSet that contains a filtered files list for a given directory. |
static NodeSet |
listFiles(ExpressionContext context,
String path,
String filter,
boolean rec)
Returns a NodeSet that contains a filtered files list for a given directory and (optionally) for its sub-directories. |
static NodeSet |
properties(ExpressionContext context,
String fileName)
Returns a NodeSet that contains informations about the fileName file. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String S_TRUE
public static final String S_FALSE
Constructor Detail |
protected FileUtil()
Method Detail |
public static NodeSet properties(ExpressionContext context, String fileName)
<xsl:value-of select="fiu:properties('$file-name')"/> |
The returned NodeSet will have the following structure:
<raw><![CDATA[../../ejb-1.1/bmp-jboss-hsqldb/out/test/src/org/ejb/test/EJB_DOUBLE_UNIQUE_PK.java]]></raw> <name><![CDATA[EJB_DOUBLE_UNIQUE_PK.java]]></name> <name-no-ext><![CDATA[EJB_DOUBLE_UNIQUE_PK]]></name-no-ext> <parent><![CDATA[../../ejb-1.1/bmp-jboss-hsqldb/out/test/src/org/ejb/test]]></parent> <path><![CDATA[../../ejb-1.1/bmp-jboss-hsqldb/out/test/src/org/ejb/test/EJB_DOUBLE_UNIQUE_PK.java]]></path> <is-absolute><![CDATA[false]]></is-absolute> <absolute-path><![CDATA[/devs/java/ejen-1.0-pre2/examples/simples/file/../../ejb-1.1/bmp-jboss-hsqldb/out/test/src/org/ejb/test/EJB_DOUBLE_UNIQUE_PK.java]]></absolute-path> <canonical-path><![CDATA[/devs/java/ejen-1.0-pre2/examples/ejb-1.1/bmp-jboss-hsqldb/out/test/src/org/ejb/test/EJB_DOUBLE_UNIQUE_PK.java]]></canonical-path> <url><![CDATA[file:/devs/java/ejen-1.0-pre2/examples/simples/file/../../ejb-1.1/bmp-jboss-hsqldb/out/test/src/org/ejb/test/EJB_DOUBLE_UNIQUE_PK.java]]></url> <can-read><![CDATA[true]]></can-read> <can-write><![CDATA[true]]></can-write> <exists><![CDATA[true]]></exists> <is-directory><![CDATA[false]]></is-directory> <is-hidden><![CDATA[false]]></is-hidden> <last-modified><![CDATA[1016763382000]]></last-modified> <length><![CDATA[2380]]></length> |
"raw" node contains simply the fileName parameter value. Some of those Nodes may not be available (MalformedURLException [url], IOException [canonical-path], or SecurityException [can-read, can-write, ..., length]).
See File
.
context
- automatically passed by the xalan extension mechanism.fileName
- name of the file.
WrappedRuntimeException
- DOM error.public static NodeSet listFiles(ExpressionContext context, String path)
This method does not filter anything but directories (only regular file names are returned) and is not recursive (only file names in the given directory are listed).
<xsl:value-of select="fiu:listFiles('../../src/org/ejen/ext')"/> |
The returned NodeSet will have the following structure:
<file> <path><![CDATA[/devs/java/ejen-1.0-pre3/src/org/ejen/ext]]></path> <sep><![CDATA[/]]></sep> <name><![CDATA[XMLInclude.java]]></name> </file> <file> <path><![CDATA[/devs/java/ejen-1.0-pre3/src/org/ejen/ext]]></path> <sep><![CDATA[/]]></sep> <name><![CDATA[FileUtil.java]]></name> </file> ... |
"path" Nodes contain "canonical" paths (absolute, without symbolic links, etc.). Because this method is not recursive, "path" Nodes will be always equal to the canonical representation of the "path" argument.
context
- automatically passed by the xalan extension mechanism.path
- directory path.
WrappedRuntimeException
- DOM or IO errors...public static NodeSet listFiles(ExpressionContext context, String path, String filter)
This method is not recursive (only file names in the given
directory are listed). The "filter" argument must be a regular expression
(see RE
) and only refers to regular file names (neither
directory names nor full path file names).
Tips: "\.java$
" means "accept file names that end with
'.java
'". "\.java$|\.jjt$
" means "accept file names
that end with '.java
' or '.jjt
'".
<xsl:value-of select="fiu:listFiles('../../src','\.java$|\.jjt$')"/> |
See listFiles(ExpressionContext, String)
.
context
- automatically passed by the xalan extension mechanism.path
- directory path.filter
- file name filter.
WrappedRuntimeException
- DOM or IO errors...public static NodeSet listFiles(ExpressionContext context, String path, String filter, boolean rec)
This method is recursive if the "rec" argument is true. The "filter" argument must
be a regular expression (see listFiles(ExpressionContext, String,String)
).
<xsl:value-of select="fiu:listFiles('../../src','\.java$|\.jjt$',true())"/> |
context
- automatically passed by the xalan extension mechanism.path
- directory path.filter
- file name filter.rec
- true (recursive) or false.
WrappedRuntimeException
- DOM or IO errors...protected static void appendFiles(Document doc, NodeSet ns, File[] files, FileFilter ff, boolean rec) throws Exception
doc
- Document to be used for Node creation.ns
- NodeSet (where Nodes have to be added).files
- files list.ff
- FileFilter to use.rec
- true (recursive) or false.
WrappedRuntimeException
- DOM or IO errors...
Exception
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |