public class URLEndpoint extends Object
Class which encapsulates the API URL, and enables relevant operations on this URL.
Constructor and Description |
---|
URLEndpoint(String url)
Overloaded constructor.
|
URLEndpoint(URL url)
Overloaded constructor.
|
Modifier and Type | Method and Description |
---|---|
URLEndpoint |
append(String str)
Appends the given string to the URL.
|
boolean |
equals(Object obj) |
static URLEndpoint |
getRootUrl()
Returns the root URL for the API.
|
static URLEndpoint |
getRootUrl(Locale locale)
Returns the root URL for the API for a specific
Locale . |
String |
getTable()
Returns the table portion of this URL.
|
int |
hashCode() |
String |
toString() |
URLEndpoint |
toURL(Locale locale)
Generates a new URL to the API using the specified
Locale . |
URLEndpoint |
toURL(String language)
Generates a new URL to the API by replacing the current language tag in the URL
with the specified language tag.
|
public URLEndpoint(URL url)
Overloaded constructor.
url
- the URLpublic URLEndpoint(String url)
Overloaded constructor.
url
- the URLpublic URLEndpoint append(String str)
Appends the given string to the URL.
str
- the string to appendURLEndpoint
with the given string appendedpublic String getTable()
Returns the table portion of this URL.
Example: URL of https://api.scb.se/OV0104/v1/doris/sv/ssd/BE/BE0401/BE0401A/ is converted to BE/BE0401/BE0401A/.
Due to speed efficiency, this method does not perform any validity check on the specified URL. Calling this method without a valid URL for the API may (and probably will) result in undefined behavior.
public URLEndpoint toURL(Locale locale)
Generates a new URL to the API using the specified Locale
.
See toURL(String)
for implementation details.
locale
- the Locale
to useURLEndpoint
representing the URLpublic URLEndpoint toURL(String language)
Generates a new URL to the API by replacing the current language tag in the URL with the specified language tag.
This method performs these steps to figure out what needs to be replaced:
Example: URL of https://api.scb.se/OV0104/v1/doris/sv/ssd/ and language input of en is converted to https://api.scb.se/OV0104/v1/doris/en/ssd/.
Due to speed efficiency, this method does not perform any validity check on the specified URL. Calling this method without a valid URL for the API may (and probably will) result in undefined behavior.
language
- the language to useURLEndpoint
representing the modified URLpublic static URLEndpoint getRootUrl()
Returns the root URL for the API.
URLEndpoint
representing the
ROOT_URL
public static URLEndpoint getRootUrl(Locale locale)
Returns the root URL for the API for a specific Locale
.
locale
- the Locale
URLEndpoint
representing the
ROOT_URL
with a converted language tag segment matching the specified
Locale
Copyright © 2018. All rights reserved.