Package org.htmlunit.javascript.host
Class Location
- java.lang.Object
-
- org.htmlunit.corejs.javascript.ScriptableObject
-
- org.htmlunit.javascript.HtmlUnitScriptable
-
- org.htmlunit.javascript.host.Location
-
- 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 Location extends HtmlUnitScriptable
A JavaScript object forLocation.- See Also:
- MSDN Documentation, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.reflect.MethodgetterHashprivate static java.lang.reflect.MethodgetterHostprivate static java.lang.reflect.MethodgetterHostnameprivate static java.lang.reflect.MethodgetterHrefprivate static java.lang.reflect.MethodgetterOriginprivate static java.lang.reflect.MethodgetterPathnameprivate static java.lang.reflect.MethodgetterPortprivate static java.lang.reflect.MethodgetterProtocolprivate static java.lang.reflect.MethodgetterSearchprivate java.lang.Stringhash_The current hash; we cache it locally because we don't want to modify the page's URL and force a page reload each time this changes.private static org.apache.commons.logging.LogLOGprivate static java.lang.reflect.MethodmethodAssignprivate static java.lang.reflect.MethodmethodReloadprivate static java.lang.reflect.MethodmethodReplaceprivate static java.lang.reflect.MethodmethodToStringprivate static java.lang.reflect.MethodsetterHashprivate static java.lang.reflect.MethodsetterHostprivate static java.lang.reflect.MethodsetterHostnameprivate static java.lang.reflect.MethodsetterHrefprivate static java.lang.reflect.MethodsetterPathnameprivate static java.lang.reflect.MethodsetterPortprivate static java.lang.reflect.MethodsetterProtocolprivate static java.lang.reflect.MethodsetterSearchprivate static java.lang.StringUNKNOWNprivate Windowwindow_The window which owns this location object.
-
Constructor Summary
Constructors Constructor Description Location()Creates an instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidassign(java.lang.String url)Loads the new HTML document corresponding to the specified URL.private static java.lang.StringdecodeHash(java.lang.String hash)java.lang.ObjectgetDefaultValue(java.lang.Class<?> hint)Returns the JavaScript default value of this object.java.lang.StringgetHash()Returns the hash portion of the location URL (the portion following the '#').private java.lang.StringgetHash(boolean encoded)java.lang.StringgetHost()Returns the host portion of the location URL (the '[hostname]:[port]' portion).java.lang.StringgetHostname()Returns the hostname portion of the location URL.java.lang.StringgetHref()Returns the location URL.java.lang.StringgetOrigin()Returns theoriginproperty.java.lang.StringgetPathname()Returns the pathname portion of the location URL.java.lang.StringgetPort()Returns the port portion of the location URL.java.lang.StringgetProtocol()Returns the protocol portion of the location URL, including the trailing ':'.java.lang.StringgetSearch()Returns the search portion of the location URL (the portion following the '?').private java.net.URLgetUrl()Returns this location's current URL.voidinitialize(Window window, Page page)Initializes this Location.voidjsConstructor()Creates an instance.java.lang.StringjsToString()Returns the location URL.voidreload(boolean force)Reloads the current page, possibly forcing retrieval from the server even if the browser cache contains the latest version of the document.voidreplace(java.lang.String url)Reloads the window using the specified URL via a postponed action.voidsetHash(java.lang.String hash)Sets the hash portion of the location URL (the portion following the '#').voidsetHash(java.lang.String oldURL, java.lang.String hash)Sets the hash portion of the location URL (the portion following the '#').voidsetHash(java.lang.String oldURL, java.lang.String hash, boolean triggerHashChanged)INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Sets the hash portion of the location URL (the portion following the '#').voidsetHost(java.lang.String host)Sets the host portion of the location URL (the '[hostname]:[port]' portion).voidsetHostname(java.lang.String hostname)Sets the hostname portion of the location URL.voidsetHref(java.lang.String newLocation)Sets the location URL to an entirely new value.voidsetPathname(java.lang.String pathname)Sets the pathname portion of the location URL.voidsetPort(java.lang.String port)Sets the port portion of the location URL.voidsetProtocol(java.lang.String protocol)Sets the protocol portion of the location URL.voidsetSearch(java.lang.String search)Sets the search portion of the location URL (the portion following the '?').private voidsetUrl(java.net.URL url)Sets this location's URL, triggering a server hit and loading the resultant document into this location's window.-
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 Detail
-
LOG
private static final org.apache.commons.logging.Log LOG
-
UNKNOWN
private static final java.lang.String UNKNOWN
- See Also:
- Constant Field Values
-
window_
private Window window_
The window which owns this location object.
-
methodAssign
private static final java.lang.reflect.Method methodAssign
-
methodReload
private static final java.lang.reflect.Method methodReload
-
methodReplace
private static final java.lang.reflect.Method methodReplace
-
methodToString
private static final java.lang.reflect.Method methodToString
-
getterHash
private static final java.lang.reflect.Method getterHash
-
setterHash
private static final java.lang.reflect.Method setterHash
-
getterHost
private static final java.lang.reflect.Method getterHost
-
setterHost
private static final java.lang.reflect.Method setterHost
-
getterHostname
private static final java.lang.reflect.Method getterHostname
-
setterHostname
private static final java.lang.reflect.Method setterHostname
-
getterHref
private static final java.lang.reflect.Method getterHref
-
setterHref
private static final java.lang.reflect.Method setterHref
-
getterOrigin
private static final java.lang.reflect.Method getterOrigin
-
getterPathname
private static final java.lang.reflect.Method getterPathname
-
setterPathname
private static final java.lang.reflect.Method setterPathname
-
getterPort
private static final java.lang.reflect.Method getterPort
-
setterPort
private static final java.lang.reflect.Method setterPort
-
getterProtocol
private static final java.lang.reflect.Method getterProtocol
-
setterProtocol
private static final java.lang.reflect.Method setterProtocol
-
getterSearch
private static final java.lang.reflect.Method getterSearch
-
setterSearch
private static final java.lang.reflect.Method setterSearch
-
hash_
private java.lang.String hash_
The current hash; we cache it locally because we don't want to modify the page's URL and force a page reload each time this changes.
-
-
Method Detail
-
jsConstructor
public void jsConstructor()
Creates an instance.
-
initialize
public void initialize(Window window, Page page)
Initializes this Location.- Parameters:
window- the window that this location belongs topage- the page that will become the enclosing page
-
getDefaultValue
public java.lang.Object getDefaultValue(java.lang.Class<?> hint)
Returns the JavaScript default value of this object. This is the JavaScript equivalent of a toString() in Java.- Specified by:
getDefaultValuein interfaceorg.htmlunit.corejs.javascript.Scriptable- Overrides:
getDefaultValuein classHtmlUnitScriptable- Parameters:
hint- a hint as to the format of the default value (ignored in this case)- Returns:
- the default value
-
assign
public void assign(java.lang.String url) throws java.io.IOExceptionLoads the new HTML document corresponding to the specified URL.- Parameters:
url- the location of the new HTML document to load- Throws:
java.io.IOException- if loading the specified location fails- See Also:
- MSDN Documentation
-
reload
public void reload(boolean force) throws java.io.IOExceptionReloads the current page, possibly forcing retrieval from the server even if the browser cache contains the latest version of the document.- Parameters:
force- iftrue, force reload from server; otherwise, may reload from cache- Throws:
java.io.IOException- if there is a problem reloading the page- See Also:
- MSDN Documentation
-
replace
public void replace(java.lang.String url) throws java.io.IOExceptionReloads the window using the specified URL via a postponed action.- Parameters:
url- the new URL to use to reload the window- Throws:
java.io.IOException- if loading the specified location fails- See Also:
- MSDN Documentation
-
jsToString
public java.lang.String jsToString()
Returns the location URL.- Returns:
- the location URL
-
getHref
public java.lang.String getHref()
Returns the location URL.- Returns:
- the location URL
- See Also:
- MSDN Documentation
-
setHref
public void setHref(java.lang.String newLocation) throws java.io.IOExceptionSets the location URL to an entirely new value.- Parameters:
newLocation- the new location URL- Throws:
java.io.IOException- if loading the specified location fails- See Also:
- MSDN Documentation
-
getSearch
public java.lang.String getSearch()
Returns the search portion of the location URL (the portion following the '?').- Returns:
- the search portion of the location URL
- See Also:
- MSDN Documentation
-
setSearch
public void setSearch(java.lang.String search) throws java.lang.ExceptionSets the search portion of the location URL (the portion following the '?').- Parameters:
search- the new search portion of the location URL- Throws:
java.lang.Exception- if an error occurs- See Also:
- MSDN Documentation
-
getHash
public java.lang.String getHash()
Returns the hash portion of the location URL (the portion following the '#').- Returns:
- the hash portion of the location URL
- See Also:
- MSDN Documentation
-
getHash
private java.lang.String getHash(boolean encoded)
-
setHash
public void setHash(java.lang.String hash)
Sets the hash portion of the location URL (the portion following the '#').- Parameters:
hash- the new hash portion of the location URL- See Also:
- MSDN Documentation
-
setHash
public void setHash(java.lang.String oldURL, java.lang.String hash)Sets the hash portion of the location URL (the portion following the '#').- Parameters:
oldURL- the old URLhash- the new hash portion of the location URL
-
setHash
public void setHash(java.lang.String oldURL, java.lang.String hash, boolean triggerHashChanged)INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Sets the hash portion of the location URL (the portion following the '#').- Parameters:
oldURL- the old URLhash- the new hash portion of the location URLtriggerHashChanged- option to disable event triggering
-
decodeHash
private static java.lang.String decodeHash(java.lang.String hash)
-
getHostname
public java.lang.String getHostname()
Returns the hostname portion of the location URL.- Returns:
- the hostname portion of the location URL
- See Also:
- MSDN Documentation
-
setHostname
public void setHostname(java.lang.String hostname) throws java.lang.ExceptionSets the hostname portion of the location URL.- Parameters:
hostname- the new hostname portion of the location URL- Throws:
java.lang.Exception- if an error occurs- See Also:
- MSDN Documentation
-
getHost
public java.lang.String getHost()
Returns the host portion of the location URL (the '[hostname]:[port]' portion).- Returns:
- the host portion of the location URL
- See Also:
- MSDN Documentation
-
setHost
public void setHost(java.lang.String host) throws java.lang.ExceptionSets the host portion of the location URL (the '[hostname]:[port]' portion).- Parameters:
host- the new host portion of the location URL- Throws:
java.lang.Exception- if an error occurs- See Also:
- MSDN Documentation
-
getPathname
public java.lang.String getPathname()
Returns the pathname portion of the location URL.- Returns:
- the pathname portion of the location URL
- See Also:
- MSDN Documentation
-
setPathname
public void setPathname(java.lang.String pathname) throws java.lang.ExceptionSets the pathname portion of the location URL.- Parameters:
pathname- the new pathname portion of the location URL- Throws:
java.lang.Exception- if an error occurs- See Also:
- MSDN Documentation
-
getPort
public java.lang.String getPort()
Returns the port portion of the location URL.- Returns:
- the port portion of the location URL
- See Also:
- MSDN Documentation
-
setPort
public void setPort(java.lang.String port) throws java.lang.ExceptionSets the port portion of the location URL.- Parameters:
port- the new port portion of the location URL- Throws:
java.lang.Exception- if an error occurs- See Also:
- MSDN Documentation
-
getProtocol
public java.lang.String getProtocol()
Returns the protocol portion of the location URL, including the trailing ':'.- Returns:
- the protocol portion of the location URL, including the trailing ':'
- See Also:
- MSDN Documentation
-
setProtocol
public void setProtocol(java.lang.String protocol) throws java.lang.ExceptionSets the protocol portion of the location URL.- Parameters:
protocol- the new protocol portion of the location URL- Throws:
java.lang.Exception- if an error occurs- See Also:
- MSDN Documentation
-
getUrl
private java.net.URL getUrl()
Returns this location's current URL.- Returns:
- this location's current URL
-
setUrl
private void setUrl(java.net.URL url) throws java.io.IOExceptionSets this location's URL, triggering a server hit and loading the resultant document into this location's window.- Parameters:
url- This location's new URL- Throws:
java.io.IOException- if there is a problem loading the new location
-
getOrigin
public java.lang.String getOrigin()
Returns theoriginproperty.- Returns:
- the
originproperty
-
-