Package org.htmlunit.javascript.host
Class URL
- java.lang.Object
-
- org.htmlunit.corejs.javascript.ScriptableObject
-
- org.htmlunit.javascript.HtmlUnitScriptable
-
- org.htmlunit.javascript.host.URL
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,org.htmlunit.corejs.javascript.ConstProperties
,org.htmlunit.corejs.javascript.debug.DebuggableObject
,org.htmlunit.corejs.javascript.Scriptable
,org.htmlunit.corejs.javascript.SymbolScriptable
public class URL extends HtmlUnitScriptable
A JavaScript object forURL
.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.net.URL
url_
-
Constructor Summary
Constructors Constructor Description URL()
Creates an instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.String
createObjectURL(java.lang.Object fileOrBlob)
The URL.createObjectURL() static method creates a DOMString containing a URL representing the object given in parameter.java.lang.Object
getDefaultValue(java.lang.Class<?> hint)
Calls for instance for implicit conversion to string.java.lang.String
getHash()
java.lang.String
getHost()
java.lang.String
getHostname()
java.lang.String
getHref()
java.lang.Object
getOrigin()
java.lang.String
getPassword()
java.lang.String
getPathname()
java.lang.String
getPort()
java.lang.String
getProtocol()
java.lang.String
getSearch()
URLSearchParams
getSearchParams()
java.lang.String
getUsername()
void
jsConstructor(java.lang.String url, java.lang.Object base)
Creates an instance.java.lang.String
jsToString()
Returns the text of the URL.static void
revokeObjectURL(org.htmlunit.corejs.javascript.Scriptable objectURL)
void
setHash(java.lang.String fragment)
void
setHost(java.lang.String host)
void
setHostname(java.lang.String hostname)
void
setHref(java.lang.String href)
void
setPassword(java.lang.String password)
void
setPathname(java.lang.String path)
void
setPort(java.lang.String port)
void
setProtocol(java.lang.String protocol)
void
setSearch(java.lang.String search)
void
setSearch(java.util.List<NameValuePair> nameValuePairs)
void
setUsername(java.lang.String username)
java.lang.String
toJSON()
-
Methods inherited from class org.htmlunit.javascript.HtmlUnitScriptable
clone, equivalentValues, get, getBrowserVersion, getClassName, getDomNodeOrDie, getDomNodeOrNull, getPrototype, getScriptableFor, getStartingScope, getWindow, getWindow, getWithPreemption, has, hasInstance, initParentScope, makeScriptableFor, put, setClassName, setDomNode, setDomNode, setParentScope, setupPromise, setupRejectedPromise
-
Methods inherited from class org.htmlunit.corejs.javascript.ScriptableObject
applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, get, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, has, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putProperty, putProperty, putProperty, querySlot, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setPrototype, size
-
-
-
-
Method Detail
-
jsConstructor
public void jsConstructor(java.lang.String url, java.lang.Object base)
Creates an instance.- Parameters:
url
- a string representing an absolute or relative URL. If url is a relative URL, base is required, and will be used as the base URL. If url is an absolute URL, a given base will be ignored.base
- a string representing the base URL to use in case url is a relative URL. If not specified, it defaults to ''.
-
createObjectURL
public static java.lang.String createObjectURL(java.lang.Object fileOrBlob)
The URL.createObjectURL() static method creates a DOMString containing a URL representing the object given in parameter. The URL lifetime is tied to the document in the window on which it was created. The new object URL represents the specified File object or Blob object.- Parameters:
fileOrBlob
- Is a File object or a Blob object to create a object URL for.- Returns:
- the url
-
revokeObjectURL
public static void revokeObjectURL(org.htmlunit.corejs.javascript.Scriptable objectURL)
- Parameters:
objectURL
- String representing the object URL that was created by calling URL.createObjectURL().
-
getHash
public java.lang.String getHash()
- Returns:
- hash property of the URL containing a '#' followed by the fragment identifier of the URL.
-
setHash
public void setHash(java.lang.String fragment) throws java.net.MalformedURLException
- Throws:
java.net.MalformedURLException
-
getHost
public java.lang.String getHost()
- Returns:
- the host, that is the hostname, and then, if the port of the URL is nonempty, a ':', followed by the port of the URL.
-
setHost
public void setHost(java.lang.String host) throws java.net.MalformedURLException
- Throws:
java.net.MalformedURLException
-
getHostname
public java.lang.String getHostname()
- Returns:
- the host, that is the hostname, and then, if the port of the URL is nonempty, a ':', followed by the port of the URL.
-
setHostname
public void setHostname(java.lang.String hostname) throws java.net.MalformedURLException
- Throws:
java.net.MalformedURLException
-
getHref
public java.lang.String getHref()
- Returns:
- whole URL
-
setHref
public void setHref(java.lang.String href) throws java.net.MalformedURLException
- Throws:
java.net.MalformedURLException
-
getOrigin
public java.lang.Object getOrigin()
- Returns:
- the origin
-
getSearchParams
public URLSearchParams getSearchParams()
- Returns:
- a URLSearchParams object allowing access to the GET decoded query arguments contained in the URL.
-
getPassword
public java.lang.String getPassword()
- Returns:
- the password specified before the domain name.
-
setPassword
public void setPassword(java.lang.String password) throws java.net.MalformedURLException
- Throws:
java.net.MalformedURLException
-
getPathname
public java.lang.String getPathname()
- Returns:
- a URLSearchParams object allowing access to the GET decoded query arguments contained in the URL.
-
setPathname
public void setPathname(java.lang.String path) throws java.net.MalformedURLException
- Throws:
java.net.MalformedURLException
-
getPort
public java.lang.String getPort()
- Returns:
- the port number of the URL. If the URL does not contain an explicit port number, it will be set to ''
-
setPort
public void setPort(java.lang.String port) throws java.net.MalformedURLException
- Throws:
java.net.MalformedURLException
-
getProtocol
public java.lang.String getProtocol()
- Returns:
- the protocol scheme of the URL, including the final ':'.
-
setProtocol
public void setProtocol(java.lang.String protocol) throws java.net.MalformedURLException
- Throws:
java.net.MalformedURLException
-
getSearch
public java.lang.String getSearch()
- Returns:
- the query string containing a '?' followed by the parameters of the URL
-
setSearch
public void setSearch(java.lang.String search) throws java.net.MalformedURLException
- Throws:
java.net.MalformedURLException
-
setSearch
public void setSearch(java.util.List<NameValuePair> nameValuePairs) throws java.net.MalformedURLException
- Throws:
java.net.MalformedURLException
-
getUsername
public java.lang.String getUsername()
- Returns:
- the username specified before the domain name.
-
setUsername
public void setUsername(java.lang.String username) throws java.net.MalformedURLException
- Throws:
java.net.MalformedURLException
-
getDefaultValue
public java.lang.Object getDefaultValue(java.lang.Class<?> hint)
Calls for instance for implicit conversion to string.- Specified by:
getDefaultValue
in interfaceorg.htmlunit.corejs.javascript.Scriptable
- Overrides:
getDefaultValue
in classHtmlUnitScriptable
- Parameters:
hint
- the type hint- Returns:
- the default value
- See Also:
HtmlUnitScriptable.getDefaultValue(java.lang.Class)
-
toJSON
public java.lang.String toJSON()
- Returns:
- a serialized version of the URL, although in practice it seems to have the same effect as URL.toString().
-
jsToString
public java.lang.String jsToString()
Returns the text of the URL.- Returns:
- the text
-
-