Class BasicStaticFiles
java.lang.Object
org.apache.juneau.rest.staticfile.BasicStaticFiles
- All Implemented Interfaces:
FileFinder
,StaticFiles
API for retrieving localized static files from either the classpath or file system.
Provides the same functionality as BasicFileFinder
but adds support for returning files as HttpResource
objects with arbitrary headers.
See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.juneau.rest.staticfile.StaticFiles
StaticFiles.Builder, StaticFiles.Void
-
Constructor Summary
ModifierConstructorDescriptionprotected
Constructor.BasicStaticFiles
(BeanStore beanStore) Constructor.BasicStaticFiles
(StaticFiles.Builder builder) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic StaticFiles.Builder
Creates a new builder for this object.boolean
Returns the contents of the resource with the specified name.Returns the file with the specified name as a string.int
hashCode()
Resolve the specified path.toString()
-
Constructor Details
-
BasicStaticFiles
Constructor.- Parameters:
beanStore
- The bean store containing injectable beans for this logger.
-
BasicStaticFiles
Constructor.- Parameters:
builder
- The builder object.
-
BasicStaticFiles
protected BasicStaticFiles()Constructor.Can be used when subclassing and overriding the
resolve(String, Locale)
method.
-
-
Method Details
-
create
Creates a new builder for this object.- Parameters:
beanStore
- The bean store to use for creating beans.- Returns:
- A new builder for this object.
-
resolve
Resolve the specified path.Subclasses can override this method to provide specialized handling.
- Specified by:
resolve
in interfaceStaticFiles
- Parameters:
path
- The path to resolve to a static file.locale
- Optional locale.- Returns:
- The resource, or
null if not found.
-
hashCode
-
equals
-
getStream
Description copied from interface:FileFinder
Returns the contents of the resource with the specified name.- Specified by:
getStream
in interfaceFileFinder
- Parameters:
name
- The resource name. SeeClass.getResource(String)
for format.locale
- The locale of the resource to retrieve.
Ifnull , won't look for localized file names.- Returns:
- The resolved resource contents, or
null if the resource was not found. - Throws:
IOException
- Thrown by underlying stream.
-
getString
Description copied from interface:FileFinder
Returns the file with the specified name as a string.- Specified by:
getString
in interfaceFileFinder
- Parameters:
name
- The file name.locale
- The locale of the resource to retrieve.
Ifnull , won't look for localized file names.- Returns:
- The contents of the file as a string. Assumes UTF-8 encoding.
- Throws:
IOException
- If file could not be read.
-
toString
-