Package org.restlet.routing
Class TemplateRoute
java.lang.Object
org.restlet.Restlet
org.restlet.routing.Filter
org.restlet.routing.Route
org.restlet.routing.TemplateRoute
- All Implemented Interfaces:
Uniform
Filter scoring the affinity of calls with the attached Restlet. The score is
used by an associated Router to determine the most appropriate
Restlet for a given call. The routing is based on a reference template.
Concurrency note: instances of this class or its subclasses can be invoked by several threads at the same time and therefore must be thread-safe. You should be especially careful when storing state in member variables.
Concurrency note: instances of this class or its subclasses can be invoked by several threads at the same time and therefore must be thread-safe. You should be especially careful when storing state in member variables.
- Author:
- Jerome Louvel
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionTemplateRoute(Restlet next) Constructor behaving as a simple extractor filter.TemplateRoute(Router router, String uriTemplate, Restlet next) Constructor.TemplateRoute(Router router, Template template, Restlet next) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected intbeforeHandle(Request request, Response response) Allows filtering before its handling by the target Restlet.intReturns the matching mode to use on the template when parsing a formatted reference.Returns the reference template to match.booleanIndicates whether the query part should be taken into account when matching a reference with the template.floatReturns the score for a given call (between 0 and 1.0).voidsetMatchingMode(int matchingMode) Sets the matching mode to use on the template when parsing a formatted reference.voidsetMatchingQuery(boolean matchingQuery) Sets whether the matching should be done on the URI with or without query string.voidsetTemplate(Template template) Sets the reference template to match.toString()Methods inherited from class org.restlet.routing.Filter
afterHandle, doHandle, getNext, handle, hasNext, setNext, setNext, start, stopMethods inherited from class org.restlet.Restlet
createFinder, finalize, getApplication, getAuthor, getContext, getDescription, getFinderClass, getLogger, getName, getOwner, handle, handle, handle, isStarted, isStopped, setAuthor, setContext, setDescription, setFinderClass, setName, setOwner
-
Constructor Details
-
TemplateRoute
Constructor behaving as a simple extractor filter.- Parameters:
next- The next Restlet.
-
TemplateRoute
Constructor. The URIs will be matched against the template using theTemplate.MODE_STARTS_WITHmatching mode. This can be changed by getting the template and callingTemplate.setMatchingMode(int)withTemplate.MODE_EQUALSfor exact matching.- Parameters:
router- The parent router.uriTemplate- The URI template.next- The next Restlet.
-
TemplateRoute
Constructor.- Parameters:
router- The parent router.template- The URI template.next- The next Restlet.
-
-
Method Details
-
beforeHandle
Allows filtering before its handling by the target Restlet. By default, it parses the template variable, adjusts the base reference of the target resource's reference.- Overrides:
beforeHandlein classFilter- Parameters:
request- The request to filter.response- The response to filter.- Returns:
- The continuation status.
-
getMatchingMode
public int getMatchingMode()Returns the matching mode to use on the template when parsing a formatted reference.- Returns:
- The matching mode to use.
-
getTemplate
Returns the reference template to match.- Returns:
- The reference template to match.
-
isMatchingQuery
public boolean isMatchingQuery()Indicates whether the query part should be taken into account when matching a reference with the template.- Returns:
- True if the query part of the reference should be taken into account, false otherwise.
-
score
Returns the score for a given call (between 0 and 1.0). -
setMatchingMode
public void setMatchingMode(int matchingMode) Sets the matching mode to use on the template when parsing a formatted reference.- Parameters:
matchingMode- The matching mode to use.
-
setMatchingQuery
public void setMatchingQuery(boolean matchingQuery) Sets whether the matching should be done on the URI with or without query string.- Parameters:
matchingQuery- True if the matching should be done with the query string, false otherwise.
-
setTemplate
Sets the reference template to match.- Parameters:
template- The reference template to match.
-
toString
-