|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.extex.resource.AbstractFinder
org.extex.resource.FileFinder
public class FileFinder
This file finder searches for the file in different directories and with several extensions.
<Finder class="de.dante.util.resource.FileFinder"
trace="false"
default="default">
<tex>
<path property="extex.texinputs"/>
<path property="texinputs"/>
<path env="EXTEX_TEXINPUTS"/>
<path env="TEXINPUTS"/>
<path>.</path>
<extension></extension>
<extension>.tex</extension>
</tex>
<fmt>
<path property="extex.texinputs"/>
<path property="texinputs"/>
<path env="EXTEX_TEXINPUTS"/>
<path env="TEXINPUTS"/>
<path>.</path>
<extension></extension>
<extension>.fmt</extension>
</fmt>
<default>
<path property="extex.texinputs"/>
<path property="texinputs"/>
<path env="EXTEX_TEXINPUTS"/>
<path env="TEXINPUTS"/>
<path>.</path>
<extension></extension>
</default>
</Finder>
Whenever a resource is sought its type is used to find the appropriate parameters for the search. If the sub-configuration with the name of the type exists then this sub-configuration is used. For instance if the resource tex with the type fmt is sought then the sub-configuration fmt determines how to find this file.
If no sub-configuration of the given type is present then the attribute default is used to find the default sub-configuration. In the example given above this default configuration is called default. Nevertheless it would also be possible to point the default configuration to another existing configuration. The attribute default is mandatory.
Each sub-configuration takes the tags path and extension in arbitrary number. path contains the path prepended before the resource name. extension contains the extension appended after the resource name.
path can carry the attribute property. In this case the value is ignored and the value is taken from the property named in the attribute. Otherwise the value of the tag is taken as path. The value taken from the property can contain several paths. They are separated by the separator specified for the platform. For instance on windows the separator ; is used and on Unix the separator : is used.
path can carry the attribute env. In this case the value is ignored and the value is taken from the environment variable named in the attribute. Otherwise the value of the tag is taken as path. The value taken from the environment variable can contain several paths. They are separated by the separator specified for the platform. For instance on windows the separator ; is used and on Unix the separator : is used.
When the full file name contains the string {type} this string is replaced by the type currently sought. This can for instance be used in default specification to attach the type as extension.
All combinations of path, resource name and extension are tried in turn. If one combination leads to a readable file then an input stream to this file is used.
The attribute trace can be used to force a tracing of the actions in the log file. The tracing is performed only if a logger is present when needed. The tracing flag can be overwritten at run-time. The attribute trace is optional.
| Field Summary |
|---|
| Fields inherited from class org.extex.resource.AbstractFinder |
|---|
ATTR_DEFAULT, ATTR_SKIP, ATTR_TRACE, EXTENSION_TAG |
| Constructor Summary | |
|---|---|
FileFinder(Configuration configuration)
Creates a new object. |
|
| Method Summary | |
|---|---|
NamedInputStream |
findResource(java.lang.String name,
java.lang.String type)
Find a resource which can be used for reading. |
void |
setEnvironment(java.util.Map<java.lang.String,java.lang.String> environment)
Setter for the environment. |
void |
setProperties(java.util.Properties properties)
Setter for the properties. |
| Methods inherited from class org.extex.resource.AbstractFinder |
|---|
enableLogging, enableTracing, getConfiguration, trace |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FileFinder(Configuration configuration)
throws ConfigurationMissingException
configuration - the encapsulated configuration object
ConfigurationMissingException - in case of an error| Method Detail |
|---|
public NamedInputStream findResource(java.lang.String name,
java.lang.String type)
throws ConfigurationException
ResourceFindernull is returned.
findResource in interface ResourceFindername - the base name of the resourcetype - the type, i.e. the extension
null if none could be found
ConfigurationException - in case of an exceptionResourceFinder.findResource(java.lang.String,
java.lang.String)public void setEnvironment(java.util.Map<java.lang.String,java.lang.String> environment)
setEnvironment in interface EnvironmentAwareenvironment - the environmentpublic void setProperties(java.util.Properties properties)
PropertyAware
setProperties in interface PropertyAwareproperties - the properties to use for configurationPropertyAware.setProperties(
java.util.Properties)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||