htmlunit-2.7

16:36:30.943 INFO  jd.cli.Main - Decompiling htmlunit-2.7.jar
package com.gargoylesoftware.htmlunit.javascript.configuration;

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;

public class ClassConfiguration$PropertyInfo
{
  private boolean readable_ = false;
  private boolean writeable_ = false;
  private boolean hasBrowsers_ = false;
  private Map<String, ClassConfiguration.BrowserInfo> browserMap_;
  private Method readMethod_;
  private Method writeMethod_;
  
  protected ClassConfiguration$PropertyInfo(ClassConfiguration paramClassConfiguration) {}
  
  public Method getReadMethod()
  {
    return readMethod_;
  }
  
  public void setReadMethod(Method readMethod)
  {
    readMethod_ = readMethod;
  }
  
  public Method getWriteMethod()
  {
    return writeMethod_;
  }
  
  public void setWriteMethod(Method writeMethod)
  {
    writeMethod_ = writeMethod;
  }
  
  private void setBrowser(ClassConfiguration.BrowserInfo browserInfo)
  {
    if (browserMap_ == null)
    {
      hasBrowsers_ = true;
      browserMap_ = new HashMap();
    }
    browserMap_.put(ClassConfiguration.BrowserInfo.access$700(browserInfo), browserInfo);
  }
  
  private boolean valueEquals(Object obj)
  {
    if (!(obj instanceof PropertyInfo)) {
      return false;
    }
    PropertyInfo info = (PropertyInfo)obj;
    if (hasBrowsers_ != hasBrowsers_) {
      return false;
    }
    if (hasBrowsers_)
    {
      if (browserMap_.size() != browserMap_.size()) {
        return false;
      }
      for (String key : browserMap_.keySet()) {
        if (!ClassConfiguration.BrowserInfo.access$800((ClassConfiguration.BrowserInfo)browserMap_.get(key), browserMap_.get(key))) {
          return false;
        }
      }
    }
    return (readable_ == readable_) && (writeable_ == writeable_);
  }
  
  private void setReadable(boolean readable)
  {
    readable_ = readable;
  }
  
  private void setWriteable(boolean writeable)
  {
    writeable_ = writeable;
  }
}

/* Location:
 * Qualified Name:     com.gargoylesoftware.htmlunit.javascript.configuration.ClassConfiguration.PropertyInfo
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.gargoylesoftware.htmlunit.javascript.configuration;

import java.lang.reflect.Method;
import java.util.Map;

class ClassConfiguration$FunctionInfo
{
  private boolean hasBrowsers_ = false;
  private Map<String, ClassConfiguration.BrowserInfo> browserMap_;
  private Method functionMethod_;
  
  private ClassConfiguration$FunctionInfo(ClassConfiguration paramClassConfiguration) {}
  
  private boolean valueEquals(Object obj)
  {
    if (!(obj instanceof FunctionInfo)) {
      return false;
    }
    FunctionInfo info = (FunctionInfo)obj;
    if (hasBrowsers_ != hasBrowsers_) {
      return false;
    }
    if (hasBrowsers_)
    {
      if (browserMap_.size() != browserMap_.size()) {
        return false;
      }
      for (String key : browserMap_.keySet()) {
        if (ClassConfiguration.BrowserInfo.access$800((ClassConfiguration.BrowserInfo)browserMap_.get(key), browserMap_.get(key))) {
          return false;
        }
      }
    }
    return true;
  }
  
  public Method getFunctionMethod()
  {
    return functionMethod_;
  }
  
  public void setFunctionMethod(Method functionMethod)
  {
    functionMethod_ = functionMethod;
  }
}

/* Location:
 * Qualified Name:     com.gargoylesoftware.htmlunit.javascript.configuration.ClassConfiguration.FunctionInfo
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.gargoylesoftware.htmlunit.javascript.configuration;

final class ClassConfiguration$BrowserInfo
{
  private String browserName_;
  private String minVersion_;
  private String maxVersion_;
  private String lessThanVersion_;
  
  private boolean valueEquals(Object obj)
  {
    if (!(obj instanceof BrowserInfo)) {
      return false;
    }
    BrowserInfo info = (BrowserInfo)obj;
    if ((minVersion_ != null) && (!minVersion_.equals(minVersion_))) {
      return false;
    }
    if ((maxVersion_ != null) && (!maxVersion_.equals(maxVersion_))) {
      return false;
    }
    if ((lessThanVersion_ != null) && (!lessThanVersion_.equals(lessThanVersion_))) {
      return false;
    }
    return browserName_ == browserName_;
  }
  
  private ClassConfiguration$BrowserInfo(ClassConfiguration paramClassConfiguration, String browserName)
  {
    browserName_ = browserName;
  }
  
  private String getBrowserName()
  {
    return browserName_;
  }
}

/* Location:
 * Qualified Name:     com.gargoylesoftware.htmlunit.javascript.configuration.ClassConfiguration.BrowserInfo
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.gargoylesoftware.htmlunit.javascript.configuration;

class ClassConfiguration$1 {}

/* Location:
 * Qualified Name:     com.gargoylesoftware.htmlunit.javascript.configuration.ClassConfiguration.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.gargoylesoftware.htmlunit.javascript.configuration;

import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

public final class ClassConfiguration
{
  private static final String GETTER_PREFIX = "jsxGet_";
  private static final String SETTER_PREFIX = "jsxSet_";
  private static final String FUNCTION_PREFIX = "jsxFunction_";
  private Map<String, PropertyInfo> propertyMap_ = new HashMap();
  private Map<String, FunctionInfo> functionMap_ = new HashMap();
  private List<String> constants_ = new ArrayList();
  private String extendedClass_;
  private final String className_;
  private final Class<? extends SimpleScriptable> linkedClass_;
  private final Method jsConstructor_;
  private final String htmlClassname_;
  private final boolean jsObject_;
  
  public ClassConfiguration(String classname, String implementingClass, String jsConstructor, String extendedClass, String htmlClass, boolean jsObject)
    throws ClassNotFoundException
  {
    className_ = classname;
    extendedClass_ = extendedClass;
    linkedClass_ = Class.forName(implementingClass);
    if ((jsConstructor != null) && (jsConstructor.length() != 0))
    {
      Method foundCtor = null;
      for (Method method : linkedClass_.getMethods()) {
        if (method.getName().equals(jsConstructor))
        {
          foundCtor = method;
          break;
        }
      }
      if (foundCtor == null) {
        throw new IllegalStateException("Constructor method \"" + jsConstructor + "\" in class \"" + implementingClass + " is not found.");
      }
      jsConstructor_ = foundCtor;
    }
    else
    {
      jsConstructor_ = null;
    }
    jsObject_ = jsObject;
    if ((htmlClass != null) && (htmlClass.length() != 0)) {
      htmlClassname_ = htmlClass;
    } else {
      htmlClassname_ = null;
    }
  }
  
  public String getClassName()
  {
    return className_;
  }
  
  public void addProperty(String name, boolean readable, boolean writeable)
  {
    PropertyInfo info = new PropertyInfo();
    info.setReadable(readable);
    info.setWriteable(writeable);
    try
    {
      if (readable) {
        info.setReadMethod(linkedClass_.getMethod("jsxGet_" + name, (Class[])null));
      }
    }
    catch (NoSuchMethodException e)
    {
      throw new IllegalStateException("Method 'jsxGet_" + name + "' was not found for " + name + " property in " + linkedClass_.getName());
    }
    if (writeable)
    {
      String setMethodName = "jsxSet_" + name;
      for (Method method : linkedClass_.getMethods()) {
        if ((method.getName().equals(setMethodName)) && (method.getParameterTypes().length == 1))
        {
          info.setWriteMethod(method);
          break;
        }
      }
      if (info.getWriteMethod() == null) {
        throw new IllegalStateException("Method 'jsxSet_" + name + "' was not found for " + name + " property in " + linkedClass_.getName());
      }
    }
    propertyMap_.put(name, info);
  }
  
  public void addConstant(String name)
  {
    constants_.add(name);
  }
  
  public Set<String> propertyKeys()
  {
    return propertyMap_.keySet();
  }
  
  public Set<String> functionKeys()
  {
    return functionMap_.keySet();
  }
  
  public List<String> constants()
  {
    return constants_;
  }
  
  public void addFunction(String name)
  {
    FunctionInfo info = new FunctionInfo(null);
    String setMethodName = "jsxFunction_" + name;
    for (Method method : linkedClass_.getMethods()) {
      if (method.getName().equals(setMethodName))
      {
        info.setFunctionMethod(method);
        break;
      }
    }
    if (info.getFunctionMethod() == null) {
      throw new IllegalStateException("Method 'jsxFunction_" + name + "' was not found for " + name + " function in " + linkedClass_.getName());
    }
    functionMap_.put(name, info);
  }
  
  public void setBrowser(String propertyName, String browserName)
    throws IllegalStateException
  {
    PropertyInfo property = getPropertyInfo(propertyName);
    if (property == null) {
      throw new IllegalStateException("Property does not exist to set browser");
    }
    property.setBrowser(new BrowserInfo(browserName, null));
  }
  
  public String getExtendedClass()
  {
    return extendedClass_;
  }
  
  public void setExtendedClass(String extendedClass)
  {
    extendedClass_ = extendedClass;
  }
  
  protected PropertyInfo getPropertyInfo(String propertyName)
  {
    return (PropertyInfo)propertyMap_.get(propertyName);
  }
  
  private FunctionInfo getFunctionInfo(String functionName)
  {
    return (FunctionInfo)functionMap_.get(functionName);
  }
  
  public boolean equals(Object obj)
  {
    if (!(obj instanceof ClassConfiguration)) {
      return false;
    }
    ClassConfiguration config = (ClassConfiguration)obj;
    if (propertyMap_.size() != propertyMap_.size()) {
      return false;
    }
    if (functionMap_.size() != functionMap_.size()) {
      return false;
    }
    Set<String> keys = propertyMap_.keySet();
    for (String key : keys) {
      if (!((PropertyInfo)propertyMap_.get(key)).valueEquals(propertyMap_.get(key))) {
        return false;
      }
    }
    for (String key : functionMap_.keySet()) {
      if (!((FunctionInfo)functionMap_.get(key)).valueEquals(functionMap_.get(key))) {
        return false;
      }
    }
    return true;
  }
  
  public int hashCode()
  {
    return className_.hashCode();
  }
  
  public Method getPropertyReadMethod(String propertyName)
  {
    PropertyInfo info = getPropertyInfo(propertyName);
    if (info == null) {
      return null;
    }
    return info.getReadMethod();
  }
  
  public Method getPropertyWriteMethod(String propertyName)
  {
    PropertyInfo info = getPropertyInfo(propertyName);
    if (info == null) {
      return null;
    }
    return info.getWriteMethod();
  }
  
  public Method getFunctionMethod(String functionName)
  {
    FunctionInfo info = getFunctionInfo(functionName);
    if (info == null) {
      return null;
    }
    return info.getFunctionMethod();
  }
  
  public Class<? extends SimpleScriptable> getLinkedClass()
  {
    return linkedClass_;
  }
  
  public Method getJsConstructor()
  {
    return jsConstructor_;
  }
  
  public String getHtmlClassname()
  {
    return htmlClassname_;
  }
  
  public boolean isJsObject()
  {
    return jsObject_;
  }
  
  protected class PropertyInfo
  {
    private boolean readable_ = false;
    private boolean writeable_ = false;
    private boolean hasBrowsers_ = false;
    private Map<String, ClassConfiguration.BrowserInfo> browserMap_;
    private Method readMethod_;
    private Method writeMethod_;
    
    protected PropertyInfo() {}
    
    public Method getReadMethod()
    {
      return readMethod_;
    }
    
    public void setReadMethod(Method readMethod)
    {
      readMethod_ = readMethod;
    }
    
    public Method getWriteMethod()
    {
      return writeMethod_;
    }
    
    public void setWriteMethod(Method writeMethod)
    {
      writeMethod_ = writeMethod;
    }
    
    private void setBrowser(ClassConfiguration.BrowserInfo browserInfo)
    {
      if (browserMap_ == null)
      {
        hasBrowsers_ = true;
        browserMap_ = new HashMap();
      }
      browserMap_.put(browserInfo.getBrowserName(), browserInfo);
    }
    
    private boolean valueEquals(Object obj)
    {
      if (!(obj instanceof PropertyInfo)) {
        return false;
      }
      PropertyInfo info = (PropertyInfo)obj;
      if (hasBrowsers_ != hasBrowsers_) {
        return false;
      }
      if (hasBrowsers_)
      {
        if (browserMap_.size() != browserMap_.size()) {
          return false;
        }
        for (String key : browserMap_.keySet()) {
          if (!((ClassConfiguration.BrowserInfo)browserMap_.get(key)).valueEquals(browserMap_.get(key))) {
            return false;
          }
        }
      }
      return (readable_ == readable_) && (writeable_ == writeable_);
    }
    
    private void setReadable(boolean readable)
    {
      readable_ = readable;
    }
    
    private void setWriteable(boolean writeable)
    {
      writeable_ = writeable;
    }
  }
  
  private class FunctionInfo
  {
    private boolean hasBrowsers_ = false;
    private Map<String, ClassConfiguration.BrowserInfo> browserMap_;
    private Method functionMethod_;
    
    private FunctionInfo() {}
    
    private boolean valueEquals(Object obj)
    {
      if (!(obj instanceof FunctionInfo)) {
        return false;
      }
      FunctionInfo info = (FunctionInfo)obj;
      if (hasBrowsers_ != hasBrowsers_) {
        return false;
      }
      if (hasBrowsers_)
      {
        if (browserMap_.size() != browserMap_.size()) {
          return false;
        }
        for (String key : browserMap_.keySet()) {
          if (((ClassConfiguration.BrowserInfo)browserMap_.get(key)).valueEquals(browserMap_.get(key))) {
            return false;
          }
        }
      }
      return true;
    }
    
    public Method getFunctionMethod()
    {
      return functionMethod_;
    }
    
    public void setFunctionMethod(Method functionMethod)
    {
      functionMethod_ = functionMethod;
    }
  }
  
  private final class BrowserInfo
  {
    private String browserName_;
    private String minVersion_;
    private String maxVersion_;
    private String lessThanVersion_;
    
    private boolean valueEquals(Object obj)
    {
      if (!(obj instanceof BrowserInfo)) {
        return false;
      }
      BrowserInfo info = (BrowserInfo)obj;
      if ((minVersion_ != null) && (!minVersion_.equals(minVersion_))) {
        return false;
      }
      if ((maxVersion_ != null) && (!maxVersion_.equals(maxVersion_))) {
        return false;
      }
      if ((lessThanVersion_ != null) && (!lessThanVersion_.equals(lessThanVersion_))) {
        return false;
      }
      return browserName_ == browserName_;
    }
    
    private BrowserInfo(String browserName)
    {
      browserName_ = browserName;
    }
    
    private String getBrowserName()
    {
      return browserName_;
    }
  }
}

/* Location:
 * Qualified Name:     com.gargoylesoftware.htmlunit.javascript.configuration.ClassConfiguration
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.gargoylesoftware.htmlunit.javascript.configuration;

import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.html.HtmlAbbreviated;
import com.gargoylesoftware.htmlunit.html.HtmlAcronym;
import com.gargoylesoftware.htmlunit.html.HtmlAddress;
import com.gargoylesoftware.htmlunit.html.HtmlBackgroundSound;
import com.gargoylesoftware.htmlunit.html.HtmlBidirectionalOverride;
import com.gargoylesoftware.htmlunit.html.HtmlBig;
import com.gargoylesoftware.htmlunit.html.HtmlBlink;
import com.gargoylesoftware.htmlunit.html.HtmlBlockQuote;
import com.gargoylesoftware.htmlunit.html.HtmlBold;
import com.gargoylesoftware.htmlunit.html.HtmlCenter;
import com.gargoylesoftware.htmlunit.html.HtmlCitation;
import com.gargoylesoftware.htmlunit.html.HtmlCode;
import com.gargoylesoftware.htmlunit.html.HtmlDefinition;
import com.gargoylesoftware.htmlunit.html.HtmlDefinitionDescription;
import com.gargoylesoftware.htmlunit.html.HtmlDefinitionTerm;
import com.gargoylesoftware.htmlunit.html.HtmlDivision;
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlEmphasis;
import com.gargoylesoftware.htmlunit.html.HtmlExample;
import com.gargoylesoftware.htmlunit.html.HtmlHeading1;
import com.gargoylesoftware.htmlunit.html.HtmlHeading2;
import com.gargoylesoftware.htmlunit.html.HtmlHeading3;
import com.gargoylesoftware.htmlunit.html.HtmlHeading4;
import com.gargoylesoftware.htmlunit.html.HtmlHeading5;
import com.gargoylesoftware.htmlunit.html.HtmlHeading6;
import com.gargoylesoftware.htmlunit.html.HtmlInlineQuotation;
import com.gargoylesoftware.htmlunit.html.HtmlItalic;
import com.gargoylesoftware.htmlunit.html.HtmlKeyboard;
import com.gargoylesoftware.htmlunit.html.HtmlListing;
import com.gargoylesoftware.htmlunit.html.HtmlMarquee;
import com.gargoylesoftware.htmlunit.html.HtmlMultiColumn;
import com.gargoylesoftware.htmlunit.html.HtmlNoBreak;
import com.gargoylesoftware.htmlunit.html.HtmlNoEmbed;
import com.gargoylesoftware.htmlunit.html.HtmlNoFrames;
import com.gargoylesoftware.htmlunit.html.HtmlNoScript;
import com.gargoylesoftware.htmlunit.html.HtmlPlainText;
import com.gargoylesoftware.htmlunit.html.HtmlS;
import com.gargoylesoftware.htmlunit.html.HtmlSample;
import com.gargoylesoftware.htmlunit.html.HtmlSmall;
import com.gargoylesoftware.htmlunit.html.HtmlSpan;
import com.gargoylesoftware.htmlunit.html.HtmlStrike;
import com.gargoylesoftware.htmlunit.html.HtmlStrong;
import com.gargoylesoftware.htmlunit.html.HtmlSubscript;
import com.gargoylesoftware.htmlunit.html.HtmlSuperscript;
import com.gargoylesoftware.htmlunit.html.HtmlTableBody;
import com.gargoylesoftware.htmlunit.html.HtmlTableColumn;
import com.gargoylesoftware.htmlunit.html.HtmlTableColumnGroup;
import com.gargoylesoftware.htmlunit.html.HtmlTableFooter;
import com.gargoylesoftware.htmlunit.html.HtmlTableHeader;
import com.gargoylesoftware.htmlunit.html.HtmlTeletype;
import com.gargoylesoftware.htmlunit.html.HtmlUnderlined;
import com.gargoylesoftware.htmlunit.html.HtmlVariable;
import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable;
import com.gargoylesoftware.htmlunit.javascript.StrictErrorHandler;
import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLDivElement;
import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLHeadingElement;
import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLQuoteElement;
import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLSpanElement;
import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLTableColElement;
import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLTableSectionElement;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.WeakHashMap;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.xml.sax.InputSource;
import org.xml.sax.SAXParseException;

public final class JavaScriptConfiguration
{
  private static final Log LOG = LogFactory.getLog(JavaScriptConfiguration.class);
  private static Document XmlDocument_;
  public static final int ENABLED = 1;
  public static final int DISABLED = 2;
  public static final int NOT_FOUND = 3;
  private static Map<BrowserVersion, JavaScriptConfiguration> ConfigurationMap_ = new WeakHashMap(11);
  private static Map<String, String> ClassnameMap_ = new HashMap();
  private static Map<Class<? extends HtmlElement>, Class<? extends SimpleScriptable>> HtmlJavaScriptMap_;
  private final Map<String, ClassConfiguration> configuration_;
  
  private JavaScriptConfiguration(BrowserVersion browser)
  {
    if (XmlDocument_ == null) {
      loadConfiguration();
    }
    if (XmlDocument_ == null) {
      throw new IllegalStateException("Configuration was not initialized - see log for details");
    }
    configuration_ = buildUsageMap(browser);
  }
  
  protected static boolean isDocumentLoaded()
  {
    return XmlDocument_ != null;
  }
  
  protected static void resetClassForTesting()
  {
    XmlDocument_ = null;
    ConfigurationMap_ = new WeakHashMap(11);
  }
  
  protected static void setXmlDocument(Document document)
  {
    XmlDocument_ = document;
  }
  
  protected static void loadConfiguration()
  {
    try
    {
      Reader reader = getConfigurationFileAsReader();
      if (reader == null)
      {
        LOG.error("Unable to load JavaScriptConfiguration.xml");
      }
      else
      {
        loadConfiguration(reader);
        reader.close();
      }
    }
    catch (Exception e)
    {
      LOG.error("Error when loading JavascriptConfiguration.xml", e);
      e.printStackTrace();
    }
  }
  
  protected static void loadConfiguration(Reader configurationReader)
  {
    InputSource inputSource = new InputSource(configurationReader);
    try
    {
      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      factory.setNamespaceAware(true);
      factory.setValidating(false);
      
      DocumentBuilder documentBuilder = factory.newDocumentBuilder();
      documentBuilder.setErrorHandler(new StrictErrorHandler());
      
      XmlDocument_ = documentBuilder.parse(inputSource);
    }
    catch (SAXParseException parseException)
    {
      LOG.error("line=[" + parseException.getLineNumber() + "] columnNumber=[" + parseException.getColumnNumber() + "] systemId=[" + parseException.getSystemId() + "] publicId=[" + parseException.getPublicId() + "]", parseException);
    }
    catch (Exception e)
    {
      LOG.error("Error when loading JavascriptConfiguration.xml", e);
    }
  }
  
  public static synchronized JavaScriptConfiguration getInstance(BrowserVersion browserVersion)
  {
    if (browserVersion == null) {
      throw new IllegalStateException("BrowserVersion must be defined");
    }
    JavaScriptConfiguration configuration = (JavaScriptConfiguration)ConfigurationMap_.get(browserVersion);
    if (configuration == null)
    {
      configuration = new JavaScriptConfiguration(browserVersion);
      ConfigurationMap_.put(browserVersion, configuration);
    }
    return configuration;
  }
  
  static JavaScriptConfiguration getAllEntries()
  {
    JavaScriptConfiguration configuration = new JavaScriptConfiguration(null);
    return configuration;
  }
  
  private static Reader getConfigurationFileAsReader()
  {
    Class<?> clazz = JavaScriptConfiguration.class;
    String name = clazz.getPackage().getName().replace('.', '/') + '/' + "JavaScriptConfiguration.xml";
    InputStream inputStream = clazz.getClassLoader().getResourceAsStream(name);
    if (inputStream == null) {
      try
      {
        String localizedName = name.replace('/', File.separatorChar);
        inputStream = new FileInputStream(localizedName);
      }
      catch (IOException e) {}
    }
    if (inputStream == null) {
      try
      {
        String localizedName = ("./src/java" + name).replace('/', File.separatorChar);
        inputStream = new FileInputStream(localizedName);
      }
      catch (IOException e) {}
    }
    return new InputStreamReader(inputStream);
  }
  
  public Set<String> keySet()
  {
    return configuration_.keySet();
  }
  
  private Map<String, ClassConfiguration> buildUsageMap(BrowserVersion browser)
  {
    Map<String, ClassConfiguration> classMap = new HashMap(30);
    Node node = XmlDocument_.getDocumentElement().getFirstChild();
    while (node != null)
    {
      if ((node instanceof Element))
      {
        Element element = (Element)node;
        if (element.getTagName().equals("class"))
        {
          String className = element.getAttribute("name");
          if (!testToExcludeElement(element, browser)) {
            try
            {
              ClassConfiguration config = parseClassElement(className, element, browser);
              if (config != null) {
                classMap.put(className, config);
              }
            }
            catch (ClassNotFoundException e)
            {
              throw new IllegalStateException("The class was not found for '" + className + "'");
            }
          }
        }
      }
      node = node.getNextSibling();
    }
    return Collections.unmodifiableMap(classMap);
  }
  
  private ClassConfiguration parseClassElement(String className, Element element, BrowserVersion browser)
    throws ClassNotFoundException
  {
    String notImplemented = element.getAttribute("notImplemented");
    if ("true".equalsIgnoreCase(notImplemented)) {
      return null;
    }
    String linkedClassname = element.getAttribute("classname");
    String jsConstructor = element.getAttribute("jsConstructor");
    String superclassName = element.getAttribute("extends");
    String htmlClassname = element.getAttribute("htmlClass");
    boolean jsObjectFlag = false;
    String jsObjectStr = element.getAttribute("JSObject");
    if ("true".equalsIgnoreCase(jsObjectStr)) {
      jsObjectFlag = true;
    }
    ClassConfiguration classConfiguration = new ClassConfiguration(className, linkedClassname, jsConstructor, superclassName, htmlClassname, jsObjectFlag);
    
    ClassnameMap_.put(linkedClassname, className);
    Node node = element.getFirstChild();
    while (node != null)
    {
      if ((node instanceof Element))
      {
        Element childElement = (Element)node;
        String tagName = childElement.getTagName();
        if (tagName.equals("property")) {
          parsePropertyElement(classConfiguration, childElement, browser);
        } else if (tagName.equals("function")) {
          parseFunctionElement(classConfiguration, childElement, browser);
        } else if (tagName.equals("constant")) {
          parseConstantElement(classConfiguration, childElement, browser);
        } else if (tagName.equals("browser")) {
          LOG.debug("browser tag not yet handled for class " + linkedClassname);
        } else if (!tagName.equals("doclink")) {
          throw new IllegalStateException("Do not understand element type '" + tagName + "' in '" + linkedClassname + "'");
        }
      }
      node = node.getNextSibling();
    }
    return classConfiguration;
  }
  
  private void parsePropertyElement(ClassConfiguration classConfiguration, Element element, BrowserVersion browser)
  {
    String notImplemented = element.getAttribute("notImplemented");
    if ("true".equalsIgnoreCase(notImplemented)) {
      return;
    }
    if (testToExcludeElement(element, browser)) {
      return;
    }
    String propertyName = element.getAttribute("name");
    boolean readable = false;
    boolean writeable = false;
    String readFlag = element.getAttribute("readable");
    if ("true".equalsIgnoreCase(readFlag)) {
      readable = true;
    }
    String writeFlag = element.getAttribute("writable");
    if ("true".equalsIgnoreCase(writeFlag)) {
      writeable = true;
    }
    classConfiguration.addProperty(propertyName, readable, writeable);
  }
  
  private void parseFunctionElement(ClassConfiguration classConfiguration, Element element, BrowserVersion browser)
  {
    String notImplemented = element.getAttribute("notImplemented");
    if ("true".equalsIgnoreCase(notImplemented)) {
      return;
    }
    String propertyName = element.getAttribute("name");
    if (testToExcludeElement(element, browser)) {
      return;
    }
    classConfiguration.addFunction(propertyName);
  }
  
  private void parseConstantElement(ClassConfiguration classConfiguration, Element element, BrowserVersion browser)
  {
    if (testToExcludeElement(element, browser)) {
      return;
    }
    String constantName = element.getAttribute("name");
    classConfiguration.addConstant(constantName);
  }
  
  private boolean testToExcludeElement(Element element, BrowserVersion browser)
  {
    if (browser == null) {
      return false;
    }
    Node node = element.getFirstChild();
    boolean browserConstraint = false;
    boolean allowBrowser = false;
    while (node != null)
    {
      if ((node instanceof Element))
      {
        Element childElement = (Element)node;
        if (childElement.getTagName().equals("browser"))
        {
          browserConstraint = true;
          if (testToIncludeForBrowserConstraint(childElement, browser)) {
            allowBrowser = true;
          }
        }
      }
      node = node.getNextSibling();
    }
    if ((browserConstraint) && (!allowBrowser)) {
      return true;
    }
    return false;
  }
  
  protected boolean classConfigEquals(String classname, ClassConfiguration config)
  {
    ClassConfiguration myConfig = (ClassConfiguration)configuration_.get(classname);
    return config.equals(myConfig);
  }
  
  public ClassConfiguration getClassConfiguration(String classname)
  {
    return (ClassConfiguration)configuration_.get(classname);
  }
  
  private boolean testToIncludeForBrowserConstraint(Element element, BrowserVersion browser)
  {
    if (((!browser.isIE()) || (!"Internet Explorer".equals(element.getAttribute("name")))) && ((!browser.isFirefox()) || (!"Firefox".equals(element.getAttribute("name"))))) {
      return false;
    }
    String max = element.getAttribute("max-version");
    float maxVersion;
    float maxVersion;
    if (max.length() == 0) {
      maxVersion = 0.0F;
    } else {
      maxVersion = Float.parseFloat(max);
    }
    if ((maxVersion > 0.0F) && (browser.getBrowserVersionNumeric() > maxVersion)) {
      return false;
    }
    String min = element.getAttribute("min-version");
    float minVersion;
    float minVersion;
    if (min.length() == 0) {
      minVersion = 0.0F;
    } else {
      minVersion = Float.parseFloat(min);
    }
    if ((minVersion > 0.0F) && (browser.getBrowserVersionNumeric() < minVersion)) {
      return false;
    }
    return true;
  }
  
  protected Class<?> getClassObject(String classname)
  {
    ClassConfiguration config = (ClassConfiguration)configuration_.get(classname);
    return config.getLinkedClass();
  }
  
  public Method getPropertyReadMethod(Class<?> clazz, String propertyName)
  {
    String classname = getClassnameForClass(clazz);
    return getPropertyReadMethod(classname, propertyName);
  }
  
  public Method getPropertyReadMethod(String classname, String propertyName)
  {
    while (classname.length() > 0)
    {
      ClassConfiguration config = (ClassConfiguration)configuration_.get(classname);
      if (config == null) {
        return null;
      }
      Method theMethod = config.getPropertyReadMethod(propertyName);
      if (theMethod != null) {
        return theMethod;
      }
      classname = config.getExtendedClass();
    }
    return null;
  }
  
  private ClassConfiguration.PropertyInfo findPropertyInChain(String classname, String propertyName)
  {
    String workname = classname;
    while (workname.length() > 0)
    {
      ClassConfiguration config = (ClassConfiguration)configuration_.get(workname);
      ClassConfiguration.PropertyInfo info = config.getPropertyInfo(propertyName);
      if (info != null) {
        return info;
      }
      workname = config.getExtendedClass();
    }
    return null;
  }
  
  public Method getPropertyWriteMethod(Class<?> clazz, String propertyName)
  {
    String classname = getClassnameForClass(clazz);
    return getPropertyWriteMethod(classname, propertyName);
  }
  
  public Method getPropertyWriteMethod(String classname, String propertyName)
  {
    while (classname.length() > 0)
    {
      ClassConfiguration config = (ClassConfiguration)configuration_.get(classname);
      Method theMethod = config.getPropertyWriteMethod(propertyName);
      if (theMethod != null) {
        return theMethod;
      }
      classname = config.getExtendedClass();
    }
    return null;
  }
  
  public Method getFunctionMethod(Class<?> clazz, String functionName)
  {
    String classname = getClassnameForClass(clazz);
    return getFunctionMethod(classname, functionName);
  }
  
  public Method getFunctionMethod(String classname, String functionName)
  {
    while (classname.length() > 0)
    {
      ClassConfiguration config = (ClassConfiguration)configuration_.get(classname);
      Method theMethod = config.getFunctionMethod(functionName);
      if (theMethod != null) {
        return theMethod;
      }
      classname = config.getExtendedClass();
    }
    return null;
  }
  
  public boolean propertyExists(Class<?> clazz, String propertyName)
  {
    String classname = getClassnameForClass(clazz);
    return propertyExists(classname, propertyName);
  }
  
  public boolean propertyExists(String classname, String propertyName)
  {
    ClassConfiguration.PropertyInfo info = findPropertyInChain(classname, propertyName);
    if (info == null) {
      return false;
    }
    return true;
  }
  
  private String getClassnameForClass(Class<?> clazz)
  {
    String name = (String)ClassnameMap_.get(clazz.getName());
    if (name == null) {
      throw new IllegalStateException("Did not find the mapping of the class to the classname for " + clazz.getName());
    }
    return name;
  }
  
  public static synchronized Map<Class<? extends HtmlElement>, Class<? extends SimpleScriptable>> getHtmlJavaScriptMapping()
  {
    if (HtmlJavaScriptMap_ != null) {
      return HtmlJavaScriptMap_;
    }
    JavaScriptConfiguration configuration = getAllEntries();
    
    Map<Class<? extends HtmlElement>, Class<? extends SimpleScriptable>> map = new HashMap();
    for (String jsClassname : configuration.keySet())
    {
      ClassConfiguration classConfig = configuration.getClassConfiguration(jsClassname);
      String htmlClassname = classConfig.getHtmlClassname();
      if (htmlClassname != null) {
        try
        {
          Class<? extends HtmlElement> htmlClass = Class.forName(htmlClassname);
          
          LOG.debug("Mapping " + htmlClass.getName() + " to " + jsClassname);
          while (!classConfig.isJsObject())
          {
            jsClassname = classConfig.getExtendedClass();
            classConfig = configuration.getClassConfiguration(jsClassname);
          }
          map.put(htmlClass, classConfig.getLinkedClass());
        }
        catch (ClassNotFoundException e)
        {
          throw new NoClassDefFoundError(e.getMessage());
        }
      }
    }
    map.put(HtmlHeading1.class, HTMLHeadingElement.class);
    map.put(HtmlHeading2.class, HTMLHeadingElement.class);
    map.put(HtmlHeading3.class, HTMLHeadingElement.class);
    map.put(HtmlHeading4.class, HTMLHeadingElement.class);
    map.put(HtmlHeading5.class, HTMLHeadingElement.class);
    map.put(HtmlHeading6.class, HTMLHeadingElement.class);
    
    map.put(HtmlInlineQuotation.class, HTMLQuoteElement.class);
    map.put(HtmlBlockQuote.class, HTMLQuoteElement.class);
    
    map.put(HtmlAbbreviated.class, HTMLSpanElement.class);
    map.put(HtmlAcronym.class, HTMLSpanElement.class);
    map.put(HtmlAddress.class, HTMLSpanElement.class);
    map.put(HtmlBackgroundSound.class, HTMLSpanElement.class);
    map.put(HtmlBidirectionalOverride.class, HTMLSpanElement.class);
    map.put(HtmlBig.class, HTMLSpanElement.class);
    map.put(HtmlBold.class, HTMLSpanElement.class);
    map.put(HtmlBlink.class, HTMLSpanElement.class);
    map.put(HtmlCenter.class, HTMLSpanElement.class);
    map.put(HtmlCitation.class, HTMLSpanElement.class);
    map.put(HtmlCode.class, HTMLSpanElement.class);
    map.put(HtmlDefinition.class, HTMLSpanElement.class);
    map.put(HtmlDefinitionDescription.class, HTMLSpanElement.class);
    map.put(HtmlDefinitionTerm.class, HTMLSpanElement.class);
    map.put(HtmlEmphasis.class, HTMLSpanElement.class);
    map.put(HtmlItalic.class, HTMLSpanElement.class);
    map.put(HtmlKeyboard.class, HTMLSpanElement.class);
    map.put(HtmlListing.class, HTMLSpanElement.class);
    map.put(HtmlMultiColumn.class, HTMLSpanElement.class);
    map.put(HtmlNoBreak.class, HTMLSpanElement.class);
    map.put(HtmlPlainText.class, HTMLSpanElement.class);
    map.put(HtmlS.class, HTMLSpanElement.class);
    map.put(HtmlSample.class, HTMLSpanElement.class);
    map.put(HtmlSmall.class, HTMLSpanElement.class);
    map.put(HtmlSpan.class, HTMLSpanElement.class);
    map.put(HtmlStrike.class, HTMLSpanElement.class);
    map.put(HtmlStrong.class, HTMLSpanElement.class);
    map.put(HtmlSubscript.class, HTMLSpanElement.class);
    map.put(HtmlSuperscript.class, HTMLSpanElement.class);
    map.put(HtmlTeletype.class, HTMLSpanElement.class);
    map.put(HtmlUnderlined.class, HTMLSpanElement.class);
    map.put(HtmlVariable.class, HTMLSpanElement.class);
    map.put(HtmlExample.class, HTMLSpanElement.class);
    
    map.put(HtmlDivision.class, HTMLDivElement.class);
    map.put(HtmlMarquee.class, HTMLDivElement.class);
    map.put(HtmlNoEmbed.class, HTMLDivElement.class);
    map.put(HtmlNoFrames.class, HTMLDivElement.class);
    map.put(HtmlNoScript.class, HTMLDivElement.class);
    
    map.put(HtmlTableBody.class, HTMLTableSectionElement.class);
    map.put(HtmlTableHeader.class, HTMLTableSectionElement.class);
    map.put(HtmlTableFooter.class, HTMLTableSectionElement.class);
    
    map.put(HtmlTableColumn.class, HTMLTableColElement.class);
    map.put(HtmlTableColumnGroup.class, HTMLTableColElement.class);
    
    HtmlJavaScriptMap_ = Collections.unmodifiableMap(map);
    return HtmlJavaScriptMap_;
  }
}

/* Location:
 * Qualified Name:     com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfiguration
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.gargoylesoftware.htmlunit.javascript;

import org.apache.commons.collections.Transformer;

class SimpleScriptable$1
  implements Transformer
{
  SimpleScriptable$1(SimpleScriptable paramSimpleScriptable) {}
  
  public Object transform(Object obj)
  {
    return this$0.getScriptableFor(obj);
  }
}

/* Location:
 * Qualified Name:     com.gargoylesoftware.htmlunit.javascript.SimpleScriptable.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.gargoylesoftware.htmlunit.javascript;

import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.SgmlPage;
import com.gargoylesoftware.htmlunit.WebAssert;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.WebWindow;
import com.gargoylesoftware.htmlunit.html.DomNode;
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfiguration;
import com.gargoylesoftware.htmlunit.javascript.host.Window;
import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement;
import java.lang.reflect.Method;
import java.util.Map;
import net.sourceforge.htmlunit.corejs.javascript.Context;
import net.sourceforge.htmlunit.corejs.javascript.FunctionObject;
import net.sourceforge.htmlunit.corejs.javascript.Scriptable;
import net.sourceforge.htmlunit.corejs.javascript.ScriptableObject;
import org.apache.commons.collections.Transformer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class SimpleScriptable
  extends ScriptableObject
  implements Cloneable
{
  private static final long serialVersionUID = 3120000176890886780L;
  private static final Log LOG = LogFactory.getLog(SimpleScriptable.class);
  private DomNode domNode_;
  private boolean caseSensitive_ = true;
  
  public Object get(St
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd