Java net uri to android net uri
Aside from some minor deviations noted below, an instance of this class represents a URI reference as defined by RFC 2396: Uniform Resource Identifiers (URI): Generic Syntax, amended by RFC 2732: Format for Literal IPv6 Addresses in URLs. The Literal IPv6 address format also supports scope_ids. The syntax and usage of scope_ids is described here. This class provides constructors for creating URI instances from their components or by parsing their string forms, methods for accessing the various components of an instance, and methods for normalizing, resolving, and relativizing URI instances. Instances of this class are immutable.
URI syntax and components
An absolute URI specifies a scheme; a URI that is not absolute is said to be relative. URIs are also classified according to whether they are opaque or hierarchical.
An opaque URI is an absolute URI whose scheme-specific part does not begin with a slash character ( ‘/’ ). Opaque URIs are not subject to further parsing. Some examples of opaque URIs are:
mailto:java-net@java.sun.com news:comp.lang.java urn:isbn:096139210x
A hierarchical URI is either an absolute URI whose scheme-specific part begins with a slash character, or a relative URI, that is, a URI that does not specify a scheme. Some examples of hierarchical URIs are:
http://java.sun.com/j2se/1.3/
docs/guide/collections/designfaq.html#28
../../../demo/jfc/SwingSet2/src/SwingSet2.java
file:///
A hierarchical URI is subject to further parsing according to the syntax
The authority component of a hierarchical URI is, if specified, either server-based or registry-based. A server-based authority parses according to the familiar syntax
The path component of a hierarchical URI is itself said to be absolute if it begins with a slash character ( ‘/’ ); otherwise it is relative. The path of a hierarchical URI that is either absolute or specifies an authority is always absolute.
All told, then, a URI instance has the following nine components:
Component Type scheme String scheme-specific-part String authority String user-info String host String port int path String query String fragment String
Whether a particular component is or is not defined in an instance depends upon the type of the URI being represented. An absolute URI has a scheme component. An opaque URI has a scheme, a scheme-specific part, and possibly a fragment, but has no other components. A hierarchical URI always has a path (though it may be empty) and a scheme-specific-part (which at least contains the path), and may have any of the other components. If the authority component is present and is server-based then the host component will be defined and the user-information and port components may be defined.
Operations on URI instances
Normalization is the process of removing unnecessary «.» and «..» segments from the path component of a hierarchical URI. Each «.» segment is simply removed. A «..» segment is removed only if it is preceded by a non- «..» segment. Normalization has no effect upon opaque URIs.
Resolution is the process of resolving one URI against another, base URI. The resulting URI is constructed from components of both URIs in the manner specified by RFC 2396, taking components from the base URI for those not specified in the original. For hierarchical URIs, the path of the original is resolved against the path of the base and then normalized. The result, for example, of resolving
calendar against any other URI simply yields the original URI, since it is absolute. Resolving the relative URI (2) above against the relative base URI (1) yields the normalized, but still relative, URI
Relativization, finally, is the inverse of resolution: For any two normalized URIs u and v,
Character categories
alpha The US-ASCII alphabetic characters, ‘A’ through ‘Z’ and ‘a’ through ‘z’ digit The US-ASCII decimal digit characters, ‘0’ through ‘9’ alphanum All alpha and digit characters unreserved All alphanum characters together with those in the string «_-!. ‘()*»
punct The characters in the string «,;:$&+=» reserved All punct characters together with those in the string «?/[]@» escaped Escaped octets, that is, triplets consisting of the percent character ( ‘%’ ) followed by two hexadecimal digits ( ‘0’ — ‘9’ , ‘A’ — ‘F’ , and ‘a’ — ‘f’ ) other The Unicode characters that are not in the US-ASCII character set, are not control characters (according to the Character.isISOControl method), and are not space characters (according to the Character.isSpaceChar method) (Deviation from RFC 2396, which is limited to US-ASCII)
The set of all legal URI characters consists of the unreserved, reserved, escaped, and other characters.
Escaped octets, quotation, encoding, and decoding
To encode non-US-ASCII characters when a URI is required to conform strictly to RFC 2396 by not containing any other characters.
To quote characters that are otherwise illegal in a component. The user-info, path, query, and fragment components differ slightly in terms of which characters are considered legal and illegal.
A character is encoded by replacing it with the sequence of escaped octets that represent that character in the UTF-8 character set. The Euro currency symbol ( ‘\u20AC’ ), for example, is encoded as «%E2%82%AC» . (Deviation from RFC 2396, which does not specify any particular character set.)
An illegal character is quoted simply by encoding it. The space character, for example, is quoted by replacing it with «%20» . UTF-8 contains US-ASCII, hence for US-ASCII characters this transformation has exactly the effect required by RFC 2396.
A sequence of escaped octets is decoded by replacing it with the sequence of characters that it represents in the UTF-8 character set. UTF-8 contains US-ASCII, hence decoding has the effect of de-quoting any quoted US-ASCII characters as well as that of decoding any encoded non-US-ASCII characters. If a decoding error occurs when decoding the escaped octets then the erroneous octets are replaced by ‘\uFFFD’ , the Unicode replacement character.
The single-argument constructor requires any illegal characters in its argument to be quoted and preserves any escaped octets and other characters that are present.
The multi-argument constructors quote illegal characters as required by the components in which they appear. The percent character ( ‘%’ ) is always quoted by these constructors. Any other characters are preserved.
The getRawUserInfo , getRawPath , getRawQuery , getRawFragment , getRawAuthority , and getRawSchemeSpecificPart methods return the values of their corresponding components in raw form, without interpreting any escaped octets. The strings returned by these methods may contain both escaped octets and other characters, and will not contain any illegal characters.
The getUserInfo , getPath , getQuery , getFragment , getAuthority , and getSchemeSpecificPart methods decode any escaped octets in their corresponding components. The strings returned by these methods may contain both other characters and illegal characters, and will not contain any escaped octets.
The toString method returns a URI string with all necessary quotation but which may contain other characters.
The toASCIIString method returns a fully quoted and encoded URI string that does not contain any other characters.
Identities
URIs, URLs, and URNs
The conceptual distinction between URIs and URLs is reflected in the differences between this class and the URL class.
An instance of this class represents a URI reference in the syntactic sense defined by RFC 2396. A URI may be either absolute or relative. A URI string is parsed according to the generic syntax without regard to the scheme, if any, that it specifies. No lookup of the host, if any, is performed, and no scheme-dependent stream handler is constructed. Equality, hashing, and comparison are defined strictly in terms of the character content of the instance. In other words, a URI instance is little more than a structured string that supports the syntactic, scheme-independent operations of comparison, normalization, resolution, and relativization.
An instance of the URL class, by contrast, represents the syntactic components of a URL together with some of the information required to access the resource that it describes. A URL must be absolute, that is, it must always specify a scheme. A URL string is parsed according to its scheme. A stream handler is always established for a URL, and in fact it is impossible to create a URL instance for a scheme for which no handler is available. Equality and hashing depend upon both the scheme and the Internet address of the host, if any; comparison is not defined. In other words, a URL is a structured string that supports the syntactic operation of resolution as well as the network I/O operations of looking up the host and opening a connection to the specified resource.
Источник
Uri Class
Definition
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Immutable URI reference.
Remarks
Portions of this page are modifications based on work created andВ shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.
Constructors
A constructor used when creating managed representations of JNI objects; called by the runtime.
Properties
Gets the decoded authority part of this URI.
Returns the runtime class of this Object .
(Inherited from Object)
Reads Uris from Parcels.
The empty URI, equivalent to «».
Gets the encoded authority part of this URI.
Gets the encoded fragment part of this URI, everything after the ‘#’.
Gets the encoded path.
Gets the encoded query component from this URI.
Gets the scheme-specific part of this URI, i.e.В everything between the scheme separator ‘:’ and the fragment separator ‘#’.
Gets the encoded user information from the authority.
Gets the decoded fragment part of this URI, everything after the ‘#’.
The handle to the underlying Android instance.
(Inherited from Object)
Gets the encoded host from the authority for this URI.
Returns true if this URI is absolute, i.
Returns true if this URI is hierarchical like «http://google.com».
Returns true if this URI is opaque like «mailto:nobody
Returns true if this URI is relative, i.e.В if it doesn’t contain an explicit scheme.
Gets the decoded last segment in the path.
Gets the decoded path.
Gets the decoded path segments.
Gets the port from the authority for this URI.
Gets the decoded query component from this URI.
Returns a set of the unique names of all query parameters.
Gets the scheme of this URI.
Gets the scheme-specific part of this URI, i.e.В everything between the scheme separator ‘:’ and the fragment separator ‘#’.
This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
Gets the decoded user information from the authority.
Methods
Constructs a new builder, copying the attributes from this Uri.
Creates and returns a copy of this object.
(Inherited from Object)
Compares the string representation of this Uri with that of another.
Decodes ‘%’-escaped octets in the given string using the UTF-8 scheme.
Describe the kinds of special objects contained in this Parcelable instance’s marshaled representation.
Encodes characters in the given string as ‘%’-escaped octets using the UTF-8 scheme.
Encodes characters in the given string as ‘%’-escaped octets using the UTF-8 scheme.
Indicates whether some other object is «equal to» this one.
(Inherited from Object)
Creates a Uri from a file.
Creates an opaque Uri from the given components.
Searches the query string for the first value with the given key and interprets it as a boolean value.
Returns a hash code value for the object.
(Inherited from Object)
Searches the query string for the first value with the given key.
Searches the query string for parameter values with the given key.
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
(Inherited from Object)
Return an equivalent URI with a lowercase scheme component.
Wakes up a single thread that is waiting on this object’s monitor.
(Inherited from Object)
Wakes up all threads that are waiting on this object’s monitor.
(Inherited from Object)
Creates a Uri which parses the given encoded URI string.
Sets the Handle property.
(Inherited from Object)
Returns the encoded string representation of this URI.
Causes the current thread to wait until another thread invokes the java.lang.Object#notify() method or the java.lang.Object#notifyAll() method for this object.
(Inherited from Object)
Causes the current thread to wait until another thread invokes the java.lang.Object#notify() method or the java.lang.Object#notifyAll() method for this object.
(Inherited from Object)
Causes the current thread to wait until another thread invokes the java.lang.Object#notify() method or the java.lang.Object#notifyAll() method for this object.
(Inherited from Object)
Creates a new Uri by appending an already-encoded path segment to a base Uri.
Flatten this object in to a Parcel.
Writes a Uri to a Parcel.
Explicit Interface Implementations
IComparable.CompareTo(Object) | |
IJavaPeerable.Disposed() | (Inherited from Object) |
IJavaPeerable.DisposeUnlessReferenced() | (Inherited from Object) |
IJavaPeerable.Finalized() | (Inherited from Object) |
IJavaPeerable.JniManagedPeerState | (Inherited from Object) |
IJavaPeerable.SetJniIdentityHashCode(Int32) | (Inherited from Object) |
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) | (Inherited from Object) |
IJavaPeerable.SetPeerReference(JniObjectReference) | (Inherited from Object) |
Extension Methods
Performs an Android runtime-checked type conversion.
Источник