htmlunit-2.7

realFunction_ = cx.compileFunction(jsObj, jsSnippet_, eventName_ + " event for " + node_ + " in " + node_.getPage().getWebResponse().getRequestSettings().getUrl(), 0, null);
    }
    Object result = realFunction_.call(cx, scope, thisObj, args);
    
    return result;
  }
  
  public Object getDefaultValue(Class<?> typeHint)
  {
    return jsSnippet_;
  }
  
  public Object get(String name, Scriptable start)
  {
    if ("toString".equals(name)) {
      new BaseFunction()
      {
        public Object call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args)
        {
          return jsSnippet_;
        }
      };
    }
    return super.get(name, start);
  }
}

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

public class DocumentFragment
  extends Node
{
  private static final long serialVersionUID = -9081976556072827541L;
  
  public Object jsxGet_xml()
  {
    Node node = jsxGet_firstChild();
    if (node != null) {
      return node.jsxGet_xml();
    }
    return "";
  }
}

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

import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable;
import com.gargoylesoftware.htmlunit.javascript.host.xml.XMLDocument;

public class DOMParser
  extends SimpleScriptable
{
  private static final long serialVersionUID = 3143102490697686971L;
  
  public void jsConstructor() {}
  
  public XMLDocument jsxFunction_parseFromString(String str, String contentType)
  {
    XMLDocument document = new XMLDocument();
    document.setParentScope(getParentScope());
    document.setPrototype(getPrototype(XMLDocument.class));
    document.jsxFunction_loadXML(str);
    return document;
  }
}

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

import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.WebWindow;
import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable;
import com.gargoylesoftware.htmlunit.javascript.configuration.ClassConfiguration;
import com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfiguration;
import com.gargoylesoftware.htmlunit.javascript.host.xml.XMLDocument;
import com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest;
import java.lang.reflect.Method;
import java.util.Map;
import net.sourceforge.htmlunit.corejs.javascript.Context;
import net.sourceforge.htmlunit.corejs.javascript.Function;
import net.sourceforge.htmlunit.corejs.javascript.FunctionObject;
import net.sourceforge.htmlunit.corejs.javascript.Scriptable;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class ActiveXObject
  extends SimpleScriptable
{
  private static final long serialVersionUID = 7327032075131452226L;
  private static final Log LOG = LogFactory.getLog(ActiveXObject.class);
  
  public static Scriptable jsConstructor(Context cx, Object[] args, Function ctorObj, boolean inNewExpr)
  {
    if ((args.length < 1) || (args.length > 2)) {
      throw Context.reportRuntimeError("ActiveXObject Error: constructor must have one or two String parameters.");
    }
    if (args[0] == Context.getUndefinedValue()) {
      throw Context.reportRuntimeError("ActiveXObject Error: constructor parameter is undefined.");
    }
    if (!(args[0] instanceof String)) {
      throw Context.reportRuntimeError("ActiveXObject Error: constructor parameter must be a String.");
    }
    String activeXName = (String)args[0];
    if (isXMLHttpRequest(activeXName)) {
      return buildXMLHttpRequest();
    }
    if (isXMLDocument(activeXName)) {
      return buildXMLDocument(getWindow(ctorObj).getWebWindow());
    }
    if (isXMLTemplate(activeXName)) {
      return buildXSLTemplate();
    }
    WebClient webClient = getWindow(ctorObj).getWebWindow().getWebClient();
    Map<String, String> map = webClient.getActiveXObjectMap();
    if (map != null)
    {
      Object mapValue = map.get(activeXName);
      if (mapValue != null)
      {
        String xClassString = (String)mapValue;
        Object object = null;
        try
        {
          Class<?> xClass = Class.forName(xClassString);
          object = xClass.newInstance();
        }
        catch (Exception e)
        {
          throw Context.reportRuntimeError("ActiveXObject Error: failed instantiating class " + xClassString + " because " + e.getMessage() + ".");
        }
        return Context.toObject(object, ctorObj);
      }
    }
    if ((webClient.isActiveXNative()) && (System.getProperty("os.name").contains("Windows"))) {
      try
      {
        return new ActiveXObjectImpl(activeXName);
      }
      catch (Exception e)
      {
        if (LOG.isWarnEnabled()) {
          LOG.warn("Error initiating Jacob", e);
        }
      }
    }
    throw Context.reportRuntimeError("Automation server can't create object");
  }
  
  static boolean isXMLHttpRequest(String name)
  {
    if (name == null) {
      return false;
    }
    name = name.toLowerCase();
    return ("Microsoft.XMLHTTP".equalsIgnoreCase(name)) || (name.startsWith("Msxml2.XMLHTTP".toLowerCase()));
  }
  
  static boolean isXMLDocument(String name)
  {
    if (name == null) {
      return false;
    }
    name = name.toLowerCase();
    return ("Microsoft.XMLDOM".equalsIgnoreCase(name)) || (name.matches("msxml\\d*\\.domdocument.*")) || (name.matches("msxml\\d*\\.freethreadeddomdocument.*"));
  }
  
  static boolean isXMLTemplate(String name)
  {
    if (name == null) {
      return false;
    }
    name = name.toLowerCase();
    return name.matches("msxml\\d*\\.xsltemplate.*");
  }
  
  private static Scriptable buildXMLHttpRequest()
  {
    SimpleScriptable scriptable = new XMLHttpRequest(false);
    
    addProperty(scriptable, "onreadystatechange", true, true);
    addProperty(scriptable, "readyState", true, false);
    addProperty(scriptable, "responseText", true, false);
    addProperty(scriptable, "responseXML", true, false);
    addProperty(scriptable, "status", true, false);
    addProperty(scriptable, "statusText", true, false);
    
    addFunction(scriptable, "abort");
    addFunction(scriptable, "getAllResponseHeaders");
    addFunction(scriptable, "getResponseHeader");
    addFunction(scriptable, "open");
    addFunction(scriptable, "send");
    addFunction(scriptable, "setRequestHeader");
    
    return scriptable;
  }
  
  private static Scriptable buildXSLTemplate()
  {
    SimpleScriptable scriptable = new XSLTemplate();
    
    addProperty(scriptable, "stylesheet", true, true);
    addFunction(scriptable, "createProcessor");
    
    return scriptable;
  }
  
  public static XMLDocument buildXMLDocument(WebWindow enclosingWindow)
  {
    XMLDocument document = new XMLDocument(enclosingWindow);
    
    addProperty(document, "async", true, true);
    addProperty(document, "parseError", true, false);
    addProperty(document, "preserveWhiteSpace", true, true);
    addProperty(document, "xml", true, false);
    
    addFunction(document, "createNode");
    addFunction(document, "createCDATASection");
    addFunction(document, "createProcessingInstruction");
    addFunction(document, "getElementsByTagName");
    addFunction(document, "load");
    addFunction(document, "loadXML");
    addFunction(document, "nodeFromID");
    addFunction(document, "selectNodes");
    addFunction(document, "selectSingleNode");
    addFunction(document, "setProperty");
    
    JavaScriptConfiguration jsConfig = JavaScriptConfiguration.getInstance(BrowserVersion.INTERNET_EXPLORER_7);
    for (String className = "Document"; className.trim().length() != 0;)
    {
      ClassConfiguration classConfig = jsConfig.getClassConfiguration(className);
      for (String function : classConfig.functionKeys()) {
        addFunction(document, function);
      }
      for (String property : classConfig.propertyKeys()) {
        addProperty(document, property, classConfig.getPropertyReadMethod(property) != null, classConfig.getPropertyWriteMethod(property) != null);
      }
      className = classConfig.getExtendedClass();
    }
    return document;
  }
  
  private static void addFunction(SimpleScriptable scriptable, String jsMethodName)
  {
    addFunction(scriptable, jsMethodName, "jsxFunction_" + jsMethodName);
  }
  
  private static void addFunction(SimpleScriptable scriptable, String jsMethodName, String javaMethodName)
  {
    Method javaFunction = getMethod(scriptable.getClass(), javaMethodName);
    FunctionObject fo = new FunctionObject(null, javaFunction, scriptable);
    scriptable.defineProperty(jsMethodName, fo, 1);
  }
  
  public static void addProperty(SimpleScriptable scriptable, String propertyName, boolean isGetter, boolean isSetter)
  {
    String getterName = null;
    if (isGetter) {
      getterName = "jsxGet_" + propertyName;
    }
    String setterName = null;
    if (isSetter) {
      setterName = "jsxSet_" + propertyName;
    }
    addProperty(scriptable, propertyName, getterName, setterName);
  }
  
  static void addProperty(SimpleScriptable scriptable, String propertyName, String getterName, String setterName)
  {
    scriptable.defineProperty(propertyName, null, getMethod(scriptable.getClass(), getterName), getMethod(scriptable.getClass(), setterName), 4);
  }
  
  static Method getMethod(Class<? extends SimpleScriptable> clazz, String name)
  {
    if (name == null) {
      return null;
    }
    for (Method method : clazz.getMethods()) {
      if (method.getName().equals(name)) {
        return method;
      }
    }
    return null;
  }
  
  public String getClassName()
  {
    return "ActiveXObject";
  }
}

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

import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable;

public class XSLTemplate
  extends SimpleScriptable
{
  private static final long serialVersionUID = 2820794481694666278L;
  private Node stylesheet_;
  
  public void jsConstructor() {}
  
  public void jsxSet_stylesheet(Node node)
  {
    stylesheet_ = node;
  }
  
  public Node jsxGet_stylesheet()
  {
    return stylesheet_;
  }
  
  public XSLTProcessor jsxFunction_createProcessor()
  {
    XSLTProcessor processor = new XSLTProcessor();
    processor.setPrototype(getPrototype(processor.getClass()));
    processor.setParentScope(getParentScope());
    processor.jsxFunction_importStylesheet(stylesheet_);
    return processor;
  }
}

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

import com.gargoylesoftware.htmlunit.SgmlPage;
import com.gargoylesoftware.htmlunit.html.DomDocumentFragment;
import com.gargoylesoftware.htmlunit.html.DomNode;
import com.gargoylesoftware.htmlunit.html.DomText;
import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable;
import com.gargoylesoftware.htmlunit.javascript.host.xml.XMLDocument;
import com.gargoylesoftware.htmlunit.javascript.host.xml.XMLSerializer;
import com.gargoylesoftware.htmlunit.xml.XmlPage;
import com.gargoylesoftware.htmlunit.xml.XmlUtil;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import net.sourceforge.htmlunit.corejs.javascript.Context;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

public class XSLTProcessor
  extends SimpleScriptable
{
  private static final long serialVersionUID = -5870183094839129375L;
  private Node style_;
  private Node input_;
  private Object output_;
  private Map<String, Object> parameters_ = new HashMap();
  
  public void jsConstructor() {}
  
  public void jsxFunction_importStylesheet(Node style)
  {
    style_ = style;
  }
  
  public XMLDocument jsxFunction_transformToDocument(Node source)
  {
    XMLDocument doc = new XMLDocument();
    doc.setPrototype(getPrototype(doc.getClass()));
    doc.setParentScope(getParentScope());
    
    Object transformResult = transform(source);
    org.w3c.dom.Node node;
    org.w3c.dom.Node node;
    if ((transformResult instanceof org.w3c.dom.Node))
    {
      org.w3c.dom.Node transformedDoc = (org.w3c.dom.Node)transformResult;
      node = transformedDoc.getFirstChild();
    }
    else
    {
      node = null;
    }
    XmlPage page = new XmlPage(node, getWindow().getWebWindow());
    doc.setDomNode(page);
    return doc;
  }
  
  private Object transform(Node source)
  {
    try
    {
      Source xmlSource = new DOMSource(source.getDomNodeOrDie());
      Source xsltSource = new DOMSource(style_.getDomNodeOrDie());
      
      org.w3c.dom.Document containerDocument = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
      
      Element containerElement = containerDocument.createElement("container");
      containerDocument.appendChild(containerElement);
      
      DOMResult result = new DOMResult(containerElement);
      
      Transformer transformer = TransformerFactory.newInstance().newTransformer(xsltSource);
      for (String qualifiedName : parameters_.keySet()) {
        transformer.setParameter(qualifiedName, parameters_.get(qualifiedName));
      }
      transformer.transform(xmlSource, result);
      
      org.w3c.dom.Node transformedNode = result.getNode();
      if (transformedNode.getFirstChild().getNodeType() == 1) {
        return transformedNode;
      }
      xmlSource = new DOMSource(source.getDomNodeOrDie());
      StringWriter writer = new StringWriter();
      Result streamResult = new StreamResult(writer);
      transformer.transform(xmlSource, streamResult);
      return writer.toString();
    }
    catch (Exception e)
    {
      throw Context.reportRuntimeError("Exception: " + e);
    }
  }
  
  public DocumentFragment jsxFunction_transformToFragment(Node source, Object output)
  {
    SgmlPage page = (SgmlPage)((Document)output).getDomNodeOrDie();
    
    DomDocumentFragment fragment = page.createDomDocumentFragment();
    DocumentFragment rv = new DocumentFragment();
    rv.setPrototype(getPrototype(rv.getClass()));
    rv.setParentScope(getParentScope());
    rv.setDomNode(fragment);
    
    transform(source, fragment);
    return rv;
  }
  
  private void transform(Node source, DomNode parent)
  {
    Object result = transform(source);
    if ((result instanceof org.w3c.dom.Node))
    {
      SgmlPage parentPage = parent.getPage();
      NodeList children = ((org.w3c.dom.Node)result).getChildNodes();
      for (int i = 0; i < children.getLength(); i++) {
        XmlUtil.appendChild(parentPage, parent, children.item(i));
      }
    }
    else
    {
      DomText text = new DomText(parent.getPage(), (String)result);
      parent.appendChild(text);
    }
  }
  
  public void jsxFunction_setParameter(String namespaceURI, String localName, Object value)
  {
    parameters_.put(getQualifiedName(namespaceURI, localName), value);
  }
  
  public Object jsxFunction_getParameter(String namespaceURI, String localName)
  {
    return parameters_.get(getQualifiedName(namespaceURI, localName));
  }
  
  private String getQualifiedName(String namespaceURI, String localName)
  {
    String qualifiedName;
    String qualifiedName;
    if ((namespaceURI != null) && (namespaceURI.length() != 0) && (!namespaceURI.equals("null"))) {
      qualifiedName = '{' + namespaceURI + '}' + localName;
    } else {
      qualifiedName = localName;
    }
    return qualifiedName;
  }
  
  public void jsxSet_input(Node input)
  {
    input_ = input;
  }
  
  public Node jsxGet_input()
  {
    return input_;
  }
  
  public void jsxSet_output(Object output)
  {
    output_ = output;
  }
  
  public Object jsxGet_output()
  {
    return output_;
  }
  
  public void jsxFunction_addParameter(String baseName, Object parameter, Object namespaceURI)
  {
    String nsString;
    String nsString;
    if ((namespaceURI instanceof String)) {
      nsString = (String)namespaceURI;
    } else {
      nsString = null;
    }
    jsxFunction_setParameter(nsString, baseName, parameter);
  }
  
  public void jsxFunction_transform()
  {
    Node input = input_;
    SgmlPage page = input.getDomNodeOrDie().getPage();
    if ((output_ == null) || (!(output_ instanceof Node)))
    {
      DomDocumentFragment fragment = page.createDomDocumentFragment();
      DocumentFragment node = new DocumentFragment();
      node.setParentScope(getParentScope());
      node.setPrototype(getPrototype(node.getClass()));
      node.setDomNode(fragment);
      output_ = fragment.getScriptObject();
    }
    transform(input_, ((Node)output_).getDomNodeOrDie());
    XMLSerializer serializer = new XMLSerializer();
    serializer.setParentScope(getParentScope());
    String output = "";
    for (DomNode child : ((Node)output_).getDomNodeOrDie().getChildren()) {
      if ((child instanceof DomText))
      {
        if (((DomText)child).getData().trim().length() != 0) {
          output = output + ((DomText)child).getData();
        }
      }
      else
      {
        String serializedString = serializer.jsxFunction_serializeToString((Node)child.getScriptObject());
        
        output = output + serializedString.substring(0, serializedString.length() - 2);
      }
    }
    output_ = output;
  }
}

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

import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable;

public class DOMException
  extends SimpleScriptable
{
  private static final long serialVersionUID = 5758391763325220491L;
  public static final short DOMSTRING_SIZE_ERR = 2;
  public static final short HIERARCHY_REQUEST_ERR = 3;
  public static final short INDEX_SIZE_ERR = 1;
  public static final short INUSE_ATTRIBUTE_ERR = 10;
  public static final short INVALID_ACCESS_ERR = 15;
  public static final short INVALID_CHARACTER_ERR = 5;
  public static final short INVALID_MODIFICATION_ERR = 13;
  public static final short INVALID_STATE_ERR = 11;
  public static final short NAMESPACE_ERR = 14;
  public static final short NO_DATA_ALLOWED_ERR = 6;
  public static final short NO_MODIFICATION_ALLOWED_ERR = 7;
  public static final short NOT_FOUND_ERR = 8;
  public static final short NOT_SUPPORTED_ERR = 9;
  public static final short SYNTAX_ERR = 12;
  public static final short WRONG_DOCUMENT_ERR = 4;
}

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

import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.html.DomDocumentType;

public class DocumentType
  extends Node
{
  private static final long serialVersionUID = -927596204137079990L;
  
  public String jsxGet_name()
  {
    String name = ((DomDocumentType)getDomNodeOrDie()).getName();
    if (("html".equals(name)) && ("FF3".equals(getBrowserVersion().getNickname()))) {
      return "HTML";
    }
    return name;
  }
  
  public String jsxGet_nodeName()
  {
    return jsxGet_name();
  }
  
  public String jsxGet_publicId()
  {
    return ((DomDocumentType)getDomNodeOrDie()).getPublicId();
  }
  
  public String jsxGet_systemId()
  {
    return ((DomDocumentType)getDomNodeOrDie()).getSystemId();
  }
  
  public String jsxGet_internalSubset()
  {
    return ((DomDocumentType)getDomNodeOrDie()).getInternalSubset();
  }
  
  public String jsxGet_entities()
  {
    if (getBrowserVersion().isIE()) {
      return "";
    }
    return null;
  }
  
  public String jsxGet_notations()
  {
    if (getBrowserVersion().isIE()) {
      return "";
    }
    return null;
  }
}

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

public final class Comment
  extends CharacterDataImpl
{
  private static final long serialVersionUID = 4557674333919900046L;
}

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

import java.lang.reflect.Method;
import net.sourceforge.htmlunit.corejs.javascript.Context;
import net.sourceforge.htmlunit.corejs.javascript.Function;
import net.sourceforge.htmlunit.corejs.javascript.Scriptable;

class ActiveXObjectImpl$1
  implements Function
{
  ActiveXObjectImpl$1(ActiveXObjectImpl paramActiveXObjectImpl, String paramString) {}
  
  public Object call(Context arg0, Scriptable arg1, Scriptable arg2, Object[] arg3)
  {
    try
    {
      Object rv = ActiveXObjectImpl.access$100().invoke(null, new Object[] { ActiveXObjectImpl.access$000(this$0), val$name, arg3 });
      return ActiveXObjectImpl.access$200(this$0, rv);
    }
    catch (Exception e)
    {
      throw Context.throwAsScriptRuntimeEx(e);
    }
  }
  
  public Scriptable construct(Context arg0, Scriptable arg1, Object[] arg2)
  {
    throw new UnsupportedOperationException();
  }
  
  public void delete(String arg0)
  {
    throw new UnsupportedOperationException();
  }
  
  public void delete(int arg0)
  {
    throw new UnsupportedOperationException();
  }
  
  public Object get(String arg0, Scriptable arg1)
  {
    throw new UnsupportedOperationException();
  }
  
  public Object get(int arg0, Scriptable arg1)
  {
    throw new UnsupportedOperationException();
  }
  
  public String getClassName()
  {
    throw new UnsupportedOperationException();
  }
  
  public Object getDefaultValue(Class<?> arg0)
  {
    throw new UnsupportedOperationException();
  }
  
  public Object[] getIds()
  {
    throw new UnsupportedOperationException();
  }
  
  public Scriptable getParentScope()
  {
    throw new UnsupportedOperationException();
  }
  
  public Scriptable getPrototype()
  {
    throw new UnsupportedOperationException();
  }
  
  public boolean has(String arg0, Scriptable arg1)
  {
    throw new UnsupportedOperationException();
  }
  
  public boolean has(int arg0, Scriptable arg1)
  {
    throw new UnsupportedOperationException();
  }
  
  public boolean hasInstance(Scriptable arg0)
  {
    throw new UnsupportedOperationException();
  }
  
  public void put(String arg0, Scriptable arg1, Object arg2)
  {
    throw new UnsupportedOperationException();
  }
  
  public void put(int arg0, Scriptable arg1, Object arg2)
  {
    throw new UnsupportedOperationException();
  }
  
  public void setParentScope(Scriptable arg0)
  {
    throw new UnsupportedOperationException();
  }
  
  public void setPrototype(Scriptable arg0)
  {
    throw new UnsupportedOperationException();
  }
}

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

import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import net.sourceforge.htmlunit.corejs.javascript.Context;
import net.sourceforge.htmlunit.corejs.javascript.Function;
import net.sourceforge.htmlunit.corejs.javascript.Scriptable;

public class ActiveXObjectImpl
  extends SimpleScriptable
{
  private static final long serialVersionUID = 6954481782205807262L;
  private static final Class<?> activeXComponentClass_;
  private static final Method METHOD_getProperty_;
  private final Object object_;
  private static final Method METHOD_callN_;
  private static final Method METHOD_getvt_;
  private static final Method METHOD_getDispatch_;
  
  static
  {
    try
    {
      activeXComponentClass_ = Class.forName("com.jacob.activeX.ActiveXComponent");
      METHOD_getProperty_ = activeXComponentClass_.getMethod("getProperty", new Class[] { String.class });
      Class<?> dispatchClass = Class.forName("com.jacob.com.Dispatch");
      METHOD_callN_ = dispatchClass.getMethod("callN", new Class[] { dispatchClass, String.class, Object[].class });
      Class<?> variantClass = Class.forName("com.jacob.com.Variant");
      METHOD_getvt_ = variantClass.getMethod("getvt", new Class[0]);
      METHOD_getDispatch_ = variantClass.getMethod("getDispatch", new Class[0]);
    }
    catch (Exception e)
    {
      throw new RuntimeException(e);
    }
  }
  
  public ActiveXObjectImpl(String activeXName)
    throws Exception
  {
    this(activeXComponentClass_.getConstructor(new Class[] { String.class }).newInstance(new Object[] { activeXName }));
  }
  
  private ActiveXObjectImpl(Object object)
  {
    object_ = object;
  }
  
  public Object get(final String name, Scriptable start)
  {
    try
    {
      Object variant = METHOD_getProperty_.invoke(object_, new Object[] { name });
      return wrapIfNecessary(variant);
    }
    catch (Exception e) {}
    new Function()
    {
      public Object call(Context arg0, Scriptable arg1, Scriptable arg2, Object[] arg3)
      {
        try
        {
          Object rv = ActiveXObjectImpl.METHOD_callN_.invoke(null, new Object[] { object_, name, arg3 });
          return ActiveXObjectImpl.this.wrapIfNecessary(rv);
        }
        catch (Exception e)
        {
          throw Context.throwAsScriptRuntimeEx(e);
        }
      }
      
      public Scriptable construct(Context arg0, Scriptable arg1, Object[] arg2)
      {
        throw new UnsupportedOperationException();
      }
      
      public void delete(String arg0)
      {
        throw new UnsupportedOperationException();
      }
      
      public void delete(int arg0)
      {
        throw new UnsupportedOperationException();
      }
      
      public Object get(String arg0, Scriptable arg1)
      {
        throw new UnsupportedOperationException();
      }
      
      public Object get(int arg0, Scriptable arg1)
      {
        throw new UnsupportedOperationException();
      }
      
      public String getClassName()
      {
        throw new UnsupportedOperationException();
      }
      
      public Object getDefaultValue(Class<?> arg0)
      {
        throw new UnsupportedOperationException();
      }
      
      public Object[] getIds()
      {
        throw new UnsupportedOperationException();
      }
      
      public Scriptable getParentScope()
      {
        throw new UnsupportedOperationException();
      }
      
      public Scriptable getPrototype()
      {
        throw new UnsupportedOperationException();
      }
      
      public boolean has(String arg0, Scriptable arg1)
      {
        throw new UnsupportedOperationException();
      }
      
      public boolean has(int arg0, Scriptable arg1)
      {
        throw new UnsupportedOperationException();
      }
      
      public boolean hasInstance(Scriptable arg0)
      {
        throw new UnsupportedOperationException();
      }
      
      public void put(String arg0, Scriptable arg1, Object arg2)
      {
        throw new UnsupportedOperationException();
      }
      
      public void put(int arg0, Scriptable arg1, Object arg2)
      {
        throw new UnsupportedOperationException();
      }
      
      public void setParentScope(Scriptable arg0)
      {
        throw new UnsupportedOperationException();
      }
      
      public void setPrototype(Scriptable arg0)
      {
        throw new UnsupportedOperationException();
      }
    };
  }
  
  private Object wrapIfNecessary(Object variant)
    throws Exception
  {
    if (((Short)METHOD_getvt_.invoke(variant, new Object[0])).shortValue() == 9) {
      return new ActiveXObjectImpl(METHOD_getDispatch_.invoke(variant, new Object[0]));
    }
    return variant;
  }
  
  public void put(String name, Scriptable start, Object value)
  {
    try
    {
      Method setMethod = activeXComponentClass_.getMethod("setProperty", new Class[] { String.class, value.getClass() });
      setMethod.invoke(object_, new Object[] { name, value });
    }
    catch (Exception e)
    {
      throw Context.throwAsScriptRuntimeEx(e);
    }
  }
}

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

import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable;

public final class MimeType
  extends SimpleScriptable
{
  private static final long serialVersionUID = -4673239005661544554L;
  private String description_;
  private String suffixes_;
  private String type_;
  private Plugin enabledPlugin_;
  
  public MimeType() {}
  
  public MimeType(String type, String description, String suffixes, Plugin plugin)
  {
    type_ = type;
    description_ = description;
    suffixes_ = suffixes;
    enabledPlugin_ = plugin;
  }
  
  public String jsxGet_description()
  {
    return description_;
  }
  
  public String jsxGet_suffixes()
  {
    return suffixes_;
  }
  
  public String jsxGet_type()
  {
    return type_;
  }
  
  public Object jsxGet_enabledPlugin()
  {
    return enabledPlugin_;
  }
}

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

import com.gargoylesoftware.htmlunit.WebWindow;
import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable;
import com.gargoylesoftware.htmlunit.javascript.SimpleScriptableProxy;

public class WindowProxy
  extends SimpleScriptableProxy
{
  private static final long serialVersionUID = -9124838618636683398L;
  private final WebWindow webWindow_;
  
  public WindowProxy(WebWindow webWindow)
  {
    webWindow_ = webWindow;
  }
  
  public SimpleScriptable getWrappedScriptable()
  {
    return (Window)webWindow_.getScriptObject();
  }
}

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

import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.ScriptResult;
import com.gargoylesoftware.htmlunit.html.DomNode;
import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
import com.gargoylesoftware.htmlunit.html.HtmlArea;
import com.gargoylesoftware.htmlunit.html.SubmittableElement;
import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable;
import java.util.LinkedList;
import net.sourceforge.htmlunit.corejs.javascript.Context;
import net.sourceforge.htmlunit.corejs.javascript.Scriptable;
import net.sourceforge.htmlunit.corejs.javascript.Undefined;

public class Event
  extends SimpleScriptable
{
  static final String KEY_CURRENT_EVENT = "Event#current";
  public static final String TYPE_SUBMIT = "submit";
  public static final String TYPE_CHANGE = "change";
  public static final String TYPE_LOAD = "load";
  public static final String TYPE_UNLOAD = "unload";
  public static final String TYPE_FOCUS = "focus";
  public static final String TYPE_FOCUS_IN = "focusin";
  public static final String TYPE_FOCUS_OUT = "focusout";
  public static final String TYPE_BLUR = "blur";
  public static final String TYPE_KEY_DOWN = "keydown";
  public static final String TYPE_KEY_PRESS = "keypress";
  public static final String TYPE_INPUT = "input";
  public static final String TYPE_KEY_UP = "keyup";
  public static final String TYPE_RESET = "reset";
  public static final String TYPE_BEFORE_UNLOAD = "beforeunload";
  public static final String TYPE_DOM_DOCUMENT_LOADED = "DOMContentLoaded";
  public static final String TYPE_PROPERTY_CHANGE = "propertychange";
  public static final String TYPE_READY_STATE_CHANGE = "readystatechange";
  public static final String TYPE_ERROR = "error";
  public static final short CAPTURING_PHASE = 1;
  public static final short AT_TARGET = 2;
  public static final short BUBBLING_PHASE = 3;
  public static final int ABORT = 4194304;
  public static final int ALT_MASK = 1;
  public static final int BACK = 536870912;
  public static final int BLUR = 8192;
  public static final int CHANGE = 32768;
  public static final int CLICK = 64;
  public static final int CONTROL_MASK = 2;
  public static final int DBLCLICK = 128;
  public static final int DRAGDROP = 2048;
  public static final int ERROR = 8388608;
  public static final int FOCUS = 4096;
  public static final int FORWARD = 134217728;
  public static final int HELP = 268435456;
  public static final int KEYDOWN = 256;
  public static final int KEYPRESS = 1024;
  public static final int KEYUP = 512;
  public static final int LOAD = 524288;
  public static final int LOCATE = 16777216;
  public static final int META_MASK = 8;
  public static final int MOUSEDOWN = 1;
  public static final int MOUSEDRAG = 32;
  public static final int MOUSEMOVE = 16;
  public static final int MOUSEOUT = 8;
  public static final int MOUSEOVER = 4;
  public static final int MOUSEUP = 2;
  public static final int MOVE = 33554432;
  public static final int RESET = 65536;
  public static final int RESIZE = 67108864;
  public static final int SCROLL = 262144;
  public static final int SELECT = 16384;
  public static final int SHIFT_MASK = 4;
  public static final int SUBMIT = 131072;
  public static final int TEXT = 1073741824;
  public static final int UNLOAD = 1048576;
  public static final int XFER_DONE = 2097152;
  private static final long serialVersionUID = 4050485607908455730L;
  private Object srcElement_;
  private Object target_;
  private Object currentTarget_;
  private String type_;
  private Object keyCode_;
  private boolean shiftKey_;
  private boolean ctrlKey_;
  private boolean altKey_;
  private String propertyName_;
  private boolean stopPropagation_;
  private Object returnValue_;
  private boolean preventDefault_;
  private short eventPhase_;
  private boolean bubbles_ = true;
  private boolean cancelable_ = true;
  private long timeStamp_ = System.currentTimeMillis();
  
  public Event(DomNode domNode, String type)
  {
    Object target = domNode.getScriptObject();
    srcElement_ = target;
    target_ = target;
    currentTarget_ = target;
    type_ = type;
    setParentScope((SimpleScriptable)target);
    setPrototype(getPrototype(getClass()));
    setDomNode(domNode, false);
  }
  
  public static Event createPropertyChangeEvent(DomNode domNode, String propertyName)
  {
    Event event = new Event(domNode, "propertychange");
    propertyName_ = propertyName;
    return event;
  }
  
  public Event() {}
  
  void startFire()
  {
    LinkedList<Event> events = (LinkedList)Context.getCurrentContext().getThreadLocal("Event#current");
    if (events == null)
    {
      events = new LinkedList();
      Context.getCurrentContext().putThreadLocal("Event#current", events);
    }
    events.add(this);
  }
  
  void endFire()
  {
    ((LinkedList)Context.getCurrentContext().getThreadLocal("Event#current")).removeLast();
  }
  
  public Object jsxGet_srcElement()
  {
    return srcElement_;
  }
  
  public void jsxSet_srcElement(Object srcElement)
  {
    srcElement_ = srcElement;
  }
  
  public Object jsxGet_target()
  {
    return target_;
  }
  
  public void setTarget(Object target)
  {
    target_ = target;
  }
  
  public Object jsxGet_currentTarget()
  {
    return currentTarget_;
  }
  
  public void setCurrentTarget(Scriptable target)
  {
    currentTarget_ = target;
  }
  
  public String jsxGet_type()
  {
    return type_;
  }
  
  public void setEventType(String eventType)
  {
    type_ = eventType;
  }
  
  public long jsxGet_timeStamp()
  {
    return timeStamp_;
  }
  
  protected void setKeyCode(Object keyCode)
  {
    keyCode_ = keyCode;
  }
  
  public Object jsxGet_keyCode()
  {
    if (keyCode_ == null)
    {
      if (getBrowserVersion().isFirefox()) {
        return Integer.valueOf(0);
      }
      return Undefined.instance;
    }
    return keyCode_;
  }
  
  public boolean jsxGet_shiftKey()
  {
    return shiftKey_;
  }
  
  protected void setShiftKey(boolean shiftKey)
  {
    shiftKey_ = shiftKey;
  }
  
  public boolean jsxGet_ctrlKey()
  {
    return ctrlKey_;
  }
  
  protected void setCtrlKey(boolean ctrlKey)
  {
    ctrlKey_ = ctrlKey;
  }
  
  public boolean jsxGet_altKey()
  {
    return altKey_;
  }
  
  protected void setAltKey(boolean altKey)
  {
    altKey_ = altKey;
  }
  
  public int jsxGet_eventPhase()
  {
    return eventPhase_;
  }
  
  public void setEventPhase(short phase)
  {
    if ((phase != 1) && (phase != 2) && (phase != 3)) {
      throw new IllegalArgumentException("Illegal phase specified: " + phase);
    }
    eventPhase_ = phase;
  }
  
  public boolean jsxGet_bubbles()
  {
    return bubbles_;
  }
  
  public boolean jsxGet_cancelable()
  {
    return cancelable_;
  }
  
  public boolean jsxGet_cancelBubble()
  {
    return stopPropagation_;
  }
  
  public void jsxSet_cancelBubble(boolean newValue)
  {
    stopPropagation_ = newValue;
  }
  
  public void jsxFunction_stopPropagation()
  {
    stopPropagation_ = true;
  }
  
  public boolean isPropagationStopped()
  {
    return stopPropagation_;
  }
  
  public Object jsxGet_returnValue()
  {
    return returnValue_;
  }
  
  public String jsxGet_propertyName()
  {
    return propertyName_;
  }
  
  public void jsxSet_returnValue(Object returnValue)
  {
    returnValue_ = returnValue;
  }
  
  public void jsxFunction_initEvent(String type, boolean bubbles, boolean cancelable)
  {
    type_ = type;
    bubbles_ = bubbles;
    cancelable_ = cancelable;
  }
  
  public void jsxFunction_preventDefault()
  {
    preventDefault_ = true;
  }
  
  public boolean isAborted(ScriptResult result)
  {
    boolean ie = getBrowserVersion().isIE();
    return (ScriptResult.isFalse(result)) || ((!ie) && (preventDefault_)) || ((ie) && (Boolean.FALSE.equals(returnValue_)));
  }
  
  public String toString()
  {
    StringBuilder buffer = new StringBuilder("Event ");
    buffer.append(jsxGet_type());
    buffer.append(" (");
    buffer.append("Current Target: ");
    buffer.append(currentTarget_);
    buffer.append(");");
    return buffer.toString();
  }
  
  public boolean applies(DomNode node)
  {
    if (("blur".equals(jsxGet_type())) || ("focus".equals(jsxGet_type()))) {
      return ((node instanceof SubmittableElement)) || ((node instanceof HtmlAnchor)) || ((node instanceof HtmlArea));
    }
    return true;
  }
}

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

import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.ElementNotFoundException;
import com.gargoylesoftware.htmlunit.SgmlPage;
import com.gargoylesoftware.htmlunit.WebRequestSettings;
import com.gargoylesoftware.htmlunit.WebR
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-2019. Infinite Loop Ltd