Package dap4.servlet
Class URLMapDefault
- java.lang.Object
-
- dap4.servlet.URLMapDefault
-
- All Implemented Interfaces:
URLMap
public class URLMapDefault extends Object implements URLMap
Define a URL map that assumes that there some prefix of the urlpath that can be replaced by a path prefix and that everything else is the same. The mapping is carried out from a properties file that has lines of the form=
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface dap4.servlet.URLMap
URLMap.Result
-
-
Constructor Summary
Constructors Constructor Description URLMapDefault()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddEntry(String urlpath, String fileprefix)Add an entry into the map.voidload(String filepath)protected URLMap.Resultlongestmatch(SortedMap<String,String> map, String prefix)URLMap.ResultmapPath(String path)Inverse of mapURL; returns a url path and suffix: U,S such that mapURL(U)+S = path Return a Pair specifying: 1.URLMap.ResultmapURL(String urlpath)Use some maximal prefix of the url path to locate the associated file path prefix.StringtoString()
-
-
-
Method Detail
-
addEntry
public void addEntry(String urlpath, String fileprefix) throws dap4.core.util.DapException
Description copied from interface:URLMapAdd an entry into the map. Any trailing / on urlprefix or leading / on file prefix will be removed.
-
load
public void load(String filepath) throws IOException
- Throws:
IOException
-
mapURL
public URLMap.Result mapURL(String urlpath) throws dap4.core.util.DapException
Description copied from interface:URLMapUse some maximal prefix of the url path to locate the associated file path prefix. Return a Pair specifying: 1. Pair.prefix: path specifying the file path associated with the url prefix 2. Pair.suffix: the suffix of the url path that was not used.- Specified by:
mapURLin interfaceURLMap- Parameters:
urlpath- a string specifying the url path to be mapped- Returns:
- Pair returning items 1 an 2 above.
- Throws:
dap4.core.util.DapException- if the map fails Note that this map does not deal with the whole url, only the path part because as a rule, the host+port is unknown at the time the map is built and also because there might be multiple hosts using the same map.
-
mapPath
public URLMap.Result mapPath(String path) throws dap4.core.util.DapException
Description copied from interface:URLMapInverse of mapURL; returns a url path and suffix: U,S such that mapURL(U)+S = path Return a Pair specifying: 1. Pair.prefix: path specifying the url path associated with the file prefix 2. Pair.suffix: the suffix of the file path that was not used.
-
longestmatch
protected URLMap.Result longestmatch(SortedMap<String,String> map, String prefix)
-
-