Class URL

  • All Implemented Interfaces:

    public final class URL
    extends Object
    implements android.os.Parcelable
    Abstraction of URL. Unifies management of both absolutes and relatives URLs.
    • Field Detail

      • EMPTY

        public static final URL EMPTY
      • CREATOR

        public static final android.os.Parcelable.Creator<URL> CREATOR
    • Constructor Detail

      • URL

        public URL​(@NonNull
                   String value)
        Create a URL object with an absolute or relative URL. If value starts with '/' is considered relative, and will take URLs.SERVER as host with port.
        value - String
    • Method Detail

      • getValue

        public String getValue()
        Original value provided to de constructor
        constructor's value param
      • getLastTerm

        public String getLastTerm()
        Returns las part of provided value, separated by '/'. Useful if the URL represents de location of a file, to obtain its name.
        string, empty if path is empty
      • isAbsolute

        public boolean isAbsolute()
        Return true if the value used to construct the URL doesn't start by '/', meaning it has a specific host. False if isRelative()
        true | false
      • isRelative

        public boolean isRelative()
        Return true if the value used to construct the URL starts by '/', meaning it has no specific host nor port. False if isAbsolute()
        true | false
      • port

        public int port()
                 throws MalformedURLException
        Gets the port number of this URL. If the port is not set, returns the port number of the protocol associated with this URL. If URL has no default port to this protocol, then -1 is returned.
        the port number
        MalformedURLException - exception thrown by URL when created
      • hashCode

        public int hashCode()
        hashCode in class Object
      • describeContents

        public int describeContents()
        Specified by:
        describeContents in interface android.os.Parcelable
      • writeToParcel

        public void writeToParcel​(android.os.Parcel dest,
                                  int flags)
        Specified by:
        writeToParcel in interface android.os.Parcelable