htmlunit-2.7

onse()
  {
    return response_;
  }
}

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

import java.util.EventObject;

public final class WebWindowEvent
  extends EventObject
{
  private static final long serialVersionUID = 6693838158619061745L;
  private final Page oldPage_;
  private final Page newPage_;
  private final int type_;
  public static final int OPEN = 1;
  public static final int CLOSE = 2;
  public static final int CHANGE = 3;
  
  public WebWindowEvent(WebWindow webWindow, int type, Page oldPage, Page newPage)
  {
    super(webWindow);
    oldPage_ = oldPage;
    newPage_ = newPage;
    switch (type)
    {
    case 1: 
    case 2: 
    case 3: 
      type_ = type;
      break;
    default: 
      throw new IllegalArgumentException("type must be one of OPEN, CLOSE, CHANGE but got " + type);
    }
  }
  
  public boolean equals(Object object)
  {
    if (getClass() == object.getClass())
    {
      WebWindowEvent event = (WebWindowEvent)object;
      return (isEqual(getSource(), event.getSource())) && (getEventType() == event.getEventType()) && (isEqual(getOldPage(), event.getOldPage())) && (isEqual(getNewPage(), event.getNewPage()));
    }
    return false;
  }
  
  public int hashCode()
  {
    return source.hashCode();
  }
  
  public Page getOldPage()
  {
    return oldPage_;
  }
  
  public Page getNewPage()
  {
    return newPage_;
  }
  
  public WebWindow getWebWindow()
  {
    return (WebWindow)getSource();
  }
  
  private boolean isEqual(Object object1, Object object2)
  {
    boolean result;
    boolean result;
    if ((object1 == null) && (object2 == null))
    {
      result = true;
    }
    else
    {
      boolean result;
      if ((object1 == null) || (object2 == null)) {
        result = false;
      } else {
        result = object1.equals(object2);
      }
    }
    return result;
  }
  
  public String toString()
  {
    StringBuilder buffer = new StringBuilder(80);
    buffer.append("WebWindowEvent(source=[");
    buffer.append(getSource());
    buffer.append("] type=[");
    switch (type_)
    {
    case 1: 
      buffer.append("OPEN");
      break;
    case 2: 
      buffer.append("CLOSE");
      break;
    case 3: 
      buffer.append("CHANGE");
      break;
    default: 
      buffer.append(type_);
    }
    buffer.append("] oldPage=[");
    buffer.append(getOldPage());
    buffer.append("] newPage=[");
    buffer.append(getNewPage());
    buffer.append("])");
    
    return buffer.toString();
  }
  
  public int getEventType()
  {
    return type_;
  }
}

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

import net.sourceforge.htmlunit.corejs.javascript.ScriptableObject;

public class DialogWindow
  extends WebWindowImpl
{
  private static final long serialVersionUID = -8851612155741170131L;
  private Object arguments_;
  
  protected DialogWindow(WebClient webClient, Object arguments)
  {
    super(webClient);
    arguments_ = arguments;
  }
  
  protected boolean isJavaScriptInitializationNeeded()
  {
    return getScriptObject() == null;
  }
  
  public WebWindow getParentWindow()
  {
    return this;
  }
  
  public WebWindow getTopWindow()
  {
    return this;
  }
  
  public void setScriptObject(Object scriptObject)
  {
    ScriptableObject so = (ScriptableObject)scriptObject;
    if (so != null) {
      so.put("dialogArguments", so, arguments_);
    }
    super.setScriptObject(scriptObject);
  }
  
  public void close()
  {
    destroyChildren();
    getWebClient().deregisterWebWindow(this);
  }
}

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

public class WebWindowNotFoundException
  extends RuntimeException
{
  private static final long serialVersionUID = 2971032116624875170L;
  private final String name_;
  
  public WebWindowNotFoundException(String name)
  {
    super("Searching for [" + name + "]");
    name_ = name;
  }
  
  public String getName()
  {
    return name_;
  }
}

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

import java.io.Serializable;

public final class FormEncodingType
  implements Serializable
{
  private static final long serialVersionUID = -7341913381207910442L;
  public static final FormEncodingType URL_ENCODED = new FormEncodingType("application/x-www-form-urlencoded");
  public static final FormEncodingType MULTIPART = new FormEncodingType("multipart/form-data");
  private final String name_;
  
  private FormEncodingType(String name)
  {
    name_ = name;
  }
  
  public String getName()
  {
    return name_;
  }
  
  public static FormEncodingType getInstance(String name)
  {
    String lowerCaseName = name.toLowerCase();
    if (MULTIPART.getName().equals(lowerCaseName)) {
      return MULTIPART;
    }
    return URL_ENCODED;
  }
  
  public String toString()
  {
    return "EncodingType[name=" + getName() + "]";
  }
}

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

public enum BrowserVersionFeatures
{
  BLUR_BEFORE_ONCHANGE,  CAN_INHERIT_CSS_PROPERTY_VALUES,  CREATEEVENT_INITALIZES_TARGET,  EXECCOMMAND_THROWS_ON_WRONG_COMMAND,  HTMLOPTION_PREVENT_DISABLED,  IGNORE_CONTENTS_OF_INNER_HEAD,  JS_FRAME_RESOLVE_URL_WITH_PARENT_WINDOW,  SET_READONLY_PROPERTIES,  STYLESHEET_HREF_EXPANDURL,  STYLESHEET_HREF_STYLE_EMPTY,  STYLESHEET_HREF_STYLE_NULL,  TEXTAREA_CRNL,  TREATS_POSITION_FIXED_LIKE_POSITION_STATIC,  XMLHTTPREQUEST_HANDLER_THIS_IS_FUNCTION;
  
  private BrowserVersionFeatures() {}
}

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

import com.gargoylesoftware.htmlunit.html.HtmlPage;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.StringTokenizer;
import net.sourceforge.htmlunit.corejs.javascript.EcmaError;
import net.sourceforge.htmlunit.corejs.javascript.JavaScriptException;
import net.sourceforge.htmlunit.corejs.javascript.RhinoException;
import net.sourceforge.htmlunit.corejs.javascript.WrappedException;

public class ScriptException
  extends RuntimeException
{
  private static final long serialVersionUID = 4788896649084231283L;
  private final String scriptSourceCode_;
  private final HtmlPage page_;
  
  public ScriptException(HtmlPage page, Throwable throwable, String scriptSourceCode)
  {
    super(getMessageFrom(throwable), throwable);
    scriptSourceCode_ = scriptSourceCode;
    page_ = page;
  }
  
  private static String getMessageFrom(Throwable throwable)
  {
    if (throwable == null) {
      return "null";
    }
    return throwable.getMessage();
  }
  
  public ScriptException(HtmlPage page, Throwable throwable)
  {
    this(page, throwable, null);
  }
  
  public void printStackTrace()
  {
    printStackTrace(System.out);
  }
  
  public void printStackTrace(PrintWriter writer)
  {
    writer.write(createPrintableStackTrace());
  }
  
  public void printStackTrace(PrintStream stream)
  {
    stream.print(createPrintableStackTrace());
  }
  
  private String createPrintableStackTrace()
  {
    StringWriter stringWriter = new StringWriter();
    PrintWriter printWriter = new PrintWriter(stringWriter);
    
    printWriter.println("======= EXCEPTION START ========");
    if (getCause() != null) {
      if ((getCause() instanceof EcmaError))
      {
        EcmaError ecmaError = (EcmaError)getCause();
        printWriter.print("EcmaError: ");
        printWriter.print("lineNumber=[");
        printWriter.print(ecmaError.lineNumber());
        printWriter.print("] column=[");
        printWriter.print(ecmaError.columnNumber());
        printWriter.print("] lineSource=[");
        printWriter.print(getFailingLine());
        printWriter.print("] name=[");
        printWriter.print(ecmaError.getName());
        printWriter.print("] sourceName=[");
        printWriter.print(ecmaError.sourceName());
        printWriter.print("] message=[");
        printWriter.print(ecmaError.getMessage());
        printWriter.print("]");
        printWriter.println();
      }
      else
      {
        printWriter.println("Exception class=[" + getCause().getClass().getName() + "]");
      }
    }
    super.printStackTrace(printWriter);
    if ((getCause() != null) && ((getCause() instanceof JavaScriptException)))
    {
      Object value = ((JavaScriptException)getCause()).getValue();
      
      printWriter.print("JavaScriptException value = ");
      if ((value instanceof Throwable)) {
        ((Throwable)value).printStackTrace(printWriter);
      } else {
        printWriter.println(value);
      }
    }
    else if ((getCause() != null) && ((getCause() instanceof WrappedException)))
    {
      WrappedException wrappedException = (WrappedException)getCause();
      printWriter.print("WrappedException: ");
      wrappedException.printStackTrace(printWriter);
      
      Throwable innerException = wrappedException.getWrappedException();
      if (innerException == null)
      {
        printWriter.println("Inside wrapped exception: null");
      }
      else
      {
        printWriter.println("Inside wrapped exception:");
        innerException.printStackTrace(printWriter);
      }
    }
    else if (getCause() != null)
    {
      printWriter.println("Enclosed exception: ");
      getCause().printStackTrace(printWriter);
    }
    if ((scriptSourceCode_ != null) && (scriptSourceCode_.length() > 0))
    {
      printWriter.println("== CALLING JAVASCRIPT ==");
      printWriter.println(scriptSourceCode_);
    }
    printWriter.println("======= EXCEPTION END ========");
    
    return stringWriter.toString();
  }
  
  public String getScriptSourceCode()
  {
    return scriptSourceCode_;
  }
  
  public String getFailingLine()
  {
    int lineNumber = getFailingLineNumber();
    if ((lineNumber == -1) || (scriptSourceCode_ == null)) {
      return "<no source>";
    }
    try
    {
      BufferedReader reader = new BufferedReader(new StringReader(scriptSourceCode_));
      for (int i = 0; i < lineNumber - 1; i++) {
        reader.readLine();
      }
      String result = reader.readLine();
      reader.close();
      return result;
    }
    catch (IOException e)
    {
      e.printStackTrace();
    }
    return "";
  }
  
  public int getFailingLineNumber()
  {
    if ((getCause() instanceof RhinoException))
    {
      RhinoException cause = (RhinoException)getCause();
      return cause.lineNumber();
    }
    return -1;
  }
  
  public HtmlPage getPage()
  {
    return page_;
  }
  
  public void printScriptStackTrace(PrintWriter writer)
  {
    StringWriter stringWriter = new StringWriter();
    PrintWriter printWriter = new PrintWriter(stringWriter);
    
    getCause().printStackTrace(printWriter);
    
    writer.print(getCause().getMessage());
    StringTokenizer st = new StringTokenizer(stringWriter.toString(), "\r\n");
    while (st.hasMoreTokens())
    {
      String line = st.nextToken();
      if (line.contains("at script"))
      {
        writer.println();
        writer.print(line.replaceFirst("at script\\.?", "at "));
      }
    }
  }
}

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

import java.io.Serializable;

public class PluginConfiguration$MimeType
  implements Serializable
{
  private static final long serialVersionUID = 3775313058008352464L;
  private final String description_;
  private final String suffixes_;
  private final String type_;
  
  public PluginConfiguration$MimeType(String type, String description, String suffixes)
  {
    WebAssert.notNull("type", type);
    type_ = type;
    description_ = description;
    suffixes_ = suffixes;
  }
  
  public String getDescription()
  {
    return description_;
  }
  
  public String getSuffixes()
  {
    return suffixes_;
  }
  
  public String getType()
  {
    return type_;
  }
  
  public int hashCode()
  {
    return type_.hashCode();
  }
  
  public boolean equals(Object o)
  {
    if (!(o instanceof MimeType)) {
      return false;
    }
    MimeType other = (MimeType)o;
    return type_.equals(type_);
  }
}

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

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

public class PluginConfiguration
  implements Serializable
{
  private static final long serialVersionUID = -3160049910272683027L;
  private final String description_;
  private final String filename_;
  private final String name_;
  private final Set<MimeType> mimeTypes_ = new HashSet();
  
  public PluginConfiguration(String name, String description, String filename)
  {
    WebAssert.notNull("name", name);
    name_ = name;
    description_ = description;
    filename_ = filename;
  }
  
  public String getDescription()
  {
    return description_;
  }
  
  public String getFilename()
  {
    return filename_;
  }
  
  public String getName()
  {
    return name_;
  }
  
  public Set<MimeType> getMimeTypes()
  {
    return mimeTypes_;
  }
  
  public int hashCode()
  {
    return name_.hashCode();
  }
  
  public boolean equals(Object o)
  {
    if (!(o instanceof PluginConfiguration)) {
      return false;
    }
    PluginConfiguration other = (PluginConfiguration)o;
    return name_.equals(name_);
  }
  
  public static class MimeType
    implements Serializable
  {
    private static final long serialVersionUID = 3775313058008352464L;
    private final String description_;
    private final String suffixes_;
    private final String type_;
    
    public MimeType(String type, String description, String suffixes)
    {
      WebAssert.notNull("type", type);
      type_ = type;
      description_ = description;
      suffixes_ = suffixes;
    }
    
    public String getDescription()
    {
      return description_;
    }
    
    public String getSuffixes()
    {
      return suffixes_;
    }
    
    public String getType()
    {
      return type_;
    }
    
    public int hashCode()
    {
      return type_.hashCode();
    }
    
    public boolean equals(Object o)
    {
      if (!(o instanceof MimeType)) {
        return false;
      }
      MimeType other = (MimeType)o;
      return type_.equals(type_);
    }
  }
}

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

import java.io.PrintStream;
import java.io.PrintWriter;

public class ObjectInstantiationException
  extends RuntimeException
{
  private static final long serialVersionUID = 8831953284047722098L;
  private final Throwable causeException_;
  
  public ObjectInstantiationException(String message, Throwable cause)
  {
    super(message);
    causeException_ = cause;
  }
  
  public Throwable getCauseException()
  {
    return causeException_;
  }
  
  public void printStackTrace(PrintWriter writer)
  {
    super.printStackTrace(writer);
    if (causeException_ != null)
    {
      writer.write("Enclosed exception: ");
      causeException_.printStackTrace(writer);
    }
  }
  
  public void printStackTrace(PrintStream stream)
  {
    super.printStackTrace(stream);
    if (causeException_ != null)
    {
      stream.print("Enclosed exception: ");
      causeException_.printStackTrace(stream);
    }
  }
}

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

import com.gargoylesoftware.htmlunit.util.EncodingSniffer;
import com.gargoylesoftware.htmlunit.util.NameValuePair;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class WebResponseImpl
  implements WebResponse
{
  private static final long serialVersionUID = 2842434739251092348L;
  private static final Log LOG = LogFactory.getLog(WebResponseImpl.class);
  private long loadTime_;
  private WebResponseData responseData_;
  private WebRequestSettings requestSettings_;
  
  public WebResponseImpl(WebResponseData responseData, URL url, HttpMethod requestMethod, long loadTime)
  {
    this(responseData, new WebRequestSettings(url, requestMethod), loadTime);
  }
  
  @Deprecated
  public WebResponseImpl(WebResponseData responseData, String charset, WebRequestSettings requestSettings, long loadTime)
  {
    this(responseData, requestSettings, loadTime);
  }
  
  public WebResponseImpl(WebResponseData responseData, WebRequestSettings requestSettings, long loadTime)
  {
    responseData_ = responseData;
    requestSettings_ = requestSettings;
    loadTime_ = loadTime;
  }
  
  public WebRequestSettings getRequestSettings()
  {
    return requestSettings_;
  }
  
  @Deprecated
  public HttpMethod getRequestMethod()
  {
    return getRequestSettings().getHttpMethod();
  }
  
  @Deprecated
  public URL getRequestUrl()
  {
    return getRequestSettings().getUrl();
  }
  
  public List<NameValuePair> getResponseHeaders()
  {
    return responseData_.getResponseHeaders();
  }
  
  public String getResponseHeaderValue(String headerName)
  {
    for (NameValuePair pair : responseData_.getResponseHeaders()) {
      if (pair.getName().equalsIgnoreCase(headerName)) {
        return pair.getValue();
      }
    }
    return null;
  }
  
  public int getStatusCode()
  {
    return responseData_.getStatusCode();
  }
  
  public String getStatusMessage()
  {
    return responseData_.getStatusMessage();
  }
  
  public String getContentType()
  {
    String contentTypeHeader = getResponseHeaderValue("content-type");
    if (contentTypeHeader == null) {
      return "";
    }
    int index = contentTypeHeader.indexOf(';');
    if (index == -1) {
      return contentTypeHeader;
    }
    return contentTypeHeader.substring(0, index);
  }
  
  @Deprecated
  public String getContentCharSet()
  {
    return getContentCharset();
  }
  
  public String getContentCharsetOrNull()
  {
    try
    {
      return EncodingSniffer.sniffEncoding(getResponseHeaders(), getContentAsStream());
    }
    catch (IOException e)
    {
      LOG.warn("Error trying to sniff encoding.", e);
    }
    return null;
  }
  
  public String getContentCharset()
  {
    String charset = getContentCharsetOrNull();
    if (charset == null) {
      charset = getRequestSettings().getCharset();
    }
    if (charset == null) {
      charset = "ISO-8859-1";
    }
    return charset;
  }
  
  public String getContentAsString()
  {
    return getContentAsString(getContentCharset());
  }
  
  public String getContentAsString(String encoding)
  {
    byte[] body = responseData_.getBody();
    if (body != null) {
      try
      {
        return new String(body, encoding);
      }
      catch (UnsupportedEncodingException e)
      {
        LOG.warn("Attempted to use unsupported encoding '" + encoding + "'; using default system encoding.");
        return new String(body);
      }
    }
    return null;
  }
  
  public InputStream getContentAsStream()
    throws IOException
  {
    byte[] body = responseData_.getBody();
    if (body != null) {
      return new ByteArrayInputStream(body);
    }
    return null;
  }
  
  public byte[] getContentAsBytes()
  {
    return responseData_.getBody();
  }
  
  public long getLoadTime()
  {
    return loadTime_;
  }
}

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

import com.gargoylesoftware.htmlunit.util.NameValuePair;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
import java.util.Collections;
import java.util.List;
import java.util.zip.GZIPInputStream;
import java.util.zip.InflaterInputStream;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;

public class WebResponseData
  implements Serializable
{
  private static final long serialVersionUID = 2979956380280496543L;
  private byte[] body_;
  private int statusCode_;
  private String statusMessage_;
  private List<NameValuePair> responseHeaders_;
  
  public WebResponseData(byte[] body, int statusCode, String statusMessage, List<NameValuePair> responseHeaders)
  {
    statusCode_ = statusCode;
    statusMessage_ = statusMessage;
    responseHeaders_ = Collections.unmodifiableList(responseHeaders);
    if (body != null) {
      try
      {
        body_ = getBody(new ByteArrayInputStream(body), responseHeaders);
      }
      catch (IOException e)
      {
        body_ = body;
      }
    }
  }
  
  public WebResponseData(InputStream bodyStream, int statusCode, String statusMessage, List<NameValuePair> responseHeaders)
    throws IOException
  {
    statusCode_ = statusCode;
    statusMessage_ = statusMessage;
    responseHeaders_ = Collections.unmodifiableList(responseHeaders);
    body_ = getBody(bodyStream, responseHeaders);
  }
  
  protected WebResponseData(int statusCode, String statusMessage, List<NameValuePair> responseHeaders)
    throws IOException
  {
    statusCode_ = statusCode;
    statusMessage_ = statusMessage;
    responseHeaders_ = Collections.unmodifiableList(responseHeaders);
  }
  
  protected byte[] getBody(InputStream stream, List<NameValuePair> headers)
    throws IOException
  {
    if (stream == null) {
      return null;
    }
    String encoding = null;
    for (NameValuePair header : headers)
    {
      String headerName = header.getName().trim();
      if (headerName.equalsIgnoreCase("content-encoding"))
      {
        encoding = header.getValue();
        break;
      }
    }
    if ((encoding != null) && (StringUtils.contains(encoding, "gzip"))) {
      stream = new GZIPInputStream(stream);
    } else if ((encoding != null) && (StringUtils.contains(encoding, "deflate"))) {
      stream = new InflaterInputStream(stream);
    }
    return IOUtils.toByteArray(stream);
  }
  
  public byte[] getBody()
  {
    return body_;
  }
  
  public List<NameValuePair> getResponseHeaders()
  {
    return responseHeaders_;
  }
  
  public int getStatusCode()
  {
    return statusCode_;
  }
  
  public String getStatusMessage()
  {
    return statusMessage_;
  }
}

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

import com.gargoylesoftware.htmlunit.html.HtmlPage;
import java.io.PrintStream;

public final class Version
{
  public static void main(String[] args)
    throws Exception
  {
    if ((args.length == 1) && (args[0].equals("-SanityCheck")))
    {
      runSanityCheck();
      return;
    }
    System.out.println(getProductName());
    System.out.println(getCopyright());
    System.out.println("Version: " + getProductVersion());
  }
  
  private static void runSanityCheck()
    throws Exception
  {
    WebClient webClient = new WebClient();
    HtmlPage page = (HtmlPage)webClient.getPage("http://htmlunit.sourceforge.net/index.html");
    page.executeJavaScript("document.location");
    System.out.println("Sanity check complete.");
  }
  
  public static String getProductName()
  {
    return "HTMLUnit";
  }
  
  public static String getProductVersion()
  {
    return Version.class.getPackage().getImplementationVersion();
  }
  
  public static String getCopyright()
  {
    return "Copyright (c) 2002-2010 Gargoyle Software Inc. All rights reserved.";
  }
}

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

public class TextPage
  implements Page
{
  private static final long serialVersionUID = -3338485355330723848L;
  private final WebResponse webResponse_;
  private final String content_;
  private WebWindow enclosingWindow_;
  
  public TextPage(WebResponse webResponse, WebWindow enclosingWindow)
  {
    webResponse_ = webResponse;
    content_ = webResponse.getContentAsString();
    enclosingWindow_ = enclosingWindow;
  }
  
  public void initialize() {}
  
  public void cleanUp() {}
  
  public String getContent()
  {
    return content_;
  }
  
  public WebResponse getWebResponse()
  {
    return webResponse_;
  }
  
  public WebWindow getEnclosingWindow()
  {
    return enclosingWindow_;
  }
}

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

import java.io.Serializable;
import org.w3c.css.sac.CSSParseException;
import org.w3c.css.sac.ErrorHandler;

public class SilentCssErrorHandler
  implements ErrorHandler, Serializable
{
  private static final long serialVersionUID = -1338175203288447931L;
  
  public void error(CSSParseException exception) {}
  
  public void fatalError(CSSParseException exception) {}
  
  public void warning(CSSParseException exception) {}
}

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

import java.io.IOException;
import java.net.URL;
import org.apache.commons.logging.Log;

class ThreadedRefreshHandler$1
  extends Thread
{
  ThreadedRefreshHandler$1(ThreadedRefreshHandler paramThreadedRefreshHandler, String x0, Page paramPage, URL paramURL, int paramInt)
  {
    super(x0);
  }
  
  public void run()
  {
    try
    {
      new WaitingRefreshHandler().handleRefresh(val$page, val$url, val$seconds);
    }
    catch (IOException e)
    {
      ThreadedRefreshHandler.access$000().error("Unable to refresh page!", e);
      throw new RuntimeException("Unable to refresh page!", e);
    }
  }
}

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

import java.io.IOException;
import java.net.URL;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class ThreadedRefreshHandler
  implements RefreshHandler
{
  private static final Log LOG = LogFactory.getLog(ThreadedRefreshHandler.class);
  
  public void handleRefresh(final Page page, final URL url, final int seconds)
  {
    Thread thread = new Thread("ThreadedRefreshHandler Thread")
    {
      public void run()
      {
        try
        {
          new WaitingRefreshHandler().handleRefresh(page, url, seconds);
        }
        catch (IOException e)
        {
          ThreadedRefreshHandler.LOG.error("Unable to refresh page!", e);
          throw new RuntimeException("Unable to refresh page!", e);
        }
      }
    };
    thread.setDaemon(true);
    thread.start();
  }
}

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

import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlInput;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public final class WebAssert
{
  public static void assertTitleEquals(HtmlPage page, String title)
  {
    String s = page.getTitleText();
    if (!s.equals(title))
    {
      String msg = "Actual page title '" + s + "' does not match expected page title '" + title + "'.";
      throw new AssertionError(msg);
    }
  }
  
  public static void assertTitleContains(HtmlPage page, String titlePortion)
  {
    String s = page.getTitleText();
    if (s.indexOf(titlePortion) == -1)
    {
      String msg = "Page title '" + s + "' does not contain the substring '" + titlePortion + "'.";
      throw new AssertionError(msg);
    }
  }
  
  public static void assertTitleMatches(HtmlPage page, String regex)
  {
    String s = page.getTitleText();
    if (!s.matches(regex))
    {
      String msg = "Page title '" + s + "' does not match the regular expression '" + regex + "'.";
      throw new AssertionError(msg);
    }
  }
  
  public static void assertElementPresent(HtmlPage page, String id)
  {
    try
    {
      page.getHtmlElementById(id);
    }
    catch (ElementNotFoundException e)
    {
      String msg = "The page does not contain an element with ID '" + id + "'.";
      throw new AssertionError(msg);
    }
  }
  
  public static void assertElementPresentByXPath(HtmlPage page, String xpath)
  {
    List<?> elements = page.getByXPath(xpath);
    if (elements.isEmpty())
    {
      String msg = "The page does not contain any elements matching the XPath expression '" + xpath + "'.";
      
      throw new AssertionError(msg);
    }
  }
  
  public static void assertElementNotPresent(HtmlPage page, String id)
  {
    try
    {
      page.getHtmlElementById(id);
    }
    catch (ElementNotFoundException e)
    {
      return;
    }
    String msg = "The page contains an element with ID '" + id + "'.";
    throw new AssertionError(msg);
  }
  
  public static void assertElementNotPresentByXPath(HtmlPage page, String xpath)
  {
    List<?> elements = page.getByXPath(xpath);
    if (!elements.isEmpty())
    {
      String msg = "The page does not contain any elements matching the XPath expression '" + xpath + "'.";
      
      throw new AssertionError(msg);
    }
  }
  
  public static void assertTextPresent(HtmlPage page, String text)
  {
    if (page.asText().indexOf(text) == -1)
    {
      String msg = "The page does not contain the text '" + text + "'.";
      throw new AssertionError(msg);
    }
  }
  
  public static void assertTextPresentInElement(HtmlPage page, String text, String id)
  {
    try
    {
      HtmlElement element = page.getHtmlElementById(id);
      if (element.asText().indexOf(text) == -1)
      {
        String msg = "The element with ID '" + id + "' does not contain the text '" + text + "'.";
        throw new AssertionError(msg);
      }
    }
    catch (ElementNotFoundException e)
    {
      String msg = "Unable to verify that the element with ID '" + id + "' contains the text '" + text + "' because the specified element does not exist.";
      
      throw new AssertionError(msg);
    }
  }
  
  public static void assertTextNotPresent(HtmlPage page, String text)
  {
    if (page.asText().contains(text))
    {
      String msg = "The page contains the text '" + text + "'.";
      throw new AssertionError(msg);
    }
  }
  
  public static void assertTextNotPresentInElement(HtmlPage page, String text, String id)
  {
    try
    {
      HtmlElement element = page.getHtmlElementById(id);
      if (element.asText().contains(text))
      {
        String msg = "The element with ID '" + id + "' contains the text '" + text + "'.";
        throw new AssertionError(msg);
      }
    }
    catch (ElementNotFoundException e)
    {
      String msg = "Unable to verify that the element with ID '" + id + "' does not contain the text '" + text + "' because the specified element does not exist.";
      
      throw new AssertionError(msg);
    }
  }
  
  public static void assertLinkPresent(HtmlPage page, String id)
  {
    try
    {
      page.getDocumentElement().getOneHtmlElementByAttribute("a", "id", id);
    }
    catch (ElementNotFoundException e)
    {
      String msg = "The page does not contain a link with ID '" + id + "'.";
      throw new AssertionError(msg);
    }
  }
  
  public static void assertLinkNotPresent(HtmlPage page, String id)
  {
    try
    {
      page.getDocumentElement().getOneHtmlElementByAttribute("a", "id", id);
      
      String msg = "The page contains a link with ID '" + id + "'.";
      throw new AssertionError(msg);
    }
    catch (ElementNotFoundException e) {}
  }
  
  public static void assertLinkPresentWithText(HtmlPage page, String text)
  {
    boolean found = false;
    for (HtmlAnchor a : page.getAnchors()) {
      if (a.asText().contains(text))
      {
        found = true;
        break;
      }
    }
    if (!found)
    {
      String msg = "The page does not contain a link with text '" + text + "'.";
      throw new AssertionError(msg);
    }
  }
  
  public static void assertLinkNotPresentWithText(HtmlPage page, String text)
  {
    boolean found = false;
    for (HtmlAnchor a : page.getAnchors()) {
      if (a.asText().contains(text))
      {
        found = true;
        break;
      }
    }
    if (found)
    {
      String msg = "The page contains a link with text '" + text + "'.";
      throw new AssertionError(msg);
    }
  }
  
  public static void assertFormPresent(HtmlPage page, String name)
  {
    try
    {
      page.getFormByName(name);
    }
    catch (ElementNotFoundException e)
    {
      String msg = "The page does not contain a form named '" + name + "'.";
      throw new AssertionError(msg);
    }
  }
  
  public static void assertFormNotPresent(HtmlPage page, String name)
  {
    try
    {
      page.getFormByName(name);
    }
    catch (ElementNotFoundException e)
    {
      return;
    }
    String msg = "The page contains a form named '" + name + "'.";
    throw new AssertionError(msg);
  }
  
  public static void assertInputPresent(HtmlPage page, String name)
  {
    String xpath = "//input[@name='" + name + "']";
    List<?> list = page.getByXPath(xpath);
    if (list.isEmpty()) {
      throw new AssertionError("Unable to find an input element named '" + name + "'.");
    }
  }
  
  public static void assertInputNotPresent(HtmlPage page, String name)
  {
    String xpath = "//input[@name='" + name + "']";
    List<?> list = page.getByXPath(xpath);
    if (!list.isEmpty()) {
      throw new AssertionError("Unable to find an input element named '" + name + "'.");
    }
  }
  
  public static void assertInputContainsValue(HtmlPage page, String name, String value)
  {
    String xpath = "//input[@name='" + name + "']";
    List<?> list = page.getByXPath(xpath);
    if (list.isEmpty()) {
      throw new AssertionError("Unable to find an input element named '" + name + "'.");
    }
    HtmlInput input = (HtmlInput)list.get(0);
    String s = input.getValueAttribute();
    if (!s.equals(value)) {
      throw new AssertionError("The input element named '" + name + "' contains the value '" + s + "', not the expected value '" + value + "'.");
    }
  }
  
  public static void assertInputDoesNotContainValue(HtmlPage page, String name, String value)
  {
    String xpath = "//input[@name='" + name + "']";
    List<?> list = page.getByXPath(xpath);
    if (list.isEmpty()) {
      throw new AssertionError("Unable to find an input element named '" + name + "'.");
    }
    HtmlInput input = (HtmlInput)list.get(0);
    String s = input.getValueAttribute();
    if (s.equals(value)) {
      throw new AssertionError("The input element named '" + name + "' contains the value '" + s + "', not the expected value '" + value + "'.");
    }
  }
  
  public static void assertAllTabIndexAttributesSet(HtmlPage page)
  {
    List<String> tags = Arrays.asList(new String[] { "a", "area", "button", "input", "object", "select", "textarea" });
    for (HtmlElement element : page.getDocumentElement().getHtmlElementsByTagNames(tags))
    {
      Short tabIndex = element.getTabIndex();
      if ((tabIndex == null) || (tabIndex == HtmlElement.TAB_INDEX_OUT_OF_BOUNDS))
      {
        String s = element.getAttribute("tabindex");
        throw new AssertionError("Illegal value for tab index: '" + s + "'.");
      }
    }
  }
  
  public static void assertAllAccessKeyAttributesUnique(HtmlPage page)
  {
    List<String> list = new ArrayList();
    for (HtmlElement element : page.getHtmlElementDescendants())
    {
      String key = element.getAttribute("accesskey");
      if ((key != null) && (key.length() != 0))
      {
        if (list.contains(key)) {
          throw new AssertionError("The access key '" + key + "' is not unique.");
        }
        list.add(key);
      }
    }
  }
  
  public static void assertAllIdAttributesUnique(HtmlPage page)
  {
    List<String> list = new ArrayList();
    for (HtmlElement element : page.getHtmlElementDescendants())
    {
      String id = element.getAttribute("id");
      if ((id != null) && (id.length() != 0))
      {
        if (list.contains(id)) {
          throw new AssertionError("The element ID '" + id + "' is not unique.");
        }
        list.add(id);
      }
    }
  }
  
  public static void notNull(String description, Object object)
  {
    if (object == null) {
      throw new NullPointerException(description);
    }
  }
}

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

import java.io.IOException;
import java.io.InputStream;

public class UnexpectedPage
  implements Page
{
  private static final long serialVersionUID = -4072615208727355040L;
  private final WebResponse webResponse_;
  private WebWindow enclosingWindow_;
  
  public UnexpectedPage(WebResponse webResponse, WebWindow enclosingWindow)
  {
    webResponse_ = webResponse;
    enclosingWindow_ = enclosingWindow;
  }
  
  public void initialize() {}
  
  public void cleanUp() {}
  
  public InputStream getInputStream()
    throws IOException
  {
    return webResponse_.getContentAsStream();
  }
  
  public WebResponse getWebResponse()
  {
    return webResponse_;
  }
  
  public WebWindow getEnclosingWindow()
  {
    return enclosingWindow_;
  }
}

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

import java.io.IOException;
import java.net.URL;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class WaitingRefreshHandler
  implements RefreshHandler
{
  private static final Log LOG = LogFactory.getLog(WaitingRefreshHandler.class);
  private final int maxwait_;
  
  public WaitingRefreshHandler(int maxwait)
  {
    maxwait_ = maxwait;
  }
  
  public WaitingRefreshHandler()
  {
    maxwait_ = 0;
  }
  
  public void handleRefresh(Page page, URL url, int requestedWait)
    throws IOException
  {
    int seconds = requestedWait;
    if ((seconds > maxwait_) && (maxwait_ > 0)) {
      seconds = maxwait_;
    }
    try
    {
      Thread.sleep(seconds * 1000);
    }
    catch (InterruptedException e)
    {
      LOG.debug("Waiting thread was interrupted. Ignoring interruption to continue navigation.");
    }
    WebWindow window = page.getEnclosingWindow();
    if (window == null) {
      return;
    }
    WebClient client
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