Package ninja
Class RouteParameter
- java.lang.Object
-
- ninja.RouteParameter
-
public class RouteParameter extends Object
Parameter in a Route.- Author:
- Joe Lauer
-
-
Constructor Summary
Constructors Constructor Description RouteParameter(int index, String token, String name, String regex)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getIndex()
Gets the index of where the token starts in the original uri.String
getName()
The name of the parameter such as "id" in "{id: [0-9]+}"String
getRegex()
The regex of the parameter such as "[0-9]+" in "{id: [0-9]+}"String
getToken()
The exact string of the parameter such as "{id: [0-9]+}" in "{id: [0-9]+}"static Map<String,RouteParameter>
parse(String path)
Parse a path such as "/user/{id: [0-9]+}/email/{addr}" for the named parameters.
-
-
-
Method Detail
-
getIndex
public int getIndex()
Gets the index of where the token starts in the original uri.- Returns:
- An index of where the token is
-
getToken
public String getToken()
The exact string of the parameter such as "{id: [0-9]+}" in "{id: [0-9]+}"- Returns:
- The parameter token
-
getName
public String getName()
The name of the parameter such as "id" in "{id: [0-9]+}"- Returns:
- The name of the parameter
-
getRegex
public String getRegex()
The regex of the parameter such as "[0-9]+" in "{id: [0-9]+}"- Returns:
- The regex of the parameter or null if no regex was included for the parameter.
-
parse
public static Map<String,RouteParameter> parse(String path)
Parse a path such as "/user/{id: [0-9]+}/email/{addr}" for the named parameters.- Parameters:
path
- The path to parse- Returns:
- A map containing the named parameters in the order they were parsed or null if no parameters were parsed.
-
-