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:
Serializable
,Cloneable
,org.htmlunit.corejs.javascript.ConstProperties
,org.htmlunit.corejs.javascript.debug.DebuggableObject
,org.htmlunit.corejs.javascript.Scriptable
,org.htmlunit.corejs.javascript.SymbolScriptable
A JavaScript object for
URL
.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.corejs.javascript.ScriptableObject.KeyComparator
-
Field Summary
FieldsFields inherited from class org.htmlunit.corejs.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST
Fields inherited from interface org.htmlunit.corejs.javascript.Scriptable
NOT_FOUND
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
createObjectURL
(Object fileOrBlob) The URL.createObjectURL() static method creates a DOMString containing a URL representing the object given in parameter.getDefaultValue
(Class<?> hint) Calls for instance for implicit conversion to string.getHash()
getHost()
getHref()
getPort()
void
jsConstructor
(String url, Object base) Creates an instance.Returns the text of the URL.static void
revokeObjectURL
(org.htmlunit.corejs.javascript.Scriptable objectURL) void
void
void
setHostname
(String hostname) void
void
setPassword
(String password) void
setPathname
(String path) void
void
setProtocol
(String protocol) void
void
setSearch
(List<NameValuePair> nameValuePairs) void
setUsername
(String username) 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
-
Field Details
-
url_
-
-
Constructor Details
-
URL
public URL()Creates an instance.
-
-
Method Details
-
jsConstructor
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
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
- Returns:
- hash property of the URL containing a '#' followed by the fragment identifier of the URL.
-
setHash
- Throws:
MalformedURLException
-
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
- Throws:
MalformedURLException
-
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
- Throws:
MalformedURLException
-
getHref
- Returns:
- whole URL
-
setHref
- Throws:
MalformedURLException
-
getOrigin
- Returns:
- the origin
-
getSearchParams
- Returns:
- a URLSearchParams object allowing access to the GET decoded query arguments contained in the URL.
-
getPassword
- Returns:
- the password specified before the domain name.
-
setPassword
- Throws:
MalformedURLException
-
getPathname
- Returns:
- a URLSearchParams object allowing access to the GET decoded query arguments contained in the URL.
-
setPathname
- Throws:
MalformedURLException
-
getPort
- Returns:
- the port number of the URL. If the URL does not contain an explicit port number, it will be set to ''
-
setPort
- Throws:
MalformedURLException
-
getProtocol
- Returns:
- the protocol scheme of the URL, including the final ':'.
-
setProtocol
- Throws:
MalformedURLException
-
getSearch
- Returns:
- the query string containing a '?' followed by the parameters of the URL
-
setSearch
- Throws:
MalformedURLException
-
setSearch
- Throws:
MalformedURLException
-
getUsername
- Returns:
- the username specified before the domain name.
-
setUsername
- Throws:
MalformedURLException
-
getDefaultValue
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:
-
toJSON
- Returns:
- a serialized version of the URL, although in practice it seems to have the same effect as URL.toString().
-
jsToString
Returns the text of the URL.- Returns:
- the text
-