com.gargoylesoftware.htmlunit.javascript.host
Class Location

java.lang.Object
  extended by net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
      extended by com.gargoylesoftware.htmlunit.javascript.SimpleScriptable
          extended by com.gargoylesoftware.htmlunit.javascript.host.Location
All Implemented Interfaces:
Serializable, Cloneable, net.sourceforge.htmlunit.corejs.javascript.ConstProperties, net.sourceforge.htmlunit.corejs.javascript.debug.DebuggableObject, net.sourceforge.htmlunit.corejs.javascript.Scriptable

public class Location
extends SimpleScriptable

A JavaScript object for a Location.

Version:
$Revision: 7605 $
Author:
Mike Bowler, Michael Ottati, Marc Guillemot, Chris Erskine, Daniel Gredler, David K. Taylor, Ahmed Ashour, Ronald Brill
See Also:
MSDN Documentation, Serialized Form

Field Summary
 
Fields inherited from class net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST
 
Fields inherited from interface net.sourceforge.htmlunit.corejs.javascript.Scriptable
NOT_FOUND
 
Constructor Summary
Location()
          Creates an instance.
 
Method Summary
 void assign(String url)
          Loads the new HTML document corresponding to the specified URL.
 Object getDefaultValue(Class<?> hint)
          Returns the JavaScript default value of this object.
 String getHash()
          Returns the hash portion of the location URL (the portion following the '#').
 String getHost()
          Returns the host portion of the location URL (the '[hostname]:[port]' portion).
 String getHostname()
          Returns the hostname portion of the location URL.
 String getHref()
          Returns the location URL.
 String getPathname()
          Returns the pathname portion of the location URL.
 String getPort()
          Returns the port portion of the location URL.
 String getProtocol()
          Returns the protocol portion of the location URL, including the trailing ':'.
 String getSearch()
          Returns the search portion of the location URL (the portion following the '?').
 void initialize(Window window)
          Initializes the object.
 void reload(boolean force)
          Reloads the current page, possibly forcing retrieval from the server even if the browser cache contains the latest version of the document.
 void replace(String url)
          Reloads the window using the specified URL via a postponed action.
 void setHash(String hash)
          Sets the hash portion of the location URL (the portion following the '#').
 void setHost(String host)
          Sets the host portion of the location URL (the '[hostname]:[port]' portion).
 void setHostname(String hostname)
          Sets the hostname portion of the location URL.
 void setHref(String newLocation)
          Sets the location URL to an entirely new value.
 void setPathname(String pathname)
          Sets the pathname portion of the location URL.
 void setPort(String port)
          Sets the port portion of the location URL.
 void setProtocol(String protocol)
          Sets the protocol portion of the location URL.
 void setSearch(String search)
          Sets the search portion of the location URL (the portion following the '?').
 String toString()
          Returns the location URL.
 
Methods inherited from class com.gargoylesoftware.htmlunit.javascript.SimpleScriptable
clone, defineFunctionProperties, defineProperty, equivalentValues, get, getBrowserVersion, getClassName, getDomNodeOrDie, getDomNodeOrNull, getPrototype, getScriptableFor, getStartingScope, getTransformerScriptableFor, getWindow, getWindow, getWithPreemption, hasInstance, initParentScope, isReadOnlySettable, makeScriptableFor, setCaseSensitive, setDomNode, setDomNode, setHtmlElement
 
Methods inherited from class net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, delete, delete, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getSlot, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, has, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putProperty, putProperty, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setGetterOrSetter, setParentScope, setPrototype, size
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Location

public Location()
Creates an instance. JavaScript objects must have a default constructor.

Method Detail

initialize

public void initialize(Window window)
Initializes the object.

Parameters:
window - the window that this location belongs to

getDefaultValue

public Object getDefaultValue(Class<?> hint)
Returns the JavaScript default value of this object. This is the JavaScript equivalent of a toString() in Java.

Specified by:
getDefaultValue in interface net.sourceforge.htmlunit.corejs.javascript.Scriptable
Overrides:
getDefaultValue in class SimpleScriptable
Parameters:
hint - a hint as to the format of the default value (ignored in this case)
Returns:
the default value

assign

public void assign(String url)
            throws IOException
Loads the new HTML document corresponding to the specified URL.

Parameters:
url - the location of the new HTML document to load
Throws:
IOException - if loading the specified location fails
See Also:
MSDN Documentation

reload

public void reload(boolean force)
            throws IOException
Reloads the current page, possibly forcing retrieval from the server even if the browser cache contains the latest version of the document.

Parameters:
force - if true, force reload from server; otherwise, may reload from cache
Throws:
IOException - if there is a problem reloading the page
See Also:
MSDN Documentation

replace

public void replace(String url)
             throws IOException
Reloads the window using the specified URL via a postponed action.

Parameters:
url - the new URL to use to reload the window
Throws:
IOException - if loading the specified location fails
See Also:
MSDN Documentation

toString

public String toString()
Returns the location URL.

Overrides:
toString in class Object
Returns:
the location URL

getHref

public String getHref()
Returns the location URL.

Returns:
the location URL
See Also:
MSDN Documentation

setHref

public void setHref(String newLocation)
             throws IOException
Sets the location URL to an entirely new value.

Parameters:
newLocation - the new location URL
Throws:
IOException - if loading the specified location fails
See Also:
MSDN Documentation

getSearch

public 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(String search)
               throws Exception
Sets the search portion of the location URL (the portion following the '?').

Parameters:
search - the new search portion of the location URL
Throws:
Exception - if an error occurs
See Also:
MSDN Documentation

getHash

public 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

setHash

public void setHash(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

getHostname

public 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(String hostname)
                 throws Exception
Sets the hostname portion of the location URL.

Parameters:
hostname - the new hostname portion of the location URL
Throws:
Exception - if an error occurs
See Also:
MSDN Documentation

getHost

public 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(String host)
             throws Exception
Sets the host portion of the location URL (the '[hostname]:[port]' portion).

Parameters:
host - the new host portion of the location URL
Throws:
Exception - if an error occurs
See Also:
MSDN Documentation

getPathname

public 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(String pathname)
                 throws Exception
Sets the pathname portion of the location URL.

Parameters:
pathname - the new pathname portion of the location URL
Throws:
Exception - if an error occurs
See Also:
MSDN Documentation

getPort

public 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(String port)
             throws Exception
Sets the port portion of the location URL.

Parameters:
port - the new port portion of the location URL
Throws:
Exception - if an error occurs
See Also:
MSDN Documentation

getProtocol

public 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(String protocol)
                 throws Exception
Sets the protocol portion of the location URL.

Parameters:
protocol - the new protocol portion of the location URL
Throws:
Exception - if an error occurs
See Also:
MSDN Documentation


Copyright © 2002-2012 Gargoyle Software Inc.. All Rights Reserved.