Package com.authlete.http
Class QuotedString
java.lang.Object
com.authlete.http.QuotedString
- All Implemented Interfaces:
Serializable
This class represents the quoted string as defined in RFC 9110:
HTTP Semantics, Section 5.6.4. Quoted Strings.
Definition
quoted-string = DQUOTE *( qdtext / quoted-pair ) DQUOTE qdtext = HTAB / SP / %x21 / %x23-5B / %x5D-7E / obs-text quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text )
Sample Code 1
// Parse the string as a quoted string. Note that a quoted // string must be enclosed with double quotes. QuotedString qs = QuotedString.parse("\"qs\""); // The string returned from the getValue() method is not // enclosed with double quotes. assertEquals("qs", qs.getValue()); // The string returned from the toString() method is // enclosed with double quotes. assertEquals("\"qs\"", qs.toString());
Sample Code 2
// Parse a quoted string without content. QuotedString qs = QuotedString.parse("\"\""); // The getValue() method returns an empty string. assertEquals("", qs.getValue()); // The toString() method returns a string containing // two double quotes. assertEquals("\"\"", qs.toString());
Sample Code 3
// !\!\"\\ String escaped = "!\\!\\\"\\\\"; // !!"\ String unescaped = "!!\"\\"; // "!\!\"\\" String input = new StringBuilder() .append('"').append(escaped).append('"').toString(); // Parse QuotedString qs = QuotedString.parse(input); // (Escaped) value assertEquals(escaped, qs.getValue()); // Unescaped value assertEquals(unescaped, qs.getUnescapedValue());
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionThe default constructor.QuotedString(String value) A constructor with the content of this quoted string. -
Method Summary
Modifier and TypeMethodDescriptionbooleanGet the content of this quoted string with quoted pairs unescaped.getValue()Get the content of this quoted string.inthashCode()static QuotedStringParse the input string as a quoted string.Set the content of this quoted string.toString()
-
Constructor Details
-
QuotedString
public QuotedString()The default constructor. -
QuotedString
A constructor with the content of this quoted string.- Parameters:
value- The content of this quoted string.
-
-
Method Details
-
getValue
Get the content of this quoted string.- Returns:
- The content of this quoted string.
-
setValue
Set the content of this quoted string.- Parameters:
value- The content of this quoted string.- Returns:
thisobject.
-
getUnescapedValue
Get the content of this quoted string with quoted pairs unescaped. See the JavaDoc of thisQuotedStringclass for the behavior of this method.- Returns:
- The content of this quoted string with quoted pairs unescaped.
-
equals
-
hashCode
-
toString
-
parse
Parse the input string as a quoted string.- Parameters:
input- A string to be parsed as a quoted string.- Returns:
- The parsed quoted string.
- Throws:
ParseCancellationException- The input string could not be parsed successfully.
-