com.gargoylesoftware.htmlunit.javascript.configuration
Class JavaScriptConfiguration

java.lang.Object
  extended by com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfiguration

public final class JavaScriptConfiguration
extends Object

A container for all the JavaScript configuration information. TODO - Need to add the logic to support the browser and JavaScript conditionals in the Class elements.

Version:
$Revision: 5754 $
Author:
Mike Bowler, Chris Erskine, Ahmed Ashour

Field Summary
static int DISABLED
          Constant indicating that this function/property is not used by the specified browser version.
static int ENABLED
          Constant indicating that this function/property is used by the specified browser version.
static int NOT_FOUND
          Constant indicating that this function/property is not defined in the configuration file.
 
Method Summary
protected  boolean classConfigEquals(String classname, ClassConfiguration config)
          Test to see if the supplied configuration matches for the parsed configuration for the named class This is a method for testing.
 ClassConfiguration getClassConfiguration(String classname)
          Gets the class configuration for the supplied JavaScript class name.
protected  Class<?> getClassObject(String classname)
          Returns the class for the given class name.
 Method getFunctionMethod(Class<?> clazz, String functionName)
          Gets the method that implements the setter for the given property based upon the class object.
 Method getFunctionMethod(String classname, String functionName)
          Returns the method that implements the given function in the class for the given class.
static Map<Class<? extends HtmlElement>,Class<? extends SimpleScriptable>> getHtmlJavaScriptMapping()
          Returns an immutable map containing the HTML to JavaScript mappings.
static JavaScriptConfiguration getInstance(BrowserVersion browserVersion)
          Returns the instance that represents the configuration for the specified BrowserVersion.
 Method getPropertyReadMethod(Class<?> clazz, String propertyName)
          Gets the method that implements the getter for the given property based upon the class object.
 Method getPropertyReadMethod(String classname, String propertyName)
          Returns the method that implements the get function for in the class for the given class.
 Method getPropertyWriteMethod(Class<?> clazz, String propertyName)
          Gets the method that implements the setter for the given property based upon the class object.
 Method getPropertyWriteMethod(String classname, String propertyName)
          Returns the method that implements the set function in the class for the given class.
protected static boolean isDocumentLoaded()
          Test for a configuration having been loaded for testing.
 Set<String> keySet()
          Gets the set of keys for the class configurations.
protected static void loadConfiguration()
          Gets the configuration file and make it an input reader and then pass to the method to read the file.
protected static void loadConfiguration(Reader configurationReader)
          Loads the configuration from a supplied Reader.
 boolean propertyExists(Class<?> clazz, String propertyName)
          Checks to see if there is an entry for the given property.
 boolean propertyExists(String classname, String propertyName)
          Checks to see if there is an entry for the given property.
protected static void resetClassForTesting()
          Resets this class to its initial state.
protected static void setXmlDocument(Document document)
          Sets the document configuration for testing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ENABLED

public static final int ENABLED
Constant indicating that this function/property is used by the specified browser version.

See Also:
Constant Field Values

DISABLED

public static final int DISABLED
Constant indicating that this function/property is not used by the specified browser version.

See Also:
Constant Field Values

NOT_FOUND

public static final int NOT_FOUND
Constant indicating that this function/property is not defined in the configuration file.

See Also:
Constant Field Values
Method Detail

isDocumentLoaded

protected static boolean isDocumentLoaded()
Test for a configuration having been loaded for testing.

Returns:
boolean - true if the XmlDocument has been loaded;

resetClassForTesting

protected static void resetClassForTesting()
Resets this class to its initial state. This method is used for testing only.


setXmlDocument

protected static void setXmlDocument(Document document)
Sets the document configuration for testing.

Parameters:
document - - The configuration document

loadConfiguration

protected static void loadConfiguration()
Gets the configuration file and make it an input reader and then pass to the method to read the file.


loadConfiguration

protected static void loadConfiguration(Reader configurationReader)
Loads the configuration from a supplied Reader.

Parameters:
configurationReader - - A reader pointing to the configuration

getInstance

public static JavaScriptConfiguration getInstance(BrowserVersion browserVersion)
Returns the instance that represents the configuration for the specified BrowserVersion. This method is synchronized to allow multithreaded access to the JavaScript configuration.

Parameters:
browserVersion - the BrowserVersion
Returns:
the instance for the specified BrowserVersion

keySet

public Set<String> keySet()
Gets the set of keys for the class configurations.

Returns:
the set of keys for the class configurations

classConfigEquals

protected boolean classConfigEquals(String classname,
                                    ClassConfiguration config)
Test to see if the supplied configuration matches for the parsed configuration for the named class This is a method for testing.

Parameters:
classname - - the parsed classname to test
config - - the expected configuration
Returns:
true if they match

getClassConfiguration

public ClassConfiguration getClassConfiguration(String classname)
Gets the class configuration for the supplied JavaScript class name.

Parameters:
classname - the js class name
Returns:
the class configuration for the supplied JavaScript class name

getClassObject

protected Class<?> getClassObject(String classname)
Returns the class for the given class name.

Parameters:
classname - the classname that you want the implementing class for (for testing only)
Returns:
the class for the given class name

getPropertyReadMethod

public Method getPropertyReadMethod(Class<?> clazz,
                                    String propertyName)
Gets the method that implements the getter for the given property based upon the class object.

Parameters:
clazz - the actual class to use as reference
propertyName - the property to find the getter for
Returns:
the method that implements the getter for the given property based upon the class object

getPropertyReadMethod

public Method getPropertyReadMethod(String classname,
                                    String propertyName)
Returns the method that implements the get function for in the class for the given class.

Parameters:
classname - the name of the class to work with
propertyName - the property to find the getter for
Returns:
the method that implements the get function for in the class for the given class

getPropertyWriteMethod

public Method getPropertyWriteMethod(Class<?> clazz,
                                     String propertyName)
Gets the method that implements the setter for the given property based upon the class object.

Parameters:
clazz - the actual class to use as reference
propertyName - the property to find the getter for
Returns:
the method that implements the setter for the given property based upon the class object

getPropertyWriteMethod

public Method getPropertyWriteMethod(String classname,
                                     String propertyName)
Returns the method that implements the set function in the class for the given class.

Parameters:
classname - the name of the class to work with
propertyName - the property to find the setter for
Returns:
the method that implements the set function in the class for the given class

getFunctionMethod

public Method getFunctionMethod(Class<?> clazz,
                                String functionName)
Gets the method that implements the setter for the given property based upon the class object.

Parameters:
clazz - the actual class to use as reference
functionName - the function to find the method for
Returns:
the method that implements the setter for the given property based upon the class object

getFunctionMethod

public Method getFunctionMethod(String classname,
                                String functionName)
Returns the method that implements the given function in the class for the given class.

Parameters:
classname - the name of the class to work with
functionName - the function to find the method for
Returns:
the method that implements the given function in the class for the given class

propertyExists

public boolean propertyExists(Class<?> clazz,
                              String propertyName)
Checks to see if there is an entry for the given property.

Parameters:
clazz - the class the property is for
propertyName - the name of the property
Returns:
boolean true if the property exists

propertyExists

public boolean propertyExists(String classname,
                              String propertyName)
Checks to see if there is an entry for the given property.

Parameters:
classname - the class the property is for
propertyName - the name of the property
Returns:
boolean true if the property exists

getHtmlJavaScriptMapping

public static Map<Class<? extends HtmlElement>,Class<? extends SimpleScriptable>> getHtmlJavaScriptMapping()
Returns an immutable map containing the HTML to JavaScript mappings. Keys are java classes for the various HTML classes (ie HtmlInput.class) and the values are the JavaScript class names (ie "HTMLAnchorElement").

Returns:
the mappings


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