com.gargoylesoftware.htmlunit.javascript
Class ProxyAutoConfig

java.lang.Object
  extended by com.gargoylesoftware.htmlunit.javascript.ProxyAutoConfig

public final class ProxyAutoConfig
extends Object

Provides an implementation of Proxy Auto-Config (PAC).

Version:
$Revision: 6701 $
Author:
Ahmed Ashour
See Also:
PAC file format

Method Summary
static boolean dateRange(String value1, Object value2, Object value3, Object value4, Object value5, Object value6, Object value7)
          Checks if today is included in the specified range.
static boolean dnsDomainIs(String host, String domain)
          Returns true if the domain of hostname matches.
static int dnsDomainLevels(String host)
          Returns the number (integer) of DNS domain levels (number of dots) in the hostname.
static String dnsResolve(String host)
          Resolves the given DNS hostname into an IP address, and returns it in the dot separated format as a string.
static String evaluate(String content, URL url)
          Evaluates the FindProxyForURL method of the specified content.
static boolean isInNet(String host, String pattern, String mask)
          Returns true if the IP address of the host matches the specified IP address pattern.
static boolean isPlainHostName(String host)
          Returns true if there is no domain name in the hostname (no dots).
static boolean isResolvable(String host)
          Tries to resolve the hostname.
static boolean localHostOrDomainIs(String host, String hostdom)
          Returns true if the hostname matches exactly the specified hostname, or if there is no domain name part in the hostname, but the unqualified hostname matches.
static String myIpAddress()
          Returns the IP address of the local host, as a string in the dot-separated integer format.
static boolean shExpMatch(String str, String shexp)
          Matches the specified string against a shell expression, not regular expression.
static boolean timeRange(String value1, Object value2, Object value3, Object value4, Object value5, Object value6, Object value7)
          Checks if the time now is included in the specified range.
static boolean weekdayRange(String wd1, Object wd2, Object gmt)
          Checks if today is included in the specified range.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

evaluate

public static String evaluate(String content,
                              URL url)
Evaluates the FindProxyForURL method of the specified content.

Parameters:
content - the JavaScript content
url - the URL to be retrieved
Returns:
semicolon-separated result

isPlainHostName

public static boolean isPlainHostName(String host)
Returns true if there is no domain name in the hostname (no dots).

Parameters:
host - the hostname from the URL (excluding port number).
Returns:
true if there is no domain name in the hostname (no dots).

dnsDomainIs

public static boolean dnsDomainIs(String host,
                                  String domain)
Returns true if the domain of hostname matches.

Parameters:
host - the hostname from the URL
domain - the domain name to test the hostname against
Returns:
true if the domain of hostname matches.

localHostOrDomainIs

public static boolean localHostOrDomainIs(String host,
                                          String hostdom)
Returns true if the hostname matches exactly the specified hostname, or if there is no domain name part in the hostname, but the unqualified hostname matches.

Parameters:
host - the hostname from the URL
hostdom - fully qualified hostname to match against
Returns:
true if the hostname matches exactly the specified hostname, or if there is no domain name part in the hostname, but the unqualified hostname matches.

isResolvable

public static boolean isResolvable(String host)
Tries to resolve the hostname. Returns true if succeeds.

Parameters:
host - the hostname from the URL.
Returns:
true if the specific hostname is resolvable.

isInNet

public static boolean isInNet(String host,
                              String pattern,
                              String mask)
Returns true if the IP address of the host matches the specified IP address pattern.

Parameters:
host - a DNS hostname, or IP address. If a hostname is passed, it will be resolved into an IP address by this function.
pattern - an IP address pattern in the dot-separated format
mask - mask for the IP address pattern informing which parts of the IP address should be matched against. 0 means ignore, 255 means match
Returns:
true if the IP address of the host matches the specified IP address pattern.

dnsResolve

public static String dnsResolve(String host)
Resolves the given DNS hostname into an IP address, and returns it in the dot separated format as a string.

Parameters:
host - the hostname to resolve
Returns:
the resolved IP address

myIpAddress

public static String myIpAddress()
Returns the IP address of the local host, as a string in the dot-separated integer format.

Returns:
the IP address of the local host, as a string in the dot-separated integer format.

dnsDomainLevels

public static int dnsDomainLevels(String host)
Returns the number (integer) of DNS domain levels (number of dots) in the hostname.

Parameters:
host - the hostname from the URL
Returns:
the number (integer) of DNS domain levels (number of dots) in the hostname.

shExpMatch

public static boolean shExpMatch(String str,
                                 String shexp)
Matches the specified string against a shell expression, not regular expression.

Parameters:
str - a string to match
shexp - the shell expression
Returns:
if the string matches

weekdayRange

public static boolean weekdayRange(String wd1,
                                   Object wd2,
                                   Object gmt)
Checks if today is included in the specified range.

Parameters:
wd1 - week day 1
wd2 - week day 2, optional
gmt - string of "GMT", or not specified
Returns:
if today is in range

dateRange

public static boolean dateRange(String value1,
                                Object value2,
                                Object value3,
                                Object value4,
                                Object value5,
                                Object value6,
                                Object value7)
Checks if today is included in the specified range.

Parameters:
value1 - the value 1
value2 - the value 2
value3 - the value 3
value4 - the value 4
value5 - the value 5
value6 - the value 6
value7 - the value 7
Returns:
if today is in range

timeRange

public static boolean timeRange(String value1,
                                Object value2,
                                Object value3,
                                Object value4,
                                Object value5,
                                Object value6,
                                Object value7)
Checks if the time now is included in the specified range.

Parameters:
value1 - the value 1
value2 - the value 2
value3 - the value 3
value4 - the value 4
value5 - the value 5
value6 - the value 6
value7 - the value 7
Returns:
if the time now is in the range


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