Class URLWrapper
- java.lang.Object
-
- net.lenni0451.commons.httpclient.utils.URLWrapper
-
public class URLWrapper extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classURLWrapper.QueryWrapper
-
Constructor Summary
Constructors Constructor Description URLWrapper()URLWrapper(java.lang.String url)URLWrapper(java.net.URI uri)URLWrapper(java.net.URL url)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static URLWrapperempty()Create a new empty URLWrapper.java.lang.StringgetHost()java.lang.StringgetPath()intgetPort()java.lang.StringgetProtocol()java.lang.StringgetQuery()java.lang.StringgetReference()java.lang.StringgetUserInfo()static URLWrapperof(java.lang.String url)Create a new URLWrapper from aString.static URLWrapperof(java.net.URI uri)Create a new URLWrapper from anURI.static URLWrapperof(java.net.URL url)Create a new URLWrapper from anURL.URLWrappersetHost(java.lang.String host)Set the host of the URL.
e.g.URLWrappersetPath(java.lang.String path)Set the file of the URL.
e.g.URLWrappersetPort(int port)Set the port of the URL.
e.g.URLWrappersetProtocol(java.lang.String protocol)Set the protocol of the URL.
e.g.URLWrappersetQuery(java.lang.String query)Set the query of the URL.
e.g.URLWrappersetReference(java.lang.String reference)Set the reference of the URL.
e.g.URLWrappersetUserInfo(java.lang.String userInfo)Set the user info of the URL.
e.g.java.lang.StringtoString()java.net.URItoURI()java.net.URLtoURL()URLWrapper.QueryWrapperwrapQuery()Get a wrapper for the query parameters.
-
-
-
Method Detail
-
empty
public static URLWrapper empty()
Create a new empty URLWrapper.- Returns:
- The URLWrapper
-
of
public static URLWrapper of(java.lang.String url) throws java.net.MalformedURLException
Create a new URLWrapper from aString.- Parameters:
url- The URL to wrap- Returns:
- The URLWrapper
- Throws:
java.net.MalformedURLException- If the URL is invalid
-
of
public static URLWrapper of(java.net.URL url)
Create a new URLWrapper from anURL.- Parameters:
url- The URL to wrap- Returns:
- The URLWrapper
-
of
public static URLWrapper of(java.net.URI uri)
Create a new URLWrapper from anURI.- Parameters:
uri- The URI to wrap- Returns:
- The URLWrapper
-
getProtocol
public java.lang.String getProtocol()
- Returns:
- The protocol of the URL. e.g.
https
-
setProtocol
public URLWrapper setProtocol(java.lang.String protocol)
Set the protocol of the URL.
e.g.https- Parameters:
protocol- The new protocol- Returns:
- The URLWrapper
-
getHost
public java.lang.String getHost()
- Returns:
- The host of the URL. e.g.
www.example.com
-
setHost
public URLWrapper setHost(java.lang.String host)
Set the host of the URL.
e.g.www.example.com- Parameters:
host- The new host- Returns:
- The URLWrapper
-
getPort
public int getPort()
- Returns:
- The port of the URL. e.g.
443
-
setPort
public URLWrapper setPort(int port)
Set the port of the URL.
e.g.443- Parameters:
port- The new port- Returns:
- The URLWrapper
-
getPath
public java.lang.String getPath()
- Returns:
- The file of the URL. e.g.
/search
-
setPath
public URLWrapper setPath(java.lang.String path)
Set the file of the URL.
e.g./search- Parameters:
path- The new file- Returns:
- The URLWrapper
-
getQuery
public java.lang.String getQuery()
- Returns:
- The query of the URL. e.g.
q=hello
-
setQuery
public URLWrapper setQuery(java.lang.String query)
Set the query of the URL.
e.g.q=hello- Parameters:
query- The new query- Returns:
- The URLWrapper
-
wrapQuery
public URLWrapper.QueryWrapper wrapQuery()
Get a wrapper for the query parameters.- Returns:
- The query wrapper
-
getUserInfo
public java.lang.String getUserInfo()
- Returns:
- The user info of the URL. e.g.
user:password
-
setUserInfo
public URLWrapper setUserInfo(java.lang.String userInfo)
Set the user info of the URL.
e.g.user:password- Parameters:
userInfo- The new user info- Returns:
- The URLWrapper
-
getReference
public java.lang.String getReference()
- Returns:
- The reference of the URL. e.g.
reference
-
setReference
public URLWrapper setReference(java.lang.String reference)
Set the reference of the URL.
e.g.reference- Parameters:
reference- The new reference- Returns:
- The URLWrapper
-
toURL
public java.net.URL toURL() throws java.net.MalformedURLException- Returns:
- The wrapped URL
- Throws:
java.net.MalformedURLException- If the URL is invalid
-
toURI
public java.net.URI toURI()
- Returns:
- The wrapped URI
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-