htmlunit-2.7

et_ = w3cRange.getStartOffset();
    
    DomNode domNodeEndContainer = (DomNode)w3cRange.getEndContainer();
    endContainer_ = ((Node)domNodeEndContainer.getScriptObject());
    endOffset_ = w3cRange.getEndOffset();
  }
  
  public Object getDefaultValue(Class<?> hint)
  {
    return toW3C().toString();
  }
  
  public Object jsxGet_startContainer()
  {
    if (startContainer_ == null) {
      return Context.getUndefinedValue();
    }
    return startContainer_;
  }
  
  public Object jsxGet_endContainer()
  {
    if (endContainer_ == null) {
      return Context.getUndefinedValue();
    }
    return endContainer_;
  }
  
  public int jsxGet_startOffset()
  {
    return startOffset_;
  }
  
  public int jsxGet_endOffset()
  {
    return endOffset_;
  }
  
  public void jsxFunction_setStart(Node refNode, int offset)
  {
    if (refNode == null) {
      throw Context.reportRuntimeError("It is illegal to call Range.setStart() with a null node.");
    }
    startContainer_ = refNode;
    startOffset_ = offset;
  }
  
  public void jsxFunction_setStartAfter(Node refNode)
  {
    if (refNode == null) {
      throw Context.reportRuntimeError("It is illegal to call Range.setStartAfter() with a null node.");
    }
    startContainer_ = refNode.jsxGet_parentNode();
    startOffset_ = (getPositionInContainer(refNode) + 1);
  }
  
  public void jsxFunction_setStartBefore(Node refNode)
  {
    if (refNode == null) {
      throw Context.reportRuntimeError("It is illegal to call Range.setStartBefore() with a null node.");
    }
    startContainer_ = refNode.jsxGet_parentNode();
    startOffset_ = getPositionInContainer(refNode);
  }
  
  private int getPositionInContainer(Node refNode)
  {
    int i = 0;
    Node node = refNode;
    while (node.jsxGet_previousSibling() != null)
    {
      node = node.jsxGet_previousSibling();
      i++;
    }
    return i;
  }
  
  public boolean jsxGet_collapsed()
  {
    return (startContainer_ == endContainer_) && (startOffset_ == endOffset_);
  }
  
  public void jsxFunction_setEnd(Node refNode, int offset)
  {
    if (refNode == null) {
      throw Context.reportRuntimeError("It is illegal to call Range.setEnd() with a null node.");
    }
    endContainer_ = refNode;
    endOffset_ = offset;
  }
  
  public void jsxFunction_setEndAfter(Node refNode)
  {
    if (refNode == null) {
      throw Context.reportRuntimeError("It is illegal to call Range.setEndAfter() with a null node.");
    }
    endContainer_ = refNode.jsxGet_parentNode();
    endOffset_ = (getPositionInContainer(refNode) + 1);
  }
  
  public void jsxFunction_setEndBefore(Node refNode)
  {
    if (refNode == null) {
      throw Context.reportRuntimeError("It is illegal to call Range.setEndBefore() with a null node.");
    }
    startContainer_ = refNode.jsxGet_parentNode();
    startOffset_ = getPositionInContainer(refNode);
  }
  
  public void jsxFunction_selectNodeContents(Node refNode)
  {
    startContainer_ = refNode;
    startOffset_ = 0;
    endContainer_ = refNode;
    endOffset_ = refNode.jsxGet_childNodes().jsxGet_length();
  }
  
  public void jsxFunction_selectNode(Node refNode)
  {
    jsxFunction_setStartBefore(refNode);
    jsxFunction_setEndAfter(refNode);
  }
  
  public void jsxFunction_collapse(boolean toStart)
  {
    if (toStart)
    {
      endContainer_ = startContainer_;
      endOffset_ = startOffset_;
    }
    else
    {
      startContainer_ = endContainer_;
      startOffset_ = endOffset_;
    }
  }
  
  public Object jsxGet_commonAncestorContainer()
  {
    Node ancestor = getCommonAncestor();
    if (ancestor == null) {
      return Context.getUndefinedValue();
    }
    return ancestor;
  }
  
  private Node getCommonAncestor()
  {
    List<Node> startAncestors = getAncestorsAndSelf(startContainer_);
    List<Node> endAncestors = getAncestorsAndSelf(endContainer_);
    List<Node> commonAncestors = ListUtils.intersection(startAncestors, endAncestors);
    if (commonAncestors.isEmpty()) {
      return null;
    }
    return (Node)commonAncestors.get(commonAncestors.size() - 1);
  }
  
  private List<Node> getAncestorsAndSelf(Node node)
  {
    List<Node> ancestors = new ArrayList();
    Node ancestor = node;
    while (ancestor != null)
    {
      ancestors.add(0, ancestor);
      ancestor = ancestor.jsxGet_parentNode();
    }
    return ancestors;
  }
  
  public Object jsxFunction_createContextualFragment(String valueAsString)
  {
    SgmlPage page = startContainer_.getDomNodeOrDie().getPage();
    DomDocumentFragment fragment = new DomDocumentFragment(page);
    HTMLElement.parseHtmlSnippet(fragment, true, valueAsString);
    return fragment.getScriptObject();
  }
  
  public Object jsxFunction_extractContents()
  {
    return toW3C().extractContents().getScriptObject();
  }
  
  public SimpleRange toW3C()
  {
    return new SimpleRange(startContainer_.getDomNodeOrNull(), startOffset_, endContainer_.getDomNodeOrDie(), endOffset_);
  }
}

/* Location:
 * Qualified Name:     com.gargoylesoftware.htmlunit.javascript.host.Range
 * 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.javascript.SimpleScriptable;
import com.gargoylesoftware.htmlunit.javascript.host.xml.XMLDocument;
import com.gargoylesoftware.htmlunit.xml.XmlPage;

public class DOMImplementation
  extends SimpleScriptable
{
  private static final long serialVersionUID = -6824157544527299635L;
  
  public boolean jsxFunction_hasFeature(String feature, String version)
  {
    if (getBrowserVersion().isIE())
    {
      if (("HTML".equals(feature)) && ("1.0".equals(version))) {
        return true;
      }
    }
    else
    {
      if (("HTML".equals(feature)) && (("1.0".equals(version)) || ("2.0".equals(version)))) {
        return true;
      }
      if (("XML".equals(feature)) && (("1.0".equals(version)) || ("2.0".equals(version)))) {
        return true;
      }
      if (("CSS2".equals(feature)) && ("2.0".equals(version))) {
        return true;
      }
      if (("XPath".equals(feature)) && ("3.0".equals(version))) {
        return true;
      }
    }
    return false;
  }
  
  public XMLDocument jsxFunction_createDocument(String namespaceURI, String qualifiedName, Object doctype)
  {
    XMLDocument document = new XMLDocument(getWindow().getWebWindow());
    document.setParentScope(getParentScope());
    document.setPrototype(getPrototype(document.getClass()));
    if ((qualifiedName != null) && (qualifiedName.length() != 0))
    {
      XmlPage page = (XmlPage)document.getDomNodeOrDie();
      page.appendChild(page.createXmlElementNS(namespaceURI, qualifiedName));
    }
    return document;
  }
}

/* Location:
 * Qualified Name:     com.gargoylesoftware.htmlunit.javascript.host.DOMImplementation
 * 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.DomAttr;
import com.gargoylesoftware.htmlunit.html.DomElement;
import com.gargoylesoftware.htmlunit.html.DomText;

public class Attr
  extends Node
{
  private static final long serialVersionUID = 3256441425892750900L;
  
  public void detachFromParent()
  {
    DomAttr domNode = getDomNodeOrDie();
    DomElement parent = (DomElement)domNode.getParentNode();
    if (parent != null) {
      domNode.setValue(parent.getAttribute(jsxGet_name()));
    }
    domNode.remove();
  }
  
  public boolean jsxGet_isId()
  {
    return getDomNodeOrDie().isId();
  }
  
  public boolean jsxGet_expando()
  {
    return true;
  }
  
  public String jsxGet_name()
  {
    return getDomNodeOrDie().getName();
  }
  
  public String jsxGet_nodeValue()
  {
    return jsxGet_value();
  }
  
  public Object jsxGet_ownerElement()
  {
    DomElement parent = getDomNodeOrDie().getOwnerElement();
    if (parent != null) {
      return parent.getScriptObject();
    }
    return null;
  }
  
  public Node jsxGet_parentNode()
  {
    return null;
  }
  
  public boolean jsxGet_specified()
  {
    return getDomNodeOrDie().getSpecified();
  }
  
  public String jsxGet_value()
  {
    return getDomNodeOrDie().getValue();
  }
  
  public void jsxSet_value(String value)
  {
    getDomNodeOrDie().setValue(value);
  }
  
  public Node jsxGet_firstChild()
  {
    return jsxGet_lastChild();
  }
  
  public Node jsxGet_lastChild()
  {
    if (getBrowserVersion().isFirefox())
    {
      DomText text = new DomText(getDomNodeOrDie().getPage(), jsxGet_nodeValue());
      return (Node)text.getScriptObject();
    }
    return null;
  }
  
  public DomAttr getDomNodeOrDie()
    throws IllegalStateException
  {
    return (DomAttr)super.getDomNodeOrDie();
  }
}

/* Location:
 * Qualified Name:     com.gargoylesoftware.htmlunit.javascript.host.Attr
 * 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.html.HTMLElement;

public class BoxObject
  extends SimpleScriptable
{
  private static final long serialVersionUID = -6650009325965623469L;
  private final HTMLElement element_;
  
  public BoxObject()
  {
    this(null);
  }
  
  public BoxObject(HTMLElement element)
  {
    element_ = element;
  }
  
  public HTMLElement jsxGet_element()
  {
    return element_;
  }
  
  public Object jsxGet_firstChild()
  {
    return element_.jsxGet_firstChild();
  }
  
  public Object jsxGet_lastChild()
  {
    return element_.jsxGet_lastChild();
  }
  
  public Object jsxGet_nextSibling()
  {
    return element_.jsxGet_nextSibling();
  }
  
  public Object jsxGet_previousSibling()
  {
    return element_.jsxGet_previousSibling();
  }
  
  public int jsxGet_x()
  {
    return element_.getPosX();
  }
  
  public int jsxGet_y()
  {
    return element_.getPosY();
  }
  
  public int jsxGet_screenX()
  {
    return jsxGet_x();
  }
  
  public int jsxGet_screenY()
  {
    return jsxGet_y() + 121;
  }
  
  public int jsxGet_width()
  {
    return element_.jsxGet_clientWidth();
  }
  
  public int jsxGet_height()
  {
    return element_.jsxGet_clientHeight();
  }
}

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

import com.gargoylesoftware.htmlunit.html.DomElement;
import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable;
import com.gargoylesoftware.htmlunit.xml.XmlUtil;

public class XPathNSResolver
  extends SimpleScriptable
{
  private static final long serialVersionUID = -6737970273175202932L;
  private Object element_;
  
  public void setElement(Node element)
  {
    element_ = element;
  }
  
  public String jsxFunction_lookupNamespaceURI(String prefix)
  {
    return XmlUtil.lookupNamespaceURI((DomElement)((SimpleScriptable)element_).getDomNodeOrDie(), prefix);
  }
}

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

import com.gargoylesoftware.htmlunit.html.DomNode;
import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable;
import java.util.List;
import net.sourceforge.htmlunit.corejs.javascript.Context;

public class XPathResult
  extends SimpleScriptable
{
  private static final long serialVersionUID = 261617209266957657L;
  public static final int ANY_TYPE = 0;
  public static final int NUMBER_TYPE = 1;
  public static final int STRING_TYPE = 2;
  public static final int BOOLEAN_TYPE = 3;
  public static final int UNORDERED_NODE_ITERATOR_TYPE = 4;
  public static final int ORDERED_NODE_ITERATOR_TYPE = 5;
  public static final int UNORDERED_NODE_SNAPSHOT_TYPE = 6;
  public static final int ORDERED_NODE_SNAPSHOT_TYPE = 7;
  public static final int ANY_UNORDERED_NODE_TYPE = 8;
  public static final int FIRST_ORDERED_NODE_TYPE = 9;
  private List<? extends Object> result_;
  private int resultType_;
  private int iteratorIndex_;
  
  void init(List<? extends Object> result, int type)
  {
    result_ = result;
    resultType_ = -1;
    if (result_.size() == 1)
    {
      Object o = result_.get(0);
      if ((o instanceof Number)) {
        resultType_ = 1;
      } else if ((o instanceof String)) {
        resultType_ = 2;
      } else if ((o instanceof Boolean)) {
        resultType_ = 3;
      }
    }
    if (resultType_ == -1) {
      if (type != 0) {
        resultType_ = type;
      } else {
        resultType_ = 4;
      }
    }
    iteratorIndex_ = 0;
  }
  
  public int jsxGet_resultType()
  {
    return resultType_;
  }
  
  public int jsxGet_snapshotLength()
  {
    if ((resultType_ != 6) && (resultType_ != 7)) {
      throw Context.reportRuntimeError("Cannot get snapshotLength for type: " + resultType_);
    }
    return result_.size();
  }
  
  public Node jsxGet_singleNodeValue()
  {
    if ((resultType_ != 8) && (resultType_ != 9)) {
      throw Context.reportRuntimeError("Cannot get singleNodeValue for type: " + resultType_);
    }
    if (!result_.isEmpty()) {
      return (Node)((DomNode)result_.get(0)).getScriptObject();
    }
    return null;
  }
  
  public Node jsxFunction_iterateNext()
  {
    if ((resultType_ != 4) && (resultType_ != 5)) {
      throw Context.reportRuntimeError("Cannot get iterateNext for type: " + resultType_);
    }
    if (iteratorIndex_ < result_.size()) {
      return (Node)((DomNode)result_.get(iteratorIndex_++)).getScriptObject();
    }
    return null;
  }
  
  public Node jsxFunction_snapshotItem(int index)
  {
    if ((resultType_ != 6) && (resultType_ != 7)) {
      throw Context.reportRuntimeError("Cannot get snapshotLength for type: " + resultType_);
    }
    if ((index >= 0) && (index < result_.size())) {
      return (Node)((DomNode)result_.get(index)).getScriptObject();
    }
    return null;
  }
  
  public double jsxGet_numberValue()
  {
    if (resultType_ != 1) {
      throw Context.reportRuntimeError("Cannot get numberValue for type: " + resultType_);
    }
    return ((Number)result_.get(0)).doubleValue();
  }
  
  public boolean jsxGet_booleanValue()
  {
    if (resultType_ != 3) {
      throw Context.reportRuntimeError("Cannot get booleanValue for type: " + resultType_);
    }
    return ((Boolean)result_.get(0)).booleanValue();
  }
  
  public String jsxGet_stringValue()
  {
    if (resultType_ != 2) {
      throw Context.reportRuntimeError("Cannot get stringValue for type: " + resultType_);
    }
    return (String)result_.get(0);
  }
}

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

import com.gargoylesoftware.htmlunit.javascript.ScriptableWithFallbackGetter;
import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable;
import java.util.ArrayList;
import java.util.List;
import net.sourceforge.htmlunit.corejs.javascript.Context;
import net.sourceforge.htmlunit.corejs.javascript.Scriptable;

public class SimpleArray
  extends SimpleScriptable
  implements ScriptableWithFallbackGetter
{
  private static final long serialVersionUID = 8025124211062703153L;
  private final List<Object> elements_ = new ArrayList();
  
  public Object jsxFunction_item(int index)
  {
    return elements_.get(index);
  }
  
  public Object getWithFallback(String name)
  {
    Object response = jsxFunction_namedItem(name);
    if (response != null) {
      return response;
    }
    return Context.getUndefinedValue();
  }
  
  public final Object get(int index, Scriptable start)
  {
    SimpleArray array = (SimpleArray)start;
    List<Object> elements = elements_;
    if ((index >= 0) && (index < elements.size())) {
      return elements.get(index);
    }
    return null;
  }
  
  public Object jsxFunction_namedItem(String name)
  {
    for (Object element : elements_) {
      if (name.equals(getItemName(element))) {
        return element;
      }
    }
    return null;
  }
  
  protected String getItemName(Object element)
  {
    return null;
  }
  
  public int jsxGet_length()
  {
    return elements_.size();
  }
  
  void add(Object element)
  {
    elements_.add(element);
  }
}

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

public class MimeTypeArray
  extends SimpleArray
{
  private static final long serialVersionUID = 6216803993814539605L;
  
  protected String getItemName(Object element)
  {
    return ((MimeType)element).jsxGet_type();
  }
}

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

import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.impl.SelectableTextInput;
import com.gargoylesoftware.htmlunit.html.impl.SimpleRange;
import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable;
import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement;
import net.sourceforge.htmlunit.corejs.javascript.Context;
import net.sourceforge.htmlunit.corejs.javascript.Undefined;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Node;
import org.w3c.dom.ranges.Range;

public class TextRange
  extends SimpleScriptable
{
  private static final long serialVersionUID = -3763822832184277966L;
  private static final Log LOG = LogFactory.getLog(TextRange.class);
  private Range range_;
  
  public TextRange() {}
  
  public TextRange(HTMLElement elt)
  {
    range_ = new SimpleRange(elt.getDomNodeOrDie());
  }
  
  public TextRange(Range range)
  {
    range_ = range.cloneRange();
  }
  
  public String jsxGet_text()
  {
    return range_.toString();
  }
  
  public void jsxSet_text(String text)
  {
    if ((range_.getStartContainer() == range_.getEndContainer()) && ((range_.getStartContainer() instanceof SelectableTextInput)))
    {
      SelectableTextInput input = (SelectableTextInput)range_.getStartContainer();
      String oldValue = input.getText();
      input.setText(oldValue.substring(0, input.getSelectionStart()) + text + oldValue.substring(input.getSelectionEnd()));
    }
  }
  
  public String jsxGet_htmlText()
  {
    Node node = range_.getCommonAncestorContainer();
    HTMLElement element = (HTMLElement)getScriptableFor(node);
    return element.jsxGet_outerHTML();
  }
  
  public Object jsxFunction_duplicate()
  {
    TextRange range = new TextRange(range_.cloneRange());
    range.setParentScope(getParentScope());
    range.setPrototype(getPrototype());
    return range;
  }
  
  public Object jsxFunction_parentElement()
  {
    Node parent = range_.getCommonAncestorContainer();
    return getScriptableFor(parent);
  }
  
  public void jsxFunction_collapse(boolean toStart)
  {
    range_.collapse(toStart);
  }
  
  public void jsxFunction_select()
  {
    HtmlPage page = (HtmlPage)getWindow().getDomNodeOrDie();
    page.setSelectionRange(range_);
  }
  
  public int jsxFunction_moveStart(String unit, Object count)
  {
    if (!"character".equals(unit))
    {
      LOG.warn("moveStart('" + unit + "') is not yet supported");
      return 0;
    }
    int c = 1;
    if (count != Undefined.instance) {
      c = (int)Context.toNumber(count);
    }
    if ((range_.getStartContainer() == range_.getEndContainer()) && ((range_.getStartContainer() instanceof SelectableTextInput)))
    {
      SelectableTextInput input = (SelectableTextInput)range_.getStartContainer();
      range_.setStart(input, range_.getStartOffset() + c);
    }
    return c;
  }
  
  public int jsxFunction_moveEnd(String unit, Object count)
  {
    if (!"character".equals(unit))
    {
      LOG.warn("moveEnd('" + unit + "') is not yet supported");
      return 0;
    }
    int c = 1;
    if (count != Undefined.instance) {
      c = (int)Context.toNumber(count);
    }
    if ((range_.getStartContainer() == range_.getEndContainer()) && ((range_.getStartContainer() instanceof SelectableTextInput)))
    {
      SelectableTextInput input = (SelectableTextInput)range_.getStartContainer();
      range_.setEnd(input, range_.getEndOffset() + c);
    }
    return c;
  }
  
  public void jsxFunction_moveToElementText(HTMLElement element)
  {
    range_.selectNode(element.getDomNodeOrDie());
  }
  
  public boolean jsxFunction_inRange(TextRange other)
  {
    Range otherRange = range_;
    
    Node start = range_.getStartContainer();
    Node otherStart = otherRange.getStartContainer();
    if (otherStart == null) {
      return false;
    }
    short startComparison = start.compareDocumentPosition(otherStart);
    boolean startNodeBefore = (startComparison == 0) || ((startComparison & 0x8) != 0) || ((startComparison & 0x2) != 0);
    if ((startNodeBefore) && ((start != otherStart) || (range_.getStartOffset() <= otherRange.getStartOffset())))
    {
      Node end = range_.getEndContainer();
      Node otherEnd = otherRange.getEndContainer();
      short endComparison = end.compareDocumentPosition(otherEnd);
      boolean endNodeAfter = (endComparison == 0) || ((endComparison & 0x8) != 0) || ((endComparison & 0x4) != 0);
      if ((endNodeAfter) && ((end != otherEnd) || (range_.getEndOffset() >= otherRange.getEndOffset()))) {
        return true;
      }
    }
    return false;
  }
}

/* Location:
 * Qualified Name:     com.gargoylesoftware.htmlunit.javascript.host.TextRange
 * 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 TextRectangle
  extends SimpleScriptable
{
  private static final long serialVersionUID = 8045028432279353283L;
  private int bottom_;
  private int left_;
  private int right_;
  private int top_;
  
  public TextRectangle() {}
  
  public TextRectangle(int bottom, int left, int right, int top)
  {
    bottom_ = bottom;
    left_ = left;
    right_ = right;
    top_ = top;
  }
  
  public void jsxSet_bottom(int bottom)
  {
    bottom_ = bottom;
  }
  
  public int jsxGet_bottom()
  {
    return bottom_;
  }
  
  public void jsxSet_left(int left)
  {
    left_ = left;
  }
  
  public int jsxGet_left()
  {
    return left_;
  }
  
  public void jsxSet_right(int right)
  {
    right_ = right;
  }
  
  public int jsxGet_right()
  {
    return right_;
  }
  
  public void jsxSet_top(int top)
  {
    top_ = top;
  }
  
  public int jsxGet_top()
  {
    return top_;
  }
}

/* Location:
 * Qualified Name:     com.gargoylesoftware.htmlunit.javascript.host.TextRectangle
 * 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 net.sourceforge.htmlunit.corejs.javascript.ScriptableObject;

public class Namespace
  extends SimpleScriptable
{
  private static final long serialVersionUID = -5554898606769625960L;
  private String name_;
  private String urn_;
  
  @Deprecated
  public Namespace() {}
  
  public Namespace(ScriptableObject parentScope, String name, String urn)
  {
    setParentScope(parentScope);
    setPrototype(getPrototype(getClass()));
    name_ = name;
    urn_ = urn;
  }
  
  public String jsxGet_name()
  {
    return name_;
  }
  
  public String jsxGet_urn()
  {
    return urn_;
  }
  
  public void jsxSet_urn(String urn)
  {
    urn_ = urn;
  }
}

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

import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable;

public class XMLDOMParseError
  extends SimpleScriptable
{
  private static final long serialVersionUID = 8435555857574741660L;
  private int errorCode_;
  private int filepos_;
  private int line_;
  private int linepos_;
  private String reason_ = "";
  private String srcText_ = "";
  private String url_ = "";
  
  public void jsConstructor() {}
  
  public int jsxGet_errorCode()
  {
    return errorCode_;
  }
  
  public int jsxGet_filepos()
  {
    return filepos_;
  }
  
  public int jsxGet_line()
  {
    return line_;
  }
  
  public int jsxGet_linepos()
  {
    return linepos_;
  }
  
  public String jsxGet_reason()
  {
    return reason_;
  }
  
  public String jsxGet_srcText()
  {
    return srcText_;
  }
  
  public String jsxGet_url()
  {
    return url_;
  }
  
  void setErrorCode(int errorCode)
  {
    errorCode_ = errorCode;
  }
  
  void setFilepos(int filepos)
  {
    filepos_ = filepos;
  }
  
  void setLine(int line)
  {
    line_ = line;
  }
  
  void setLinepos(int linepos)
  {
    linepos_ = linepos;
  }
  
  void setReason(String reason)
  {
    reason_ = reason;
  }
  
  void setSrcText(String srcText)
  {
    srcText_ = srcText;
  }
  
  void setUrl(String url)
  {
    url_ = url;
  }
}

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

import com.gargoylesoftware.htmlunit.javascript.host.Attr;
import org.apache.commons.lang.StringEscapeUtils;

public class XMLAttr
  extends Attr
{
  private static final long serialVersionUID = -9062357417620766444L;
  
  public String jsxGet_text()
  {
    return jsxGet_value();
  }
  
  public void jsxSet_text(String value)
  {
    jsxSet_value(value);
  }
  
  public String jsxGet_xml()
  {
    StringBuilder sb = new StringBuilder();
    sb.append(jsxGet_name());
    sb.append('=');
    sb.append('"');
    sb.append(StringEscapeUtils.escapeXml(jsxGet_value()));
    sb.append('"');
    return sb.toString();
  }
}

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

import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.html.DomAttr;
import com.gargoylesoftware.htmlunit.html.DomElement;
import com.gargoylesoftware.htmlunit.html.DomNode;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable;
import com.gargoylesoftware.htmlunit.javascript.host.Document;
import com.gargoylesoftware.htmlunit.javascript.host.DocumentFragment;
import com.gargoylesoftware.htmlunit.javascript.host.Element;
import com.gargoylesoftware.htmlunit.javascript.host.Node;
import com.gargoylesoftware.htmlunit.util.StringUtils;
import org.w3c.dom.NamedNodeMap;

public class XMLSerializer
  extends SimpleScriptable
{
  private static final long serialVersionUID = -934136191731299896L;
  
  public void jsConstructor() {}
  
  public String jsxFunction_serializeToString(Node root)
  {
    if ((root instanceof Document)) {
      root = ((Document)root).jsxGet_documentElement();
    } else if ((root instanceof DocumentFragment)) {
      root = root.jsxGet_firstChild();
    }
    if ((root instanceof Element))
    {
      StringBuilder buffer = new StringBuilder();
      boolean isIE = getBrowserVersion().isIE();
      toXml(1, root.getDomNodeOrDie(), buffer, isIE);
      if (isIE) {
        buffer.append('\r').append('\n');
      }
      return buffer.toString();
    }
    if (root == null) {
      return "";
    }
    return root.getDomNodeOrDie().asXml();
  }
  
  private void toXml(int indent, DomNode node, StringBuilder buffer, boolean isIE)
  {
    String nodeName = node.getNodeName();
    if ((!isIE) && ((node.getPage() instanceof HtmlPage))) {
      nodeName = nodeName.toUpperCase();
    }
    buffer.append('<').append(nodeName);
    if ((node.getNamespaceURI() != null) && (node.getPrefix() != null))
    {
      boolean sameNamespace = false;
      for (DomNode parentNode = node.getParentNode(); (parentNode instanceof DomElement); parentNode = parentNode.getParentNode()) {
        if (node.getNamespaceURI().equals(parentNode.getNamespaceURI())) {
          sameNamespace = true;
        }
      }
      if ((node.getParentNode() == null) || (!sameNamespace)) {
        ((DomElement)node).setAttribute("xmlns:" + node.getPrefix(), node.getNamespaceURI());
      }
    }
    NamedNodeMap attributesMap = node.getAttributes();
    for (int i = 0; i < attributesMap.getLength(); i++)
    {
      DomAttr attrib = (DomAttr)attributesMap.item(i);
      buffer.append(' ').append(attrib.getQualifiedName()).append('=').append('"').append(attrib.getValue()).append('"');
    }
    boolean startTagClosed = false;
    for (DomNode child : node.getChildren())
    {
      if (!startTagClosed)
      {
        buffer.append('>');
        startTagClosed = true;
      }
      switch (child.getNodeType())
      {
      case 1: 
        toXml(indent + 1, child, buffer, isIE);
        break;
      case 3: 
        String value = child.getNodeValue();
        value = StringUtils.escapeXmlChars(value);
        if ((isIE) && (value.trim().length() == 0))
        {
          buffer.append('\r').append('\n');
          DomNode sibling = child.getNextSibling();
          if ((sibling != null) && (sibling.getNodeType() == 1)) {
            for (int i = 0; i < indent; i++) {
              buffer.append('\t');
            }
          }
        }
        else
        {
          buffer.append(value);
        }
        break;
      case 4: 
      case 8: 
        buffer.append(child.asXml());
      }
    }
    if (!startTagClosed) {
      buffer.append('/').append('>');
    } else {
      buffer.append('<').append('/').append(node.getNodeName()).append('>');
    }
  }
}

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

import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.HttpMethod;
import com.gargoylesoftware.htmlunit.SgmlPage;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.WebRequestSettings;
import com.gargoylesoftware.htmlunit.WebResponse;
import com.gargoylesoftware.htmlunit.WebResponseData;
import com.gargoylesoftware.htmlunit.WebResponseImpl;
import com.gargoylesoftware.htmlunit.WebWindow;
import com.gargoylesoftware.htmlunit.html.DomAttr;
import com.gargoylesoftware.htmlunit.html.DomCDataSection;
import com.gargoylesoftware.htmlunit.html.DomElement;
import com.gargoylesoftware.htmlunit.html.DomNode;
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable;
import com.gargoylesoftware.htmlunit.javascript.host.Attr;
import com.gargoylesoftware.htmlunit.javascript.host.Document;
import com.gargoylesoftware.htmlunit.javascript.host.Element;
import com.gargoylesoftware.htmlunit.javascript.host.Window;
import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLCollection;
import com.gargoylesoftware.htmlunit.util.NameValuePair;
import com.gargoylesoftware.htmlunit.xml.XmlPage;
import java.io.IOException;
import java.net.URL;
import java.util.Collections;
import java.util.List;
import net.sourceforge.htmlunit.corejs.javascript.Context;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class XMLDocument
  extends Document
{
  private static final long serialVersionUID = 1225601711396578064L;
  private static final Log LOG = LogFactory.getLog(XMLDocument.class);
  private boolean async_ = true;
  private boolean preserveWhiteSpace_;
  private XMLDOMParseError parseError_;
  
  public XMLDocument()
  {
    this(null);
  }
  
  public XMLDocument(WebWindow enclosingWindow)
  {
    if (enclosingWindow != null) {
      try
      {
        XmlPage page = new XmlPage((WebResponse)null, enclosingWindow);
        setDomNode(page);
      }
      catch (IOException e)
      {
        throw Context.reportRuntimeError("IOException: " + e);
      }
    }
  }
  
  public void jsxSet_async(boolean async)
  {
    async_ = async;
  }
  
  public boolean jsxGet_async()
  {
    return async_;
  }
  
  public boolean jsxFunction_load(String xmlSource)
  {
    if (async_) {
      LOG.debug("XMLDocument.load(): 'async' is true, currently treated as false.");
    }
    try
    {
      HtmlPage htmlPage = (HtmlPage)getWindow().getWebWindow().getEnclosedPage();
      WebRequestSettings settings = new WebRequestSettings(htmlPage.getFullyQualifiedUrl(xmlSource));
      WebResponse webResponse = getWindow().getWebWindow().getWebClient().loadWebResponse(settings);
      XmlPage page = new XmlPage(webResponse, getWindow().getWebWindow(), false);
      setDomNode(page);
      return true;
    }
    catch (IOException e)
    {
      XMLDOMParseError parseError = jsxGet_parseError();
      parseError.setErrorCode(-1);
      parseError.setFilepos(1);
      parseError.setLine(1);
      parseError.setLinepos(1);
      parseError.setReason(e.getMessage());
      parseError.setSrcText("xml");
      parseError.setUrl(xmlSource);
      LOG.debug("Error parsing XML from '" + xmlSource + "'", e);
    }
    return false;
  }
  
  public boolean jsxFunction_loadXML(String strXML)
  {
    try
    {
      List<NameValuePair> emptyList = Collections.emptyList();
      WebResponseData data = new WebResponseData(strXML.getBytes(), 200, null, emptyList);
      WebResponse webResponse = new WebResponseImpl(data, (URL)null, (HttpMethod)null, 0L);
      XmlPage page = new XmlPage(webResponse, getWindow().getWebWindow());
      setDomNode(page);
      return true;
    }
    catch (IOException e)
    {
      LOG.debug("Error parsing XML\n" + strXML, e);
    }
    return false;
  }
  
  public SimpleScriptable makeScriptableFor(DomNode domNode)
  {
    SimpleScriptable scriptable;
    if (((domNode instanceof DomElement)) && (!(domNode instanceof HtmlElement)))
    {
      scriptable = new Element();
    }
    else
    {
      SimpleScriptable scriptable;
      if ((domNode instanceof DomAttr))
      {
        Attr attribute;
        Attr attribute;
        if (getPage().getWebClient().getBrowserVersion().isIE()) {
          attribute = new XMLAttr();
        } else {
          attribute = new Attr();
        }
        scriptable = attribute;
      }
      else
      {
        return super.makeScriptableFor(domNode);
      }
    }
    SimpleScriptable scriptable;
    scriptable.setPrototype(getPrototype(scriptable.getClass()));
    scriptable.setParentScope(getParentScope());
    scriptable.setDomNode(domNode);
    return scriptable;
  }
  
  protected void initParentScope(DomNode domNode, SimpleScriptable scriptable)
  {
    scriptable.setParentScope(getParentScope());
  }
  
  public XMLDOMParseError jsxGet_parseError()
  {
    if (parseError_ == null)
    {
      parseError_ = new XMLDOMParseError();
      parseError_.setPrototype(getPrototype(parseError_.getClass()));
      parseError_.setParentScope(getParentScope());
    }
    return parseError_;
  }
  
  public String jsxGet_xml()
  {
    XMLSerializer seralizer = new XMLSerializer();
    seralizer.setParentScope(getWindow());
    seralizer.setPrototype(getPrototype(seralizer.getClass()));
    return seralizer.jsxFunction_serializeToString(jsxGet_documentElement());
  }
  
  public boolean jsxGet_preserveWhiteSpace()
  {
    return preserveWhiteSpace_;
  }
  
  public void jsxSet_preserveWhiteSpace(boolean preserveWhiteSpace)
  {
    preserveWhiteSpace_ = preserveWhiteSpace;
  }
  
  public void jsxFunction_setProperty(String name, String value) {}
  
  public HTMLCollection jsxFunction_selectNodes(String expression)
  {
    HTMLCollection collection = new HTMLCollection(this);
    collection.init(getDomNodeOrDie(), expression);
    return collection;
  }
  
  public Object jsxFunction_selectSingleNode(String expression)
  {
    HTMLCollection collection = jsxFunction_selectNodes(expression);
    if (collection.jsxGet_length() > 0) {
      return collection.get(0, collection);
    }
    return null;
  }
  
  public HTMLCollection jsxFunction_getElementsByTagName(String tagName)
  {
    HTMLCollection collection = new HTMLCollection(this);
    collection.init(getDomNodeOrDie().getFirstChild(), "//*[local-name()='" + tagName + "']");
    return collection;
  }
  
  public Object jsxFunction_getElementById(String id)
  {
    XmlPage xmlPage = (XmlPage)getDomNodeOrDie();
    Object domElement = xmlPage.getFirstByXPath("//*[@id = \"" + id + "\"]");
    if (domElement == null) {
      return null;
    }
    if ((domElement instanceof HtmlElement)) {
      return ((HtmlElement)domElement).getScriptObject();
    }
    LOG.debug("getElementById(" + id + "): no HTML DOM node found with this ID");
    return null;
  }
  
  public Object jsxFunction_nodeFromID(String id)
  {
    return null;
  }
  
  public Object jsxFunction_createProcessingInstruction(String target, String data)
  {
    DomNode node = ((XmlPage)getPage()).createProcessingInstruction(target, data);
    return getScriptableFor(node);
  }
  
  public Object jsxFunction_createCDATASection(String data)
  {
    DomCDataSection node = ((XmlPage)getPage()).createCDATASection(data);
    return getScriptableFor(node);
  }
  
  public Object jsxFunction_createNode(Object type, String name, Object namespaceURI)
  {
    switch ((short)(int)Context.toNumber(type))
    {
    case 1: 
      return jsxFunction_createElementNS((String)namespaceURI, name);
    case 2: 
      return jsxFunction_createAttribute(name);
    }
    throw Context.reportRuntimeError("xmlDoc.createNode(): Unsupported type " + (short)(int)Context.toNumber(type));
  }
}

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

import net.sourceforge.htmlunit.corejs.javascript.Context;
import net.sourceforge.htmlunit.corejs.javascript.ContextAction;

class XMLHttpRequest$1
  implements ContextAction
{
  XMLHttpRequest$1(XMLHttpRequest paramXMLHttpRequest, Object paramObject) {}
  
  public Object run(Context cx)
  {
    cx.putThreadLocal("startingScope", val$startingScope);
    XMLHttpRequest.access$000(this$0, cx);
    return null;
  }
}

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

import com.gargoylesoftware.htmlunit.javascript.background.JavaScriptJob;
import net.sourceforge.htmlunit.corejs.javascript.ContextAction;
import net.sourceforge.htmlunit.corejs.javascript.ContextFactory;

class XMLHttpRequest$2
  extends JavaScriptJob
{
  XMLHttpRequest$2(XMLHttpRequest paramXMLHttpRequest, ContextFactory paramContextFactory, ContextAction paramContextAction) {}
  
  public void run()
  {
    val$cf.call(val$action);
  }
  
  public String toString()
  {
    return "XMLHttpRequest Job " + getId();
  }
}

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

import com.gargoylesoftware.htmlunit.WebResponse;
import com.gargoyl
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