Package snap.web
Class WebURL
java.lang.Object
snap.web.WebURL
A class to represent a URL for a WebSite and WebFile (it can be both for nested sources).
Has the form: [Scheme:][//Authority][/Path[!/Path]][?Query][#HashTag].
Authority has the form: [UserInfo@]Host[:Port].
WebURL is a thin wrapper around standard URL, but provides easy access to the WebSite and WebFile.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncreateFile
(boolean isDir) Creates a file for the URL.boolean
Standard equals implementation.Returns the site for this URL (assumes this URL is a site).byte[]
getBytes()
Returns bytes for this URL.byte[]
Returns bytes for this URL.Returns the child URL for given name.getFile()
Returns the file for the URL.Returns the FileHeader.Returns the last component of the file path.Returns the filename without extension.Returns the file type (extension without the '.').Returns the URL for the file only (no query/hashtags).getHead()
Returns the response for a HEAD request.getHost()
Returns the Host part of the URL.Returns an input stream for file.Returns the source as standard Java File (if possible).Returns the source as standard Java URL (if possible).long
Returns the last modified time.Returns the parent URL.getPath()
Returns the part of the URL string that describes the file path.int
getPort()
Returns the port of the URL.getQuery()
Returns the part of the URL string that describes the query.Returns the URL for the file and query only (no hashtag references).getQueryValue
(String aKey) Returns the value for given Query key in URL, if available.getRef()
Returns the hash tag reference from the URL as a simple string.getRefValue
(String aKey) Returns the value for given HashTag key in URL, if available.Returns Response for a Get request.void
getResponseAndCall
(Consumer<WebResponse> aCallback) Returns bytes for this URL.Returns the URL Scheme (lower case).getSite()
Returns the site that this URL belongs to.Returns the URL for the site that this URL belongs to.Returns the source of this URL (java.net.URL, File, String).Returns the source as standard Java URL.Returns the full URL string.getText()
Returns the file bytes as a string.static WebURL
Returns a URL for given class and resource name.static WebURL
Returns a URL for given object.static WebURL
getURLOrThrow
(Object anObj) Returns a URL for given object.Returns the windows drive letter.int
hashCode()
Standard HashCode implementation.boolean
Returns whether URL specifies only the file (no query/hashtags).boolean
isFound()
Returns whether URL can be found.boolean
Returns whether URL specifies only file and query (no hashtag references).byte[]
postBytes
(byte[] theBytes) Returns bytes for this URL.toString()
Standard toString implementation.
-
Field Details
-
_asSite
-
-
Constructor Details
-
WebURL
Constructor for given source.
-
-
Method Details
-
getURL
Returns a URL for given object. -
getURLOrThrow
Returns a URL for given object. -
getURL
Returns a URL for given class and resource name. -
getSource
Returns the source of this URL (java.net.URL, File, String). -
getSourceURL
Returns the source as standard Java URL. Might contain site-path separator. See getJavaURL(). -
getString
Returns the full URL string. -
getScheme
Returns the URL Scheme (lower case). -
getHost
Returns the Host part of the URL. -
getPort
public int getPort()Returns the port of the URL. -
getPath
Returns the part of the URL string that describes the file path. -
getFilename
Returns the last component of the file path. -
getFilenameSimple
Returns the filename without extension. -
getFileType
Returns the file type (extension without the '.'). -
getQuery
Returns the part of the URL string that describes the query. -
getQueryValue
Returns the value for given Query key in URL, if available. -
getRef
Returns the hash tag reference from the URL as a simple string. -
getRefValue
Returns the value for given HashTag key in URL, if available. -
getSite
Returns the site that this URL belongs to. -
getSiteURL
Returns the URL for the site that this URL belongs to. -
getAsSite
Returns the site for this URL (assumes this URL is a site). -
getFile
Returns the file for the URL. -
createFile
Creates a file for the URL. -
isFileURL
public boolean isFileURL()Returns whether URL specifies only the file (no query/hashtags). -
getFileURL
Returns the URL for the file only (no query/hashtags). -
isQueryURL
public boolean isQueryURL()Returns whether URL specifies only file and query (no hashtag references). -
getQueryURL
Returns the URL for the file and query only (no hashtag references). -
getJavaURL
Returns the source as standard Java URL (if possible). -
getJavaFile
Returns the source as standard Java File (if possible). -
isFound
public boolean isFound()Returns whether URL can be found. -
getLastModTime
public long getLastModTime()Returns the last modified time. -
getBytes
public byte[] getBytes()Returns bytes for this URL. -
getBytesOrThrow
Returns bytes for this URL.- Throws:
IOException
-
postBytes
public byte[] postBytes(byte[] theBytes) Returns bytes for this URL. -
getText
Returns the file bytes as a string. -
getInputStream
Returns an input stream for file. -
getHead
Returns the response for a HEAD request. -
getFileHeader
Returns the FileHeader. -
getResponse
Returns Response for a Get request. -
getResponseAndCall
Returns bytes for this URL. -
getParent
Returns the parent URL. -
getChild
Returns the child URL for given name. -
getWindowsDriveLetterPath
Returns the windows drive letter. -
equals
Standard equals implementation. -
hashCode
public int hashCode()Standard HashCode implementation. -
toString
Standard toString implementation.
-