Package com.authlete.http
Class ForwardedPair
java.lang.Object
com.authlete.http.ForwardedPair
- All Implemented Interfaces:
Serializable
This class represents the forwarded pair as defined in RFC 7239:
Forwarded HTTP Extension, Section 4. Forwarded HTTP Header Field.
Definition
Forwarded = 1#forwarded-element
forwarded-element =
[ forwarded-pair ] *( ";" [ forwarded-pair ] )
forwarded-pair = token "=" value
value = token / quoted-string
token = <Defined in [RFC7230], Section 3.2.6>
quoted-string = <Defined in [RFC7230], Section 3.2.6>
Sample Code 1
// Parse the string as a forwarded pair. ForwardedPair pair = ForwardedPair.parse("name=value"); assertNotNull(pair); // The name of the forwarded pair. Token name = pair.getName(); assertNotNull(name); assertEquals("name", name.getValue()); // The value of the forwarded pair. Object value = pair.getValue(); assertNotNull(value); assertEquals(Token.class, value.getClass()); assertEquals("value", ((Token)value).getValue());
Sample Code 2
// Parse the string as a forwarded pair. ForwardedPair pair = ForwardedPair.parse("name=\"value\""); assertNotNull(pair); // The name of the forwarded pair. Token name = pair.getName(); assertNotNull(name); assertEquals("name", name.getValue()); // The value of the forwarded pair. Note that this time // the getValue() method returns a QuotedString instance. Object value = pair.getValue(); assertNotNull(value); assertEquals(QuotedString.class, value.getClass()); assertEquals("value", ((QuotedString)value).getValue());
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionThe default constructor.ForwardedPair(Token name, Object value) A constructor with the name and value of this forwarded pair. -
Method Summary
Modifier and TypeMethodDescriptionbooleangetName()Get the name of this forwarded pair.getValue()Get the value of this forwarded pair.inthashCode()static ForwardedPairParse the input string as a forwarded pair.Set the name of this forwarded pair.Set the value of this forwarded pair.toString()
-
Constructor Details
-
ForwardedPair
public ForwardedPair()The default constructor. -
ForwardedPair
A constructor with the name and value of this forwarded pair.- Parameters:
name- The name of this forwarded pair.value- The value of this forwarded pair.- Throws:
IllegalArgumentException- Thevalueis not an instance of eitherTokenorQuotedString, or null.
-
-
Method Details
-
getName
Get the name of this forwarded pair.- Returns:
- The name of this forwarded pair.
-
setName
Set the name of this forwarded pair.- Parameters:
name- The name of this forwarded pair.- Returns:
thisobject.
-
getValue
Get the value of this forwarded pair.- Returns:
- The value of this forwarded pair.
-
setValue
Set the value of this forwarded pair.- Parameters:
value- The value of this forwarded pair.- Returns:
thisobject.- Throws:
IllegalArgumentException- Thevalueis not an instance of eitherTokenorQuotedString, or null.
-
equals
-
hashCode
-
toString
-
parse
Parse the input string as a forwarded pair.- Parameters:
input- A string to be parsed as a forwarded pair.- Returns:
- The parsed forwarded pair.
- Throws:
ParseCancellationException- The input string could not be parsed successfully.
-