Package es.situm.sdk.model
Class URL
- java.lang.Object
-
- es.situm.sdk.model.URL
-
- All Implemented Interfaces:
android.os.Parcelable
public final class URL extends Object implements android.os.Parcelable
Abstraction of URL. Unifies management of both absolutes and relatives URLs.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringasStringURL()URLasURL()Returns current URL as aURL.intdescribeContents()booleanequals(Object o)StringgetLastTerm()Returns las part of provided value, separated by '/'.StringgetValue()Original value provided to de constructorinthashCode()Stringhost()Wrap ofasURL()and methodURL.getHost()booleanisAbsolute()Return true if the value used to construct the URL doesn't start by '/', meaning it has a specific host.booleanisRelative()Return true if the value used to construct the URL starts by '/', meaning it has no specific host nor port.Stringpath()intport()Gets the port number of this URL.Stringprotocol()Wrap ofasURL()and methodURL.getProtocol()StringtoString()voidwriteToParcel(android.os.Parcel dest, int flags)
-
-
-
Method Detail
-
getValue
@NonNull public String getValue()
Original value provided to de constructor- Returns:
- constructor's value param
-
getLastTerm
@NonNull 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.- Returns:
- 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 ifisRelative()- Returns:
- 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 ifisAbsolute()- Returns:
- true | false
-
asURL
@NonNull public URL asURL() throws MalformedURLException
Returns current URL as aURL. If url is relative, host with port is currentURLs.SERVER- Returns:
URL- Throws:
MalformedURLException- exception thrown byURLwhen created
-
protocol
@NonNull public String protocol() throws MalformedURLException
Wrap ofasURL()and methodURL.getProtocol()- Returns:
String- Throws:
MalformedURLException- exception thrown byURLwhen created
-
host
@NonNull public String host() throws MalformedURLException
Wrap ofasURL()and methodURL.getHost()- Returns:
String- Throws:
MalformedURLException- exception thrown byURLwhen created
-
port
public int port() throws MalformedURLExceptionGets the port number of this URL. If the port is not set, returns the port number of the protocol associated with this URL. IfURLhas no default port to this protocol, then -1 is returned.- Returns:
- the port number
- Throws:
MalformedURLException- exception thrown byURLwhen created
-
path
@NonNull public String path() throws MalformedURLException
- Throws:
MalformedURLException
-
describeContents
public int describeContents()
- Specified by:
describeContentsin interfaceandroid.os.Parcelable
-
writeToParcel
public void writeToParcel(android.os.Parcel dest, int flags)- Specified by:
writeToParcelin interfaceandroid.os.Parcelable
-
-