Class CgiQuery
java.lang.Object
uk.ac.starlink.util.CgiQuery
Utility class for constructing CGI query strings.
The name is somewhat out of date or misleading;
the intention is to provide URLs with a query part that can be
interpreted as an application/x-www-form-urlencoded string.
- Since:
- 1 Oct 2004
- Author:
- Mark Taylor (Starlink)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringLegal characters for query part of a URI - see RFC 2396. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddArgument(String name, double value) Adds a floating point argument to this query.addArgument(String name, float value) Adds a single-precision floating point argument to this query.addArgument(String name, long value) Adds an integer argument to this query.addArgument(String name, String value) Adds a string argument to this query.voidallowUnencodedChars(String extraChars) Provides a list of characters that will be passed as parameter or value content through without percent-encoding.booleanstatic StringformatDouble(double value) Formats a double precision value.static StringformatDouble(double value, int nsf, int maxleng) Formats a floating point value.static StringformatFloat(float value) Formats a single precision value.inthashCode()toString()Returns this query as a string.toURL()Returns this query as a URL.
-
Field Details
-
QUERY_CHARS
Legal characters for query part of a URI - see RFC 2396.- See Also:
-
-
Constructor Details
-
CgiQuery
Constructs a CGI query. The submittedbaseargument may optionally be a partially-formed CGI-query, that is, one ending in a '?' and zero or more '&name=value' pairs.- Parameters:
base- base part of the CGI URL- Throws:
IllegalArgumentException- ifbaseis not a legal base URL
-
-
Method Details
-
allowUnencodedChars
Provides a list of characters that will be passed as parameter or value content through without percent-encoding. The default behaviour is quite conservative, but in many cases this can be relaxed without causing trouble.- Parameters:
extraChars- string each of whose characters will not be percent-encoded
-
addArgument
-
addArgument
-
addArgument
-
addArgument
-
toURL
-
equals
-
hashCode
-
toString
-
formatDouble
Formats a double precision value.- Parameters:
value- value- Returns:
- string representation
-
formatFloat
Formats a single precision value.- Parameters:
value- value- Returns:
- string representation
-
formatDouble
Formats a floating point value. It will be done in fixed point format if it can be done within the given number of characters, else exponential notation.- Parameters:
value- valuensf- number of significant figuresmaxleng- maximum length of string - if longer than this, will return to exponential notation- Returns:
- fixed format string representation
-