- java.lang.Object
-
- org.refcodes.web.UrlSugar
-
public class UrlSugar extends Object
Declarative syntactic sugar which may be statically imported in order to allow declarative definitions forUrl(UrlBuilder) creation and tweaking:import static org.refcodes.web.UrlSugar.*;
-
-
Constructor Summary
Constructors Constructor Description UrlSugar()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description UrlBuildertoUrl()Creates an emptyUrlBuilder, make sure to set required attributes for a valid URL.UrlBuildertoUrl(String aUrl)Constructs anUrlBuilderfrom the provided URLString.UrlBuildertoUrl(String aProtocol, String aHost)Constructs anUrlBuilderwith the common attributes.UrlBuildertoUrl(String aProtocol, String aHost, int aPort)Constructs anUrlBuilderwith the common attributes.UrlBuildertoUrl(String aProtocol, String aHost, int aPort, String aPath)Constructs anUrlBuilderwith the common attributes.UrlBuildertoUrl(String aProtocol, String aHost, int aPort, String aPath, FormFields aQueryFields)Constructs anUrlBuilderwith the common attributes.UrlBuildertoUrl(String aProtocol, String aHost, int aPort, String aPath, FormFields aQueryFields, String aFragment)Constructs anUrlBuilderwith the common attributes.UrlBuildertoUrl(String aProtocol, String aHost, String aPath)Constructs anUrlBuilderwith the common attributes.UrlBuildertoUrl(String aProtocol, String aHost, String aPath, FormFields aQueryFields)Constructs anUrlBuilderwith the common attributes.UrlBuildertoUrl(String aProtocol, String aHost, String aPath, FormFields aQueryFields, String aFragment)Constructs anUrlBuilderwith the common attributes.UrlBuildertoUrl(URL aURL)Constructs anUrlBuilderfrom the providedURLinstance.UrlBuildertoUrl(org.refcodes.data.Scheme aScheme, String aHost)Constructs anUrlBuilderwith the common attributes.UrlBuildertoUrl(org.refcodes.data.Scheme aScheme, String aHost, int aPort)Constructs anUrlBuilderwith the common attributes.UrlBuildertoUrl(org.refcodes.data.Scheme aScheme, String aHost, int aPort, String aPath)Constructs anUrlBuilderwith the common attributes.UrlBuildertoUrl(org.refcodes.data.Scheme aScheme, String aHost, int aPort, String aPath, FormFields aQueryFields)Constructs anUrlBuilderwith the common attributes.UrlBuildertoUrl(org.refcodes.data.Scheme aScheme, String aHost, int aPort, String aPath, FormFields aQueryFields, String aFragment)Constructs anUrlBuilderwith the common attributes.UrlBuildertoUrl(org.refcodes.data.Scheme aScheme, String aHost, String aPath)Constructs anUrlBuilderwith the common attributes.UrlBuildertoUrl(org.refcodes.data.Scheme aScheme, String aHost, String aPath, FormFields aQueryFields)Constructs anUrlBuilderwith the common attributes.UrlBuildertoUrl(org.refcodes.data.Scheme aScheme, String aHost, String aPath, FormFields aQueryFields, String aFragment)Constructs anUrlBuilderwith the common attributes.
-
-
-
Method Detail
-
toUrl
public UrlBuilder toUrl()
Creates an emptyUrlBuilder, make sure to set required attributes for a valid URL.- Returns:
- The accordingly constructed
UrlBuilderinstance.
-
toUrl
public UrlBuilder toUrl(String aUrl) throws MalformedURLException
Constructs anUrlBuilderfrom the provided URLString.- Parameters:
aUrl- The URLStringto be parsed.- Returns:
- The accordingly constructed
UrlBuilderinstance. - Throws:
MalformedURLException- in case the provided URL is considered being malformed.
-
toUrl
public UrlBuilder toUrl(URL aURL)
Constructs anUrlBuilderfrom the providedURLinstance.- Parameters:
aURL- TheURLto be used.- Returns:
- The accordingly constructed
UrlBuilderinstance.
-
toUrl
public UrlBuilder toUrl(org.refcodes.data.Scheme aScheme, String aHost)
Constructs anUrlBuilderwith the common attributes.- Parameters:
aScheme- TheScheme(e.g. HTTP or HTTPS) to be used for the destination URL.aHost- The host to which the destination URL is to point to.- Returns:
- The accordingly constructed
UrlBuilderinstance.
-
toUrl
public UrlBuilder toUrl(org.refcodes.data.Scheme aScheme, String aHost, int aPort)
Constructs anUrlBuilderwith the common attributes.- Parameters:
aScheme- TheScheme(e.g. HTTP or HTTPS) to be used for the destination URL.aHost- The host to which the destination URL is to point to.aPort- The port to be used when connecting to the host.- Returns:
- The accordingly constructed
UrlBuilderinstance.
-
toUrl
public UrlBuilder toUrl(org.refcodes.data.Scheme aScheme, String aHost, int aPort, String aPath)
Constructs anUrlBuilderwith the common attributes.- Parameters:
aScheme- TheScheme(e.g. HTTP or HTTPS) to be used for the destination URL.aHost- The host to which the destination URL is to point to.aPort- The port to be used when connecting to the host.aPath- The path on the host to which the base destination URL is to point to.- Returns:
- The accordingly constructed
UrlBuilderinstance.
-
toUrl
public UrlBuilder toUrl(org.refcodes.data.Scheme aScheme, String aHost, int aPort, String aPath, FormFields aQueryFields)
Constructs anUrlBuilderwith the common attributes.- Parameters:
aScheme- TheScheme(e.g. HTTP or HTTPS) to be used for the destination URL.aHost- The host to which the destination URL is to point to.aPort- The port to be used when connecting to the host.aPath- The path on the host to which the base destination URL is to point to.aQueryFields- The Query-Fields to be used for the HTTP Query-String.- Returns:
- The accordingly constructed
UrlBuilderinstance.
-
toUrl
public UrlBuilder toUrl(org.refcodes.data.Scheme aScheme, String aHost, int aPort, String aPath, FormFields aQueryFields, String aFragment)
Constructs anUrlBuilderwith the common attributes.- Parameters:
aScheme- TheScheme(e.g. HTTP or HTTPS) to be used for the destination URL.aHost- The host to which the destination URL is to point to.aPort- The port to be used when connecting to the host.aPath- The path on the host to which the base destination URL is to point to.aQueryFields- The Query-Fields to be used for the HTTP Query-String.aFragment- The fragment to be set.- Returns:
- The accordingly constructed
UrlBuilderinstance.
-
toUrl
public UrlBuilder toUrl(String aProtocol, String aHost)
Constructs anUrlBuilderwith the common attributes.- Parameters:
aProtocol- The protocolString(e.g. "http://" or "https://") to be used for the destination URL.aHost- The host to which the destination URL is to point to.- Returns:
- The accordingly constructed
UrlBuilderinstance.
-
toUrl
public UrlBuilder toUrl(String aProtocol, String aHost, int aPort)
Constructs anUrlBuilderwith the common attributes.- Parameters:
aProtocol- The protocolString(e.g. "http://" or "https://") to be used for the destination URL.aHost- The host to which the destination URL is to point to.aPort- The port to be used when connecting to the host.- Returns:
- The accordingly constructed
UrlBuilderinstance.
-
toUrl
public UrlBuilder toUrl(String aProtocol, String aHost, int aPort, String aPath)
Constructs anUrlBuilderwith the common attributes.- Parameters:
aProtocol- The protocolString(e.g. "http://" or "https://") to be used for the destination URL.aHost- The host to which the destination URL is to point to.aPort- The port to be used when connecting to the host.aPath- The path on the host to which the base destination URL is to point to.- Returns:
- The accordingly constructed
UrlBuilderinstance.
-
toUrl
public UrlBuilder toUrl(String aProtocol, String aHost, int aPort, String aPath, FormFields aQueryFields)
Constructs anUrlBuilderwith the common attributes.- Parameters:
aProtocol- The protocolString(e.g. "http://" or "https://") to be used for the destination URL.aHost- The host to which the destination URL is to point to.aPort- The port to be used when connecting to the host.aPath- The path on the host to which the base destination URL is to point to.aQueryFields- The Query-Fields to be used for the HTTP Query-String.- Returns:
- The accordingly constructed
UrlBuilderinstance.
-
toUrl
public UrlBuilder toUrl(String aProtocol, String aHost, int aPort, String aPath, FormFields aQueryFields, String aFragment)
Constructs anUrlBuilderwith the common attributes.- Parameters:
aProtocol- The protocolString(e.g. "http://" or "https://") to be used for the destination URL.aHost- The host to which the destination URL is to point to.aPort- The port to be used when connecting to the host.aPath- The path on the host to which the base destination URL is to point to.aQueryFields- The Query-Fields to be used for the HTTP Query-String.aFragment- The fragment to be set.- Returns:
- The accordingly constructed
UrlBuilderinstance.
-
toUrl
public UrlBuilder toUrl(org.refcodes.data.Scheme aScheme, String aHost, String aPath)
Constructs anUrlBuilderwith the common attributes.- Parameters:
aScheme- TheScheme(e.g. HTTP or HTTPS) to be used for the destination URL.aHost- The host to which the destination URL is to point to.aPath- The path on the host to which the base destination URL is to point to.- Returns:
- The accordingly constructed
UrlBuilderinstance.
-
toUrl
public UrlBuilder toUrl(org.refcodes.data.Scheme aScheme, String aHost, String aPath, FormFields aQueryFields)
Constructs anUrlBuilderwith the common attributes.- Parameters:
aScheme- TheScheme(e.g. HTTP or HTTPS) to be used for the destination URL.aHost- The host to which the destination URL is to point to.aPath- The path on the host to which the base destination URL is to point to.aQueryFields- The Query-Fields to be used for the HTTP Query-String.- Returns:
- The accordingly constructed
UrlBuilderinstance.
-
toUrl
public UrlBuilder toUrl(org.refcodes.data.Scheme aScheme, String aHost, String aPath, FormFields aQueryFields, String aFragment)
Constructs anUrlBuilderwith the common attributes.- Parameters:
aScheme- TheScheme(e.g. HTTP or HTTPS) to be used for the destination URL.aHost- The host to which the destination URL is to point to.aPath- The path on the host to which the base destination URL is to point to.aQueryFields- The Query-Fields to be used for the HTTP Query-String.aFragment- The fragment to be set.- Returns:
- The accordingly constructed
UrlBuilderinstance.
-
toUrl
public UrlBuilder toUrl(String aProtocol, String aHost, String aPath)
Constructs anUrlBuilderwith the common attributes.- Parameters:
aProtocol- The protocolString(e.g. "http://" or "https://") to be used for the destination URL.aHost- The host to which the destination URL is to point to.aPath- The path on the host to which the base destination URL is to point to.- Returns:
- The accordingly constructed
UrlBuilderinstance.
-
toUrl
public UrlBuilder toUrl(String aProtocol, String aHost, String aPath, FormFields aQueryFields)
Constructs anUrlBuilderwith the common attributes.- Parameters:
aProtocol- The protocolString(e.g. "http://" or "https://") to be used for the destination URL.aHost- The host to which the destination URL is to point to.aPath- The path on the host to which the base destination URL is to point to.aQueryFields- The Query-Fields to be used for the HTTP Query-String.- Returns:
- The accordingly constructed
UrlBuilderinstance.
-
toUrl
public UrlBuilder toUrl(String aProtocol, String aHost, String aPath, FormFields aQueryFields, String aFragment)
Constructs anUrlBuilderwith the common attributes.- Parameters:
aProtocol- The protocolString(e.g. "http://" or "https://") to be used for the destination URL.aHost- The host to which the destination URL is to point to.aPath- The path on the host to which the base destination URL is to point to.aQueryFields- The Query-Fields to be used for the HTTP Query-String.aFragment- The fragment to be set.- Returns:
- The accordingly constructed
UrlBuilderinstance.
-
-