org.restlet.util
Class RouteList

java.lang.Object
  extended by org.restlet.util.WrapperList<Route>
      extended by org.restlet.util.RouteList
All Implemented Interfaces:
java.lang.Iterable<Route>, java.util.Collection<Route>, java.util.List<Route>

public final class RouteList
extends WrapperList<Route>

Modifiable list of routes with some helper methods. Note that this class implements the java.util.List interface using the Route class as the generic type. This allows you to use an instance of this class as any other java.util.List, in particular all the helper methods in java.util.Collections.

Note that structural changes to this list are thread-safe, using an underlying CopyOnWriteArrayList.

Author:
Jerome Louvel
See Also:
Collections, List

Constructor Summary
RouteList()
          Constructor.
RouteList(java.util.List<Route> delegate)
          Constructor.
 
Method Summary
 Route getBest(Request request, Response response, float requiredScore)
          Returns the best route match for a given call.
 Route getFirst(Request request, Response response, float requiredScore)
          Returns the first route match for a given call.
 Route getLast(Request request, Response response, float requiredScore)
          Returns the last route match for a given call.
 Route getNext(Request request, Response response, float requiredScore)
          Returns a next route match in a round robin mode for a given call.
 Route getRandom(Request request, Response response, float requiredScore)
          Returns a random route match for a given call.
 void removeAll(Restlet target)
          Removes all routes routing to a given target.
 RouteList subList(int fromIndex, int toIndex)
          Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.
 
Methods inherited from class org.restlet.util.WrapperList
add, add, addAll, addAll, clear, contains, containsAll, equals, get, getDelegate, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, size, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RouteList

public RouteList()
Constructor.


RouteList

public RouteList(java.util.List<Route> delegate)
Constructor.

Parameters:
delegate - The delegate list.
Method Detail

getBest

public Route getBest(Request request,
                     Response response,
                     float requiredScore)
Returns the best route match for a given call.

Parameters:
request - The request to score.
response - The response to score.
requiredScore - The minimum score required to have a match.
Returns:
The best route match or null.

getFirst

public Route getFirst(Request request,
                      Response response,
                      float requiredScore)
Returns the first route match for a given call.

Parameters:
request - The request to score.
response - The response to score.
requiredScore - The minimum score required to have a match.
Returns:
The first route match or null.

getLast

public Route getLast(Request request,
                     Response response,
                     float requiredScore)
Returns the last route match for a given call.

Parameters:
request - The request to score.
response - The response to score.
requiredScore - The minimum score required to have a match.
Returns:
The last route match or null.

getNext

public Route getNext(Request request,
                     Response response,
                     float requiredScore)
Returns a next route match in a round robin mode for a given call.

Parameters:
request - The request to score.
response - The response to score.
requiredScore - The minimum score required to have a match.
Returns:
A next route or null.

getRandom

public Route getRandom(Request request,
                       Response response,
                       float requiredScore)
Returns a random route match for a given call.

Parameters:
request - The request to score.
response - The response to score.
requiredScore - The minimum score required to have a match.
Returns:
A random route or null.

removeAll

public void removeAll(Restlet target)
Removes all routes routing to a given target.

Parameters:
target - The target Restlet to detach.

subList

public RouteList subList(int fromIndex,
                         int toIndex)
Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.

Specified by:
subList in interface java.util.List<Route>
Overrides:
subList in class WrapperList<Route>
Parameters:
fromIndex - The start position.
toIndex - The end position (exclusive).
Returns:
The sub-list.


Copyright © 2005-2008 Noelios Technologies.