Package es.situm.sdk.model
Class URL
java.lang.Object
es.situm.sdk.model.URL
- All Implemented Interfaces:
android.os.Parcelable
Abstraction of URL. Unifies management of both absolutes and relatives URLs.
-
Nested Class Summary
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final android.os.Parcelable.Creator<URL>static final URLFields inherited from interface android.os.Parcelable
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasURL()Returns current URL as aURL.intbooleanReturns las part of provided value, separated by '/'.getValue()Original value provided to de constructorinthashCode()host()Wrap ofasURL()and methodURL.getHost()booleanReturn true if the value used to construct the URL doesn't start by '/', meaning it has a specific host.booleanReturn true if the value used to construct the URL starts by '/', meaning it has no specific host nor port.path()intport()Gets the port number of this URL.protocol()Wrap ofasURL()and methodURL.getProtocol()toString()voidwriteToParcel(android.os.Parcel dest, int flags)
-
Field Details
-
EMPTY
-
CREATOR
-
-
Constructor Details
-
URL
Create a URL object with an absolute or relative URL. If value starts with '/' is considered relative, and will takeURLs.SERVERas host with port.- Parameters:
value-String
-
-
Method Details
-
getValue
Original value provided to de constructor- Returns:
- constructor's value param
-
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
Returns current URL as aURL. If url is relative, host with port is currentURLs.SERVER- Returns:
URL- Throws:
MalformedURLException- exception thrown byURLwhen created
-
asStringURL
- Returns:
String
-
protocol
Wrap ofasURL()and methodURL.getProtocol()- Returns:
String- Throws:
MalformedURLException- exception thrown byURLwhen created
-
host
Wrap ofasURL()and methodURL.getHost()- Returns:
String- Throws:
MalformedURLException- exception thrown byURLwhen created
-
port
Gets 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
- Throws:
MalformedURLException
-
equals
-
toString
-
hashCode
public int hashCode() -
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
-