Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Nested Classes](https://developer.android.com/reference/android/net/UrlQuerySanitizer#nestedclasses) \| [Ctors](https://developer.android.com/reference/android/net/UrlQuerySanitizer#pubctors) \| [Methods](https://developer.android.com/reference/android/net/UrlQuerySanitizer#pubmethods) \| [Protected Methods](https://developer.android.com/reference/android/net/UrlQuerySanitizer#promethods) \| [Inherited Methods](https://developer.android.com/reference/android/net/UrlQuerySanitizer#inhmethods)

# UrlQuerySanitizer

*** ** * ** ***


`
public


class
UrlQuerySanitizer
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.net.UrlQuerySanitizer |

<br />

*** ** * ** ***

Sanitizes the Query portion of a URL. Simple example:

```
UrlQuerySanitizer sanitizer = new UrlQuerySanitizer();
sanitizer.setAllowUnregisteredParamaters(true);
sanitizer.parseUrl("http://example.com/?name=Joe+User");
String name = sanitizer.getValue("name"));
// name now contains "Joe_User"
```
Register ValueSanitizers to customize the way individual parameters are sanitized:

```
UrlQuerySanitizer sanitizer = new UrlQuerySanitizer();
sanitizer.registerParamater("name", UrlQuerySanitizer.createSpaceLegal());
sanitizer.parseUrl("http://example.com/?name=Joe+User");
String name = sanitizer.getValue("name"));
// name now contains "Joe User". (The string is first decoded, which
// converts the '+' to a ' '. Then the string is sanitized, which
// converts the ' ' to an '_'. (The ' ' is converted because the default
unregistered parameter sanitizer does not allow any special characters,
and ' ' is a special character.)
```


There are several ways to create ValueSanitizers. In order of increasing
sophistication:

1. Call one of the UrlQuerySanitizer.createXXX() methods.
2. Construct your own instance of UrlQuerySanitizer.IllegalCharacterValueSanitizer.
3. Subclass UrlQuerySanitizer.ValueSanitizer to define your own value sanitizer.

<br />

## Summary

| ### Nested classes ||
|---|---|
| ` class` | `https://developer.android.com/reference/android/net/UrlQuerySanitizer.IllegalCharacterValueSanitizer` Sanitize values based on which characters they contain. |
| ` class` | `https://developer.android.com/reference/android/net/UrlQuerySanitizer.ParameterValuePair` A simple tuple that holds parameter-value pairs. |
| ` interface` | `https://developer.android.com/reference/android/net/UrlQuerySanitizer.ValueSanitizer` A functor used to sanitize a single query value. |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/net/UrlQuerySanitizer#UrlQuerySanitizer()() ` Constructs a UrlQuerySanitizer. |
| ` https://developer.android.com/reference/android/net/UrlQuerySanitizer#UrlQuerySanitizer(java.lang.String)(https://developer.android.com/reference/java/lang/String url) ` Constructs a UrlQuerySanitizer and parses a URL. |

| ### Public methods ||
|---|---|
| ` static final https://developer.android.com/reference/android/net/UrlQuerySanitizer.ValueSanitizer` | ` https://developer.android.com/reference/android/net/UrlQuerySanitizer#getAllButNulAndAngleBracketsLegal()() ` Return a value sanitizer that allows any special characters except angle brackets ('\<' and '\>') and Nul ('\\0'). |
| ` static final https://developer.android.com/reference/android/net/UrlQuerySanitizer.ValueSanitizer` | ` https://developer.android.com/reference/android/net/UrlQuerySanitizer#getAllButNulLegal()() ` Return a value sanitizer that allows everything except Nul ('\\0') characters. |
| ` static final https://developer.android.com/reference/android/net/UrlQuerySanitizer.ValueSanitizer` | ` https://developer.android.com/reference/android/net/UrlQuerySanitizer#getAllButWhitespaceLegal()() ` Return a value sanitizer that allows everything except Nul ('\\0') characters, space (' '), and other whitespace characters. |
| ` static final https://developer.android.com/reference/android/net/UrlQuerySanitizer.ValueSanitizer` | ` https://developer.android.com/reference/android/net/UrlQuerySanitizer#getAllIllegal()() ` Return a value sanitizer that does not allow any special characters, and also does not allow script URLs. |
| ` boolean` | ` https://developer.android.com/reference/android/net/UrlQuerySanitizer#getAllowUnregisteredParamaters()() ` Get whether or not unregistered parameters are allowed. |
| ` static final https://developer.android.com/reference/android/net/UrlQuerySanitizer.ValueSanitizer` | ` https://developer.android.com/reference/android/net/UrlQuerySanitizer#getAmpAndSpaceLegal()() ` Return a value sanitizer that does not allow any special characters except ampersand ('\&') and space (' '). |
| ` static final https://developer.android.com/reference/android/net/UrlQuerySanitizer.ValueSanitizer` | ` https://developer.android.com/reference/android/net/UrlQuerySanitizer#getAmpLegal()() ` Return a value sanitizer that does not allow any special characters except ampersand ('\&'). |
| ` https://developer.android.com/reference/android/net/UrlQuerySanitizer.ValueSanitizer` | ` https://developer.android.com/reference/android/net/UrlQuerySanitizer#getEffectiveValueSanitizer(java.lang.String)(https://developer.android.com/reference/java/lang/String parameter) ` Get the effective value sanitizer for a parameter. |
| ` https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/net/UrlQuerySanitizer.ParameterValuePair>` | ` https://developer.android.com/reference/android/net/UrlQuerySanitizer#getParameterList()() ` An array list of all of the parameter-value pairs in the sanitized query, in the order they appeared in the query. |
| ` https://developer.android.com/reference/java/util/Set<https://developer.android.com/reference/java/lang/String>` | ` https://developer.android.com/reference/android/net/UrlQuerySanitizer#getParameterSet()() ` Get a set of all of the parameters found in the sanitized query. |
| ` boolean` | ` https://developer.android.com/reference/android/net/UrlQuerySanitizer#getPreferFirstRepeatedParameter()() ` Get whether or not the first occurrence of a repeated parameter is preferred. |
| ` static final https://developer.android.com/reference/android/net/UrlQuerySanitizer.ValueSanitizer` | ` https://developer.android.com/reference/android/net/UrlQuerySanitizer#getSpaceLegal()() ` Return a value sanitizer that does not allow any special characters except space (' '). |
| ` https://developer.android.com/reference/android/net/UrlQuerySanitizer.ValueSanitizer` | ` https://developer.android.com/reference/android/net/UrlQuerySanitizer#getUnregisteredParameterValueSanitizer()() ` Get the current value sanitizer used when processing unregistered parameter values. |
| ` static final https://developer.android.com/reference/android/net/UrlQuerySanitizer.ValueSanitizer` | ` https://developer.android.com/reference/android/net/UrlQuerySanitizer#getUrlAndSpaceLegal()() ` Return a value sanitizer that allows all the characters used by encoded URLs and allows spaces, which are not technically legal in encoded URLs, but commonly appear anyway. |
| ` static final https://developer.android.com/reference/android/net/UrlQuerySanitizer.ValueSanitizer` | ` https://developer.android.com/reference/android/net/UrlQuerySanitizer#getUrlLegal()() ` Return a value sanitizer that allows all the characters used by encoded URLs. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/UrlQuerySanitizer#getValue(java.lang.String)(https://developer.android.com/reference/java/lang/String parameter) ` Get the value for a parameter in the current sanitized query. |
| ` https://developer.android.com/reference/android/net/UrlQuerySanitizer.ValueSanitizer` | ` https://developer.android.com/reference/android/net/UrlQuerySanitizer#getValueSanitizer(java.lang.String)(https://developer.android.com/reference/java/lang/String parameter) ` Get the value sanitizer for a parameter. |
| ` boolean` | ` https://developer.android.com/reference/android/net/UrlQuerySanitizer#hasParameter(java.lang.String)(https://developer.android.com/reference/java/lang/String parameter) ` Check if a parameter exists in the current sanitized query. |
| ` void` | ` https://developer.android.com/reference/android/net/UrlQuerySanitizer#parseQuery(java.lang.String)(https://developer.android.com/reference/java/lang/String query) ` Parse a query. |
| ` void` | ` https://developer.android.com/reference/android/net/UrlQuerySanitizer#parseUrl(java.lang.String)(https://developer.android.com/reference/java/lang/String url) ` Parse the query parameters out of an encoded URL. |
| ` void` | ` https://developer.android.com/reference/android/net/UrlQuerySanitizer#registerParameter(java.lang.String,%20android.net.UrlQuerySanitizer.ValueSanitizer)(https://developer.android.com/reference/java/lang/String parameter, https://developer.android.com/reference/android/net/UrlQuerySanitizer.ValueSanitizer valueSanitizer) ` Register a value sanitizer for a particular parameter. |
| ` void` | ` https://developer.android.com/reference/android/net/UrlQuerySanitizer#registerParameters(java.lang.String[],%20android.net.UrlQuerySanitizer.ValueSanitizer)(https://developer.android.com/reference/java/lang/String parameters, https://developer.android.com/reference/android/net/UrlQuerySanitizer.ValueSanitizer valueSanitizer) ` Register a value sanitizer for an array of parameters. |
| ` void` | ` https://developer.android.com/reference/android/net/UrlQuerySanitizer#setAllowUnregisteredParamaters(boolean)(boolean allowUnregisteredParamaters) ` Set whether or not unregistered parameters are allowed. |
| ` void` | ` https://developer.android.com/reference/android/net/UrlQuerySanitizer#setPreferFirstRepeatedParameter(boolean)(boolean preferFirstRepeatedParameter) ` Set whether or not the first occurrence of a repeated parameter is preferred. |
| ` void` | ` https://developer.android.com/reference/android/net/UrlQuerySanitizer#setUnregisteredParameterValueSanitizer(android.net.UrlQuerySanitizer.ValueSanitizer)(https://developer.android.com/reference/android/net/UrlQuerySanitizer.ValueSanitizer sanitizer) ` Set the value sanitizer used when processing unregistered parameter values. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/UrlQuerySanitizer#unescape(java.lang.String)(https://developer.android.com/reference/java/lang/String string) ` |

| ### Protected methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/net/UrlQuerySanitizer#addSanitizedEntry(java.lang.String,%20java.lang.String)(https://developer.android.com/reference/java/lang/String parameter, https://developer.android.com/reference/java/lang/String value) ` Record a sanitized parameter-value pair. |
| ` void` | ` https://developer.android.com/reference/android/net/UrlQuerySanitizer#clear()() ` Clear the existing entries. |
| ` int` | ` https://developer.android.com/reference/android/net/UrlQuerySanitizer#decodeHexDigit(char)(char c) ` Convert a character that represents a hexidecimal digit into an integer. |
| ` boolean` | ` https://developer.android.com/reference/android/net/UrlQuerySanitizer#isHexDigit(char)(char c) ` Test if a character is a hexidecimal digit. |
| ` void` | ` https://developer.android.com/reference/android/net/UrlQuerySanitizer#parseEntry(java.lang.String,%20java.lang.String)(https://developer.android.com/reference/java/lang/String parameter, https://developer.android.com/reference/java/lang/String value) ` Parse an escaped parameter-value pair. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Public constructors

### UrlQuerySanitizer

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UrlQuerySanitizer ()
```

Constructs a UrlQuerySanitizer.


Defaults:

- unregistered parameters are not allowed.
- the last instance of a repeated parameter is preferred.
- The default value sanitizer is an AllIllegal value sanitizer.

### UrlQuerySanitizer

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UrlQuerySanitizer (String url)
```

Constructs a UrlQuerySanitizer and parses a URL.
This constructor is provided for convenience when the
default parsing behavior is acceptable.


Because the URL is parsed before the constructor returns, there isn't
a chance to configure the sanitizer to change the parsing behavior.


`
UrlQuerySanitizer sanitizer = new UrlQuerySanitizer(myUrl);
String name = sanitizer.getValue("name");
`


Defaults:

- unregistered parameters *are* allowed.
- the last instance of a repeated parameter is preferred.
- The default value sanitizer is an AllIllegal value sanitizer.

  | Parameters ||
  |---|---|
  | `url` | `String` <br /> |

## Public methods

### getAllButNulAndAngleBracketsLegal

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final UrlQuerySanitizer.ValueSanitizer getAllButNulAndAngleBracketsLegal ()
```

Return a value sanitizer that allows any special characters
except angle brackets ('\<' and '\>') and Nul ('\\0').
Allows script URLs.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/UrlQuerySanitizer.ValueSanitizer` | a value sanitizer <br /> |

### getAllButNulLegal

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final UrlQuerySanitizer.ValueSanitizer getAllButNulLegal ()
```

Return a value sanitizer that allows everything except Nul ('\\0')
characters. Script URLs are allowed.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/UrlQuerySanitizer.ValueSanitizer` | a value sanitizer <br /> |

### getAllButWhitespaceLegal

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final UrlQuerySanitizer.ValueSanitizer getAllButWhitespaceLegal ()
```

Return a value sanitizer that allows everything except Nul ('\\0')
characters, space (' '), and other whitespace characters.
Script URLs are allowed.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/UrlQuerySanitizer.ValueSanitizer` | a value sanitizer <br /> |

### getAllIllegal

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final UrlQuerySanitizer.ValueSanitizer getAllIllegal ()
```

Return a value sanitizer that does not allow any special characters,
and also does not allow script URLs.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/UrlQuerySanitizer.ValueSanitizer` | a value sanitizer <br /> |

### getAllowUnregisteredParamaters

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean getAllowUnregisteredParamaters ()
```

Get whether or not unregistered parameters are allowed. If not
allowed, they will be dropped when a query is parsed.

<br />

| Returns ||
|---|---|
| `boolean` | true if unregistered parameters are allowed. <br /> |

**See also:**

- `https://developer.android.com/reference/android/net/UrlQuerySanitizer#setAllowUnregisteredParamaters(boolean)`

### getAmpAndSpaceLegal

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final UrlQuerySanitizer.ValueSanitizer getAmpAndSpaceLegal ()
```

Return a value sanitizer that does not allow any special characters
except ampersand ('\&') and space (' '). Does not allow script URLs.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/UrlQuerySanitizer.ValueSanitizer` | a value sanitizer <br /> |

### getAmpLegal

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final UrlQuerySanitizer.ValueSanitizer getAmpLegal ()
```

Return a value sanitizer that does not allow any special characters
except ampersand ('\&'). Does not allow script URLs.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/UrlQuerySanitizer.ValueSanitizer` | a value sanitizer <br /> |

### getEffectiveValueSanitizer

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UrlQuerySanitizer.ValueSanitizer getEffectiveValueSanitizer (String parameter)
```

Get the effective value sanitizer for a parameter. Like getValueSanitizer,
except if there is no value sanitizer registered for a parameter, and
unregistered parameters are allowed, then the default value sanitizer is
returned.

<br />

| Parameters ||
|---|---|
| `parameter` | `String`: an unescaped parameter <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/UrlQuerySanitizer.ValueSanitizer` | the effective value sanitizer for a parameter. <br /> |

### getParameterList

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public List<UrlQuerySanitizer.ParameterValuePair> getParameterList ()
```

An array list of all of the parameter-value pairs in the sanitized
query, in the order they appeared in the query. May contain duplicate
parameters.

**Note:** Do not modify this list. Treat it as a read-only list.

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/net/UrlQuerySanitizer.ParameterValuePair>` | <br /> |

### getParameterSet

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Set<String> getParameterSet ()
```

Get a set of all of the parameters found in the sanitized query.


Note: Do not modify this set. Treat it as a read-only set.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/Set<https://developer.android.com/reference/java/lang/String>` | all the parameters found in the current query. <br /> |

### getPreferFirstRepeatedParameter

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean getPreferFirstRepeatedParameter ()
```

Get whether or not the first occurrence of a repeated parameter is
preferred.

<br />

| Returns ||
|---|---|
| `boolean` | true if the first occurrence of a repeated parameter is preferred. <br /> |

**See also:**

- `https://developer.android.com/reference/android/net/UrlQuerySanitizer#setPreferFirstRepeatedParameter(boolean)`

### getSpaceLegal

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final UrlQuerySanitizer.ValueSanitizer getSpaceLegal ()
```

Return a value sanitizer that does not allow any special characters
except space (' '). Does not allow script URLs.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/UrlQuerySanitizer.ValueSanitizer` | a value sanitizer <br /> |

### getUnregisteredParameterValueSanitizer

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UrlQuerySanitizer.ValueSanitizer getUnregisteredParameterValueSanitizer ()
```

Get the current value sanitizer used when processing
unregistered parameter values.


**Note:** The default unregistered parameter value sanitizer is
one that doesn't allow any special characters, similar to what
is returned by calling createAllIllegal.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/UrlQuerySanitizer.ValueSanitizer` | the current ValueSanitizer used to sanitize unregistered parameter values. <br /> |

### getUrlAndSpaceLegal

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final UrlQuerySanitizer.ValueSanitizer getUrlAndSpaceLegal ()
```

Return a value sanitizer that allows all the characters used by
encoded URLs and allows spaces, which are not technically legal
in encoded URLs, but commonly appear anyway.
Does not allow script URLs.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/UrlQuerySanitizer.ValueSanitizer` | a value sanitizer <br /> |

### getUrlLegal

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final UrlQuerySanitizer.ValueSanitizer getUrlLegal ()
```

Return a value sanitizer that allows all the characters used by
encoded URLs. Does not allow script URLs.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/UrlQuerySanitizer.ValueSanitizer` | a value sanitizer <br /> |

### getValue

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String getValue (String parameter)
```

Get the value for a parameter in the current sanitized query.
Returns null if the parameter does not
exit.

<br />

| Parameters ||
|---|---|
| `parameter` | `String`: the unencoded name of a parameter. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the sanitized unencoded value of the parameter, or null if the parameter does not exist. <br /> |

### getValueSanitizer

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public UrlQuerySanitizer.ValueSanitizer getValueSanitizer (String parameter)
```

Get the value sanitizer for a parameter. Returns null if there
is no value sanitizer registered for the parameter.

<br />

| Parameters ||
|---|---|
| `parameter` | `String`: the unescaped parameter <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/UrlQuerySanitizer.ValueSanitizer` | the currently registered value sanitizer for this parameter. <br /> |

**See also:**

- `https://developer.android.com/reference/android/net/UrlQuerySanitizer#registerParameter(java.lang.String,%20android.net.UrlQuerySanitizer.ValueSanitizer)`

### hasParameter

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean hasParameter (String parameter)
```

Check if a parameter exists in the current sanitized query.

<br />

| Parameters ||
|---|---|
| `parameter` | `String`: the unencoded name of a parameter. <br /> |

| Returns ||
|---|---|
| `boolean` | true if the parameter exists in the current sanitized queary. <br /> |

### parseQuery

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void parseQuery (String query)
```

Parse a query. A query string is any number of parameter-value clauses
separated by any non-zero number of ampersands. A parameter-value clause
is a parameter followed by an equal sign, followed by a value. If the
equal sign is missing, the value is assumed to be the empty string.

<br />

| Parameters ||
|---|---|
| `query` | `String`: the query to parse. <br /> |

### parseUrl

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void parseUrl (String url)
```

Parse the query parameters out of an encoded URL.
Works by extracting the query portion from the URL and then
calling parseQuery(). If there is no query portion it is
treated as if the query portion is an empty string.

<br />

| Parameters ||
|---|---|
| `url` | `String`: the encoded URL to parse. <br /> |

### registerParameter

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void registerParameter (String parameter, 
                UrlQuerySanitizer.ValueSanitizer valueSanitizer)
```

Register a value sanitizer for a particular parameter. Can also be used
to replace or remove an already-set value sanitizer.


Registering a non-null value sanitizer for a particular parameter
makes that parameter a registered parameter.

<br />

| Parameters ||
|---|---|
| `parameter` | `String`: an unencoded parameter name <br /> |
| `valueSanitizer` | `UrlQuerySanitizer.ValueSanitizer`: the value sanitizer to use for a particular parameter. May be null in order to unregister that parameter. <br /> |

**See also:**

- `https://developer.android.com/reference/android/net/UrlQuerySanitizer#getAllowUnregisteredParamaters()`

### registerParameters

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void registerParameters (String[] parameters, 
                UrlQuerySanitizer.ValueSanitizer valueSanitizer)
```

Register a value sanitizer for an array of parameters.

<br />

| Parameters ||
|---|---|
| `parameters` | `String`: An array of unencoded parameter names. <br /> |

**See also:**

- `https://developer.android.com/reference/android/net/UrlQuerySanitizer#registerParameter(java.lang.String,%20android.net.UrlQuerySanitizer.ValueSanitizer)`

### setAllowUnregisteredParamaters

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setAllowUnregisteredParamaters (boolean allowUnregisteredParamaters)
```

Set whether or not unregistered parameters are allowed. If they
are not allowed, then they will be dropped when a query is sanitized.


Defaults to false.

<br />

| Parameters ||
|---|---|
| `allowUnregisteredParamaters` | `boolean`: true to allow unregistered parameters. <br /> |

**See also:**

- `https://developer.android.com/reference/android/net/UrlQuerySanitizer#getAllowUnregisteredParamaters()`

### setPreferFirstRepeatedParameter

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setPreferFirstRepeatedParameter (boolean preferFirstRepeatedParameter)
```

Set whether or not the first occurrence of a repeated parameter is
preferred. True means the first repeated parameter is preferred.
False means that the last repeated parameter is preferred.


The preferred parameter is the one that is returned when getParameter
is called.


defaults to false.

<br />

| Parameters ||
|---|---|
| `preferFirstRepeatedParameter` | `boolean`: True if the first repeated parameter is preferred. <br /> |

**See also:**

- `https://developer.android.com/reference/android/net/UrlQuerySanitizer#getPreferFirstRepeatedParameter()`

### setUnregisteredParameterValueSanitizer

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setUnregisteredParameterValueSanitizer (UrlQuerySanitizer.ValueSanitizer sanitizer)
```

Set the value sanitizer used when processing unregistered
parameter values.

<br />

| Parameters ||
|---|---|
| `sanitizer` | `UrlQuerySanitizer.ValueSanitizer`: set the ValueSanitizer used to sanitize unregistered parameter values. <br /> |

### unescape

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String unescape (String string)
```

<br />

<br />

| Parameters ||
|---|---|
| `string` | `String` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | <br /> |

## Protected methods

### addSanitizedEntry

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected void addSanitizedEntry (String parameter, 
                String value)
```

Record a sanitized parameter-value pair. Override if you want to
do additional filtering or validation.

<br />

| Parameters ||
|---|---|
| `parameter` | `String`: an unescaped parameter <br /> |
| `value` | `String`: a sanitized unescaped value <br /> |

### clear

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected void clear ()
```

Clear the existing entries. Called to get ready to parse a new
query string.

<br />

### decodeHexDigit

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected int decodeHexDigit (char c)
```

Convert a character that represents a hexidecimal digit into an integer.
If the character is not a hexidecimal digit, then -1 is returned.
Both upper case and lower case hex digits are allowed.

<br />

| Parameters ||
|---|---|
| `c` | `char`: the hexidecimal digit. <br /> |

| Returns ||
|---|---|
| `int` | the integer value of the hexidecimal digit. <br /> |

### isHexDigit

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected boolean isHexDigit (char c)
```

Test if a character is a hexidecimal digit. Both upper case and lower
case hex digits are allowed.

<br />

| Parameters ||
|---|---|
| `c` | `char`: the character to test <br /> |

| Returns ||
|---|---|
| `boolean` | true if c is a hex digit. <br /> |

### parseEntry

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected void parseEntry (String parameter, 
                String value)
```

Parse an escaped parameter-value pair. The default implementation
unescapes both the parameter and the value, then looks up the
effective value sanitizer for the parameter and uses it to sanitize
the value. If all goes well then addSanitizedValue is called with
the unescaped parameter and the sanitized unescaped value.

<br />

| Parameters ||
|---|---|
| `parameter` | `String`: an escaped parameter <br /> |
| `value` | `String`: an unsanitized escaped value <br /> |