public class Expression extends UriTemplateComponent
An Expression represents the text between '{' and '}', including the enclosing braces, as defined in Section 2 of RFC6570.
http://www.example.com/foo{?query,number}
\___________/
^
|
|
The expression
This class models this representation and adds helper functions for replacement and reverse matching.
| Modifier and Type | Class and Description |
|---|---|
static class |
Expression.Builder
Builder class for creating an
Expression. |
| Constructor and Description |
|---|
Expression(Operator op,
List<VarSpec> varSpecs)
Create a new Expression
|
Expression(String rawExpression,
int startPosition)
Create a new Expression.
|
| Modifier and Type | Method and Description |
|---|---|
static Expression.Builder |
continuation(VarSpec... varSpec)
Creates a new
Expression.Builder to create an expression using form-style query continuation expansion
according to section 3.2.9. |
boolean |
equals(Object obj) |
static Expression.Builder |
fragment(VarSpec... varSpec)
Creates a new
Expression.Builder to create an expression with a fragment operator
according to section 3.2.4. |
Pattern |
getMatchPattern()
Returns a string that contains a regular expression that matches the
URI template expression.
|
Operator |
getOperator()
Get the
Operator value for this expression. |
String |
getReplacementPattern()
Get the replacementToken.
|
String |
getValue()
Returns the value of this component
|
List<VarSpec> |
getVarSpecs()
Get the varSpecs.
|
int |
hashCode() |
static Expression.Builder |
label(VarSpec... varSpec)
Creates a new
Expression.Builder to create an expression using label expansion
according to section 3.2.5. |
static Expression.Builder |
matrix(VarSpec... varSpec)
Creates a new
Expression.Builder to create an expression using path-style parameter
(a.k.a. |
static Expression.Builder |
path(VarSpec... varSpec)
Creates a new
Expression.Builder to create an expression using path expansion
according to section 3.2.6. |
static Expression.Builder |
query(VarSpec... varSpec)
Creates a new
Expression.Builder to create an expression using form-style query string expansion
according to section 3.2.8. |
static Expression.Builder |
reserved(VarSpec... varSpec)
Creates a new
Expression.Builder to create an expression that will use reserved expansion
according to section 3.2.3. |
static Expression.Builder |
simple(VarSpec... varSpec)
Creates a new
Expression.Builder to create a simple expression according
to section 3.2.2. |
String |
toString()
Returns the string representation of the expression.
|
getEndPosition, getStartPositionpublic Expression(String rawExpression, int startPosition) throws MalformedUriTemplateException
rawExpression - startPosition - MalformedUriTemplateExceptionpublic Expression(Operator op, List<VarSpec> varSpecs)
op - varSpecs - MalformedUriTemplateExceptionpublic static Expression.Builder simple(VarSpec... varSpec)
Expression.Builder to create a simple expression according
to section 3.2.2.
Calling:
String exp = Expression.simple(var("var")).build().toString();
Will return the following expression:
{var}
public static Expression.Builder reserved(VarSpec... varSpec)
Expression.Builder to create an expression that will use reserved expansion
according to section 3.2.3.
Calling:
String exp = Expression.reserved().var("var").build().toString();
Will return the following expression:
{+var}
public static Expression.Builder fragment(VarSpec... varSpec)
Expression.Builder to create an expression with a fragment operator
according to section 3.2.4.
Calling:
String exp = Expression.fragment().var("var").build().toString();
Will return the following expression:
{#var}
public static Expression.Builder label(VarSpec... varSpec)
Expression.Builder to create an expression using label expansion
according to section 3.2.5.
Calling:
String exp = Expression.label(var("var")).build().toString();
Will return the following expression:
{.var}
public static Expression.Builder path(VarSpec... varSpec)
Expression.Builder to create an expression using path expansion
according to section 3.2.6.
Calling:
String exp = Expression.path().var("var").build().toString();
Will return the following expression:
{/var}
public static Expression.Builder matrix(VarSpec... varSpec)
Expression.Builder to create an expression using path-style parameter
(a.k.a. matrix parameter) expansion according to
section 3.2.7.
Calling:
String exp = Expression.matrix().var("var").build().toString();
Will return the following expression:
{;var}
public static Expression.Builder query(VarSpec... varSpec)
Expression.Builder to create an expression using form-style query string expansion
according to section 3.2.8.
Calling:
String exp = Expression.query().var("var").build().toString();
Will return the following expression:
{?var}
public static Expression.Builder continuation(VarSpec... varSpec)
Expression.Builder to create an expression using form-style query continuation expansion
according to section 3.2.9.
Calling:
String exp = Expression.continuation().var("var").build().toString();
Will return the following expression:
{&var}
public Pattern getMatchPattern()
getMatchPattern in class UriTemplateComponentpublic String getReplacementPattern()
public Operator getOperator()
Operator value for this expression.public String toString()
toString in class ObjectObject.toString()public String getValue()
getValue in class UriTemplateComponentCopyright © 2012-04-30–2016 Ryan J. McDonough. All rights reserved.