Package org.restlet.routing
Class Extractor
- java.lang.Object
-
- org.restlet.Restlet
-
- org.restlet.routing.Filter
-
- org.restlet.routing.Extractor
-
- All Implemented Interfaces:
Uniform
public class Extractor extends Filter
Filter extracting attributes from a call. Multiple extractions can be defined, based on the query string of the resource reference, on the request form (ex: posted from a browser) or on cookies.
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classExtractor.ExtractInfoInternal class holding extraction information.
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<Extractor.ExtractInfo>cookieExtractsThe list of cookies to extract.private java.util.List<Extractor.ExtractInfo>entityExtractsThe list of request entity parameters to extract.private java.util.List<Extractor.ExtractInfo>queryExtractsThe list of query parameters to extract.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected intbeforeHandle(Request request, Response response)Allows filtering before its handling by the target Restlet.voidextractFromCookie(java.lang.String attribute, java.lang.String cookieName, boolean first)Extracts an attribute from the request cookies.voidextractFromEntity(java.lang.String attribute, java.lang.String parameter, boolean first)Extracts an attribute from the request entity form.voidextractFromQuery(java.lang.String attribute, java.lang.String parameter, boolean first)Extracts an attribute from the query string of the resource reference.private java.util.List<Extractor.ExtractInfo>getCookieExtracts()Returns the list of query extracts.private java.util.List<Extractor.ExtractInfo>getEntityExtracts()Returns the list of query extracts.private java.util.List<Extractor.ExtractInfo>getQueryExtracts()Returns the list of query extracts.-
Methods inherited from class org.restlet.routing.Filter
afterHandle, doHandle, getNext, handle, hasNext, setNext, setNext, start, stop
-
Methods 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
-
-
-
-
Field Detail
-
cookieExtracts
private volatile java.util.List<Extractor.ExtractInfo> cookieExtracts
The list of cookies to extract.
-
entityExtracts
private volatile java.util.List<Extractor.ExtractInfo> entityExtracts
The list of request entity parameters to extract.
-
queryExtracts
private volatile java.util.List<Extractor.ExtractInfo> queryExtracts
The list of query parameters to extract.
-
-
Method Detail
-
beforeHandle
protected int beforeHandle(Request request, Response response)
Allows filtering before its handling by the target Restlet. By default it extracts the attributes from form parameters (query, cookies, entity) and finally puts them in the request's attributes (Message.getAttributes()).- Overrides:
beforeHandlein classFilter- Parameters:
request- The request to filter.response- The response to filter.- Returns:
- The continuation status.
-
extractFromCookie
public void extractFromCookie(java.lang.String attribute, java.lang.String cookieName, boolean first)Extracts an attribute from the request cookies.- Parameters:
attribute- The name of the request attribute to set.cookieName- The name of the cookies to extract.first- Indicates if only the first cookie should be set. Otherwise as a List instance might be set in the attribute value.
-
extractFromEntity
public void extractFromEntity(java.lang.String attribute, java.lang.String parameter, boolean first)Extracts an attribute from the request entity form.- Parameters:
attribute- The name of the request attribute to set.parameter- The name of the entity form parameter to extract.first- Indicates if only the first cookie should be set. Otherwise as a List instance might be set in the attribute value.
-
extractFromQuery
public void extractFromQuery(java.lang.String attribute, java.lang.String parameter, boolean first)Extracts an attribute from the query string of the resource reference.- Parameters:
attribute- The name of the request attribute to set.parameter- The name of the query string parameter to extract.first- Indicates if only the first cookie should be set. Otherwise as a List instance might be set in the attribute value.
-
getCookieExtracts
private java.util.List<Extractor.ExtractInfo> getCookieExtracts()
Returns the list of query extracts.- Returns:
- The list of query extracts.
-
getEntityExtracts
private java.util.List<Extractor.ExtractInfo> getEntityExtracts()
Returns the list of query extracts.- Returns:
- The list of query extracts.
-
getQueryExtracts
private java.util.List<Extractor.ExtractInfo> getQueryExtracts()
Returns the list of query extracts.- Returns:
- The list of query extracts.
-
-