Class DirectoryTemplate
- All Implemented Interfaces:
Handler
,TemplateInterface
<filelist>
tag, if present in the document,
triggers the generation of a directory and file listing, based on the
current URL.
Template Properties:
- prepend
- String to prepend to the properties "Directories" and "Files" That contain the directory and file lists respectively. Defaults to the Templates properties prefix.
- delimiter
- Delimiter character to separate entries, defaults to " ".
- directory
- The directory to use instead of the one implied by the URL.
If it starts with "/", then it is resolved relative to the
document root, otherwise it is resolved relative to the
directory implied by the URL. The document root is
found in the porperty
"[prefix].root"
, or in"root"
, or (if neither exists), the current directory of the server. - DirectoryName
- If set (usually by an upstream handler, such as the FileHandler, or TemplateHandler), this is used as the directory name instead of deriving it from the URL.
- debug
- if set, a comment is emitted indicating where the file-list entitiy was encountered.
- [prepend].Directories
- List of sub-directories in current directory is set by this template.
- [prepend].Files
- List of files with valid suffixes in current directory. is set by this template.
- mime.xxx
- An indication that suffix "xxx" is valid.
Only valid file names are returned.
See
FileHandler
for a description of how to set mime types for url suffixes. - select
- Specifies a "glob" pattern to restrict the names of files and directories returned. The form "![pattern]" selects the inverse of the glob pattern.
- stats
- If specified, then for each file, the properties: [prepend].[file].mod and [prepend].[file].size are set, containing the file last modified time (seconds since epoch) and size (bytes) respectively.
prefix
is used to match the leading
portion of a URL.
The tag takes the optional parameters: prepend
and stats
that override the corrosponding request
properties (above). In addition, the attribute dir
may be used to select an alternate directory for files.
- Version:
- %V% DirectoryTemplate.java
- Author:
- Stephen Uhler
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
Generate properties containing the files and directories in the "current" directory.boolean
Initializes the handler.boolean
init
(RewriteContext hr) Reset at each pageboolean
Compute the directory info, and add it to the request properties.void
Turn on the directory calculator.
-
Constructor Details
-
DirectoryTemplate
public DirectoryTemplate()
-
-
Method Details
-
init
Description copied from interface:Handler
Initializes the handler.- Specified by:
init
in interfaceHandler
- Parameters:
server
- The HTTP server that created thisHandler
. TypicalHandler
s will useServer.props
to obtain run-time configuration information.prefix
- The handlers name. The string thisHandler
may prepend to all of the keys that it uses to extract configuration information fromServer.props
. This is set (by theServer
andChainHandler
) to help avoid configuration parameter namespace collisions.- Returns:
true
if thisHandler
initialized successfully,false
otherwise. Iffalse
is returned, thisHandler
should not be used.
-
respond
Compute the directory info, and add it to the request properties. -
init
Reset at each page- Specified by:
init
in interfaceTemplateInterface
- Overrides:
init
in classTemplate
-
tag_filelist
Turn on the directory calculator. The presense of this tag causes the files and subdirectories in the current directory to be added to the request properties.The attribute "stats" may be specified to enable additional statistics, overriding the request properties.
-
getFiles
Generate properties containing the files and directories in the "current" directory. The current directory is taken from the "DirectoryName" request property, or derived from the URL. This functionality was culled from the FileHandler and the Directory Handler.If "directory" is specified (e.g. not null), then it is used as the directory instead. If "directory" starts with "/" then the directory is resolved relative to the document root, otherwise it is resolved relative to the current directory. If "select" is specified, then only files or directories matching the supplied glob pattern are selected. If the first character of "select" is "!", then the sense of the glob pattern is inverted.
-