Uri.Builder  |  API reference  |  Android Developers


public static final class Uri.Builder
extends Object



Helper class for building or manipulating URI references. Not safe for concurrent use.

An absolute hierarchical URI reference follows the pattern: <scheme>://<authority><absolute path>?<query>#<fragment>

Relative URI references (which are always hierarchical) follow one of two patterns: <relative or absolute path>?<query>#<fragment> or //<authority><absolute path>?<query>#<fragment>

An opaque URI follows this pattern: <scheme>:<opaque part>#<fragment>

Use Uri.buildUpon() to obtain a builder representing an existing URI.

Summary

Public constructors

Builder()

Constructs a new Builder.

Public methods

Uri.Builder appendEncodedPath(String newSegment)

Appends the given segment to the path.

Uri.Builder appendPath(String newSegment)

Encodes the given segment and appends it to the path.

Uri.Builder appendQueryParameter(String key, String value)

Encodes the key and value and then appends the parameter to the query string.

Uri.Builder authority(String authority)

Encodes and sets the authority.

Uri build()

Constructs a Uri with the current attributes.

Uri.Builder clearQuery()

Clears the the previously set query.

Uri.Builder encodedAuthority(String authority)

Sets the previously encoded authority.

Uri.Builder encodedFragment(String fragment)

Sets the previously encoded fragment.

Uri.Builder encodedOpaquePart(String opaquePart)

Sets the previously encoded opaque scheme-specific-part.

Uri.Builder encodedPath(String path)

Sets the previously encoded path.

Uri.Builder encodedQuery(String query)

Sets the previously encoded query.

Uri.Builder fragment(String fragment)

Encodes and sets the fragment.

Uri.Builder opaquePart(String opaquePart)

Encodes and sets the given opaque scheme-specific-part.

Uri.Builder path(String path)

Sets the path.

Uri.Builder query(String query)

Encodes and sets the query.

Uri.Builder scheme(String scheme)

Sets the scheme.

String toString()

Returns a string representation of the object.

Inherited methods

From class java.lang.Object

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

Indicates whether some other object is "equal to" this one.

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class<?> getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

Wakes up a single thread that is waiting on this object's monitor.

final void notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String toString()

Returns a string representation of the object.

final void wait(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 wait(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 wait()

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

Public constructors

Builder

public Builder ()

Constructs a new Builder.

Public methods

appendEncodedPath

public Uri.Builder appendEncodedPath (String newSegment)

Appends the given segment to the path.

Parameters
newSegment String
Returns
Uri.Builder

appendPath

public Uri.Builder appendPath (String newSegment)

Encodes the given segment and appends it to the path.

Parameters
newSegment String
Returns
Uri.Builder

appendQueryParameter

public Uri.Builder appendQueryParameter (String key, 
                String value)

Encodes the key and value and then appends the parameter to the query string.

Parameters
key String: which will be encoded
value String: which will be encoded
Returns
Uri.Builder

encodedAuthority

public Uri.Builder encodedAuthority (String authority)

Sets the previously encoded authority.

Parameters
authority String
Returns
Uri.Builder

encodedFragment

public Uri.Builder encodedFragment (String fragment)

Sets the previously encoded fragment.

Parameters
fragment String
Returns
Uri.Builder

encodedOpaquePart

public Uri.Builder encodedOpaquePart (String opaquePart)

Sets the previously encoded opaque scheme-specific-part.

Parameters
opaquePart String: encoded opaque part
Returns
Uri.Builder

encodedPath

public Uri.Builder encodedPath (String path)

Sets the previously encoded path.

If the path is not null and doesn't start with a '/', and if you specify a scheme and/or authority, the builder will prepend the given path with a '/'.

Parameters
path String
Returns
Uri.Builder

opaquePart

public Uri.Builder opaquePart (String opaquePart)

Encodes and sets the given opaque scheme-specific-part.

Parameters
opaquePart String: decoded opaque part
Returns
Uri.Builder

path

public Uri.Builder path (String path)

Sets the path. Leaves '/' characters intact but encodes others as necessary.

If the path is not null and doesn't start with a '/', and if you specify a scheme and/or authority, the builder will prepend the given path with a '/'.

Parameters
path String
Returns
Uri.Builder

scheme

public Uri.Builder scheme (String scheme)

Sets the scheme.

Parameters
scheme String: name or null if this is a relative Uri
Returns
Uri.Builder

toString

public String toString ()

Returns a string representation of the object.

Returns
String a string representation of the object.