com.gargoylesoftware.htmlunit.javascript.host
Class ApplicationCache

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.ApplicationCache
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 ApplicationCache
extends SimpleScriptable

A collection of offline resources as defined in the HTML5 spec. Intended to support offline web applications.

NOTE: This class is essentially a skeleton implementation providing minimal compatibility while we wait for the HTML5 dust to settle. The first real browser we should worry about supporting with this implementation will probably be either Firefox 3.5 or Firefox 4.

Version:
$Revision: 8948 $
Author:
Daniel Gredler, Frank Danek
See Also:
HTML5 spec, Offline Resources in Firefox, Mozilla Documentation, Serialized Form

Field Summary
static short STATUS_CHECKING
          The application cache manifest is being fetched and checked for updates.
static short STATUS_DOWNLOADING
          Resources are being downloaded to be added to the cache.
static short STATUS_IDLE
          The application cache is not in the process of being updated.
static short STATUS_OBSOLETE
          The application cache group is now obsolete.
static short STATUS_UNCACHED
          The object isn't associated with an application cache.
static short STATUS_UPDATEREADY
          There is a new version of the application cache available.
 
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
ApplicationCache()
           
 
Method Summary
 void add(String uri)
          Adds an item to the dynamically managed entries.
 String getClassName()
          Returns the JavaScript class name.
 int getLength()
          Returns the number of entries in the dynamically managed offline resource list.
 Object getOncached()
          Returns the event listener to be called when caching is complete.
 Object getOnchecking()
          Returns the event listener to be called when fetching the application cache manifest and checking for updates.
 Object getOndownloading()
          Returns the event listener to be called when resources are being downloaded into the cache.
 Object getOnerror()
          Returns the event listener to be called when an error occurs during the caching process.
 Object getOnnoupdate()
          Returns the event listener to be called when there is no update to download.
 Object getOnprogress()
          Returns the event listener to be called periodically throughout the download process.
 Object getOnupdateready()
          Returns the event listener to be called when a resource update is ready.
 short getStatus()
          Returns the status of the application cache.
 boolean hasItem(String uri)
          Returns true if the specified URI represents a resource that's in the application cache's list.
 String item(int index)
          Returns the URI of the item at the specific offset into the list of cached resources.
 void remove(String uri)
          Removes an item from the list of dynamically managed entries.
 void setOncached(Object o)
          Sets the event listener to be called when caching is complete.
 void setOnchecking(Object o)
          Sets the event listener to be called when fetching the application cache manifest and checking for updates.
 void setOndownloading(Object o)
          Sets the event listener to be called when resources are being downloaded into the cache.
 void setOnerror(Object o)
          Sets the event listener to be called when an error occurs during the caching process.
 void setOnnoupdate(Object o)
          Sets the event listener to be called when there is no update to download.
 void setOnprogress(Object o)
          Sets the event listener to be called periodically throughout the download process.
 void setOnupdateready(Object o)
          Sets the event listener to be called when a resource update is ready.
 void swapCache()
          Swaps in the newest version of the application cache.
 void update()
          Begins the application cache update process.
 
Methods inherited from class com.gargoylesoftware.htmlunit.javascript.SimpleScriptable
clone, defineFunctionProperties, defineProperty, equivalentValues, get, getBrowserVersion, getDefaultValue, getDomNodeOrDie, getDomNodeOrNull, getPrototype, getScriptableFor, getStartingScope, getTransformerScriptableFor, getWindow, getWindow, getWithPreemption, hasInstance, initParentScope, isReadOnlySettable, makeScriptableFor, setCaseSensitive, setDomNode, setDomNode, setHtmlElement, setParentScope
 
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, setPrototype, size
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATUS_UNCACHED

public static final short STATUS_UNCACHED
The object isn't associated with an application cache.

See Also:
Constant Field Values

STATUS_IDLE

public static final short STATUS_IDLE
The application cache is not in the process of being updated.

See Also:
Constant Field Values

STATUS_CHECKING

public static final short STATUS_CHECKING
The application cache manifest is being fetched and checked for updates.

See Also:
Constant Field Values

STATUS_DOWNLOADING

public static final short STATUS_DOWNLOADING
Resources are being downloaded to be added to the cache.

See Also:
Constant Field Values

STATUS_UPDATEREADY

public static final short STATUS_UPDATEREADY
There is a new version of the application cache available.

See Also:
Constant Field Values

STATUS_OBSOLETE

public static final short STATUS_OBSOLETE
The application cache group is now obsolete.

See Also:
Constant Field Values
Constructor Detail

ApplicationCache

public ApplicationCache()
Method Detail

getClassName

public String getClassName()
Returns the JavaScript class name.

Specified by:
getClassName in interface net.sourceforge.htmlunit.corejs.javascript.Scriptable
Overrides:
getClassName in class SimpleScriptable
Returns:
the JavaScript class name

getOnchecking

public Object getOnchecking()
Returns the event listener to be called when fetching the application cache manifest and checking for updates.

Returns:
the event listener to be called when fetching the application cache manifest and checking for updates

setOnchecking

public void setOnchecking(Object o)
Sets the event listener to be called when fetching the application cache manifest and checking for updates.

Parameters:
o - the event listener to be called when fetching the application cache manifest and checking for updates

getOnerror

public Object getOnerror()
Returns the event listener to be called when an error occurs during the caching process.

Returns:
the event listener to be called when an error occurs during the caching process

setOnerror

public void setOnerror(Object o)
Sets the event listener to be called when an error occurs during the caching process.

Parameters:
o - the event listener to be called when an error occurs during the caching process

getOnnoupdate

public Object getOnnoupdate()
Returns the event listener to be called when there is no update to download.

Returns:
the event listener to be called when there is no update to download

setOnnoupdate

public void setOnnoupdate(Object o)
Sets the event listener to be called when there is no update to download.

Parameters:
o - the event listener to be called when there is no update to download

getOndownloading

public Object getOndownloading()
Returns the event listener to be called when resources are being downloaded into the cache.

Returns:
the event listener to be called when resources are being downloaded into the cache

setOndownloading

public void setOndownloading(Object o)
Sets the event listener to be called when resources are being downloaded into the cache.

Parameters:
o - the event listener to be called when resources are being downloaded into the cache

getOnprogress

public Object getOnprogress()
Returns the event listener to be called periodically throughout the download process.

Returns:
the event listener to be called periodically throughout the download process

setOnprogress

public void setOnprogress(Object o)
Sets the event listener to be called periodically throughout the download process.

Parameters:
o - the event listener to be called periodically throughout the download process

getOnupdateready

public Object getOnupdateready()
Returns the event listener to be called when a resource update is ready.

Returns:
the event listener to be called when a resource update is ready

setOnupdateready

public void setOnupdateready(Object o)
Sets the event listener to be called when a resource update is ready.

Parameters:
o - the event listener to be called when a resource update is ready

getOncached

public Object getOncached()
Returns the event listener to be called when caching is complete.

Returns:
the event listener to be called when caching is complete

setOncached

public void setOncached(Object o)
Sets the event listener to be called when caching is complete.

Parameters:
o - the event listener to be called when caching is complete

getStatus

public short getStatus()
Returns the status of the application cache.

Returns:
the status of the application cache

getLength

public int getLength()
Returns the number of entries in the dynamically managed offline resource list.

Returns:
the number of entries in the dynamically managed offline resource list

add

public void add(String uri)
Adds an item to the dynamically managed entries. The resource will be fetched and added to the application cache.

Parameters:
uri - the URI of the item to add to the dynamically managed entries

hasItem

public boolean hasItem(String uri)
Returns true if the specified URI represents a resource that's in the application cache's list.

Parameters:
uri - the URI to check
Returns:
true if the specified URI represents a resource that's in the application cache's list

item

public String item(int index)
Returns the URI of the item at the specific offset into the list of cached resources.

Parameters:
index - the index of the cached item whose URI should be returned
Returns:
the URI of the item at the specific offset into the list of cached resources

remove

public void remove(String uri)
Removes an item from the list of dynamically managed entries. If this was the last reference to the given URI in the application cache, the cache entry is removed.

Parameters:
uri - the URI to remove

swapCache

public void swapCache()
Swaps in the newest version of the application cache.


update

public void update()
Begins the application cache update process.



Copyright © 2002–2014 Gargoyle Software Inc.. All rights reserved.