Package digilib.conf
Class DigilibRequest
- java.lang.Object
-
- digilib.util.ParameterMap
-
- digilib.conf.DigilibRequest
-
- Direct Known Subclasses:
DigilibServletRequest
public class DigilibRequest extends ParameterMap
Class holding the parameters of a digilib user request. The parameters are mostly named like the servlet parameters:
request.path: url of the page/document.
fn: url of the page/document.
pn: page number.
dw: width of result window in pixels.
dh: height of result window in pixels.
wx: left edge of image area (float from 0 to 1).
wy: top edge of image area (float from 0 to 1).
ww: width of image area(float from 0 to 1).
wh: height of image area(float from 0 to 1).
ws: scale factor.
mo: special options like 'fit'.
...et cetera- Author:
- casties
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DigilibRequest.ParsingOption
special options for parsing the request.
-
Field Summary
Fields Modifier and Type Field Description protected DigilibConfiguration
config
DigilibConfiguration for this requestString
errorMessage
error message while configuringString
iiifApiVersion
IIIF image API versionString
iiifPrefix
IIIF path prefix (taken from config)protected String
iiifSlashReplacement
IIIF slash replacement (taken from config)boolean
parseIiifImageApi
parse IIIF path as IIIF image APIEnumSet<DigilibRequest.ParsingOption>
parsingOptions
active pasing optionsprotected ImageJobDescription
ticket
ImageJobDescription for this request-
Fields inherited from class digilib.util.ParameterMap
options, params
-
-
Constructor Summary
Constructors Constructor Description DigilibRequest()
DigilibRequest(DigilibConfiguration config)
Create DigilibRequest with DigilibConfiguration.DigilibRequest(DigilibConfiguration config, ParameterMap params)
Create DigilibRequest with DigilibConfiguration with added ParameterMap.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description String
decodeIiifIdentifier(String identifier)
Decodes the IIIF identifier part into a digilib path.String
encodeIiifIdentifier(String path)
Encodes a digilib path into an IIIF identifier partString
getAsString()
Return the request parameters as a String in the parameter form 'fn=/icons&pn=1'.String
getAsString(int type)
Return the request parameters of a given type type as a String in the parameter form 'fn=/icons&pn=1'.DigilibConfiguration
getDigilibConfig()
String
getFilePath()
The image file path to be accessed.ImageJobDescription
getJobDescription()
boolean
hasOption(String param, String opt)
Deprecated.useParameterMap.hasOption(DigilibOption)
for "mo"-options.protected void
initOptions()
set up optionsprotected void
initParams()
Define and set up parameters with default values.void
setDigilibConfig(DigilibConfiguration config)
void
setJobDescription(ImageJobDescription ticket)
boolean
setWithIiifImageParams(String identifier, String region, String size, String rotation, String quality, String format)
Populate a request from IIIF image API parameters.boolean
setWithIiifPath(String path)
Populate a request from a string with an IIIF image API path.void
setWithParamString(String qs, String sep)
Set request parameters from query string.-
Methods inherited from class digilib.util.ParameterMap
cloneInstance, get, getAsBoolean, getAsFile, getAsFloat, getAsInt, getAsString, getInstance, getOptions, getParameters, getParams, getValue, hasOption, hasValue, newParameter, newParameter, put, put, setOptions, setParams, setValue, setValue, setValue, setValueFromString
-
-
-
-
Field Detail
-
parsingOptions
public EnumSet<DigilibRequest.ParsingOption> parsingOptions
active pasing options
-
iiifPrefix
public String iiifPrefix
IIIF path prefix (taken from config)
-
iiifSlashReplacement
protected String iiifSlashReplacement
IIIF slash replacement (taken from config)
-
iiifApiVersion
public String iiifApiVersion
IIIF image API version
-
parseIiifImageApi
public boolean parseIiifImageApi
parse IIIF path as IIIF image API
-
errorMessage
public String errorMessage
error message while configuring
-
ticket
protected ImageJobDescription ticket
ImageJobDescription for this request
-
config
protected DigilibConfiguration config
DigilibConfiguration for this request
-
-
Constructor Detail
-
DigilibRequest
public DigilibRequest()
-
DigilibRequest
public DigilibRequest(DigilibConfiguration config)
Create DigilibRequest with DigilibConfiguration.- Parameters:
config
- the DigilibConfiguration
-
DigilibRequest
public DigilibRequest(DigilibConfiguration config, ParameterMap params)
Create DigilibRequest with DigilibConfiguration with added ParameterMap.- Parameters:
config
- the DigilibConfigurationparams
- ParameterMap to add
-
-
Method Detail
-
initParams
protected void initParams()
Define and set up parameters with default values.- Overrides:
initParams
in classParameterMap
-
initOptions
protected void initOptions()
Description copied from class:ParameterMap
set up options- Overrides:
initOptions
in classParameterMap
-
getAsString
public String getAsString()
Return the request parameters as a String in the parameter form 'fn=/icons&pn=1'. Empty (undefined) fields are not included.- Returns:
- String of request parameters in parameter form.
-
getAsString
public String getAsString(int type)
Return the request parameters of a given type type as a String in the parameter form 'fn=/icons&pn=1'. Empty (undefined) fields are not included.- Parameters:
type
- the type- Returns:
- String of request parameters in parameter form.
-
setWithParamString
public void setWithParamString(String qs, String sep)
Set request parameters from query string. Uses the separator string qs to get 'fn=foo' style parameters.- Parameters:
qs
- query stringsep
- parameter-separator string
-
setWithIiifPath
public boolean setWithIiifPath(String path)
Populate a request from a string with an IIIF image API path. path should be non-URL-decoded and have no leading slash. URI template: {scheme}://{server}{/prefix}/{identifier}/{region}/{size}/{rotation}/{quality}.{format}- Parameters:
path
- String with IIIF Image API path.- Returns:
- true of successful
- See Also:
- IIIF Image API
-
setWithIiifImageParams
public boolean setWithIiifImageParams(String identifier, String region, String size, String rotation, String quality, String format)
Populate a request from IIIF image API parameters.- Parameters:
identifier
- the identifierregion
- the regionsize
- the sizerotation
- the rotationquality
- the qualityformat
- the format- Returns:
- true if successful
- See Also:
- IIIF Image API
-
decodeIiifIdentifier
public String decodeIiifIdentifier(String identifier)
Decodes the IIIF identifier part into a digilib path.- Parameters:
identifier
- the identifier- Returns:
- the path
- Throws:
UnsupportedEncodingException
- on error
-
encodeIiifIdentifier
public String encodeIiifIdentifier(String path)
Encodes a digilib path into an IIIF identifier part- Parameters:
path
- the path- Returns:
- the identifier
- Throws:
UnsupportedEncodingException
- on error
-
hasOption
public boolean hasOption(String param, String opt)
Deprecated.useParameterMap.hasOption(DigilibOption)
for "mo"-options.Test if option stringopt
is set. Checks if the substringopt
is contained in the options stringparam
.- Parameters:
param
- the paramopt
- Option string to be tested.- Returns:
- if option is set
-
getFilePath
public String getFilePath()
The image file path to be accessed. The image file path is assembled from the servlets RequestPath and Parameter fn and normalized.- Returns:
- the effective filepath.
-
getJobDescription
public ImageJobDescription getJobDescription()
- Returns:
- the ticket
-
setJobDescription
public void setJobDescription(ImageJobDescription ticket)
- Parameters:
ticket
- the ticket to set
-
getDigilibConfig
public DigilibConfiguration getDigilibConfig()
- Returns:
- the config
-
setDigilibConfig
public void setDigilibConfig(DigilibConfiguration config)
- Parameters:
config
- the config to set
-
-