Class ProxyAutoConfig
- java.lang.Object
-
- org.htmlunit.corejs.javascript.ScriptableObject
-
- org.htmlunit.javascript.HtmlUnitScriptable
-
- org.htmlunit.javascript.proxyautoconfig.ProxyAutoConfig
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,org.htmlunit.corejs.javascript.ConstProperties
,org.htmlunit.corejs.javascript.debug.DebuggableObject
,org.htmlunit.corejs.javascript.Scriptable
,org.htmlunit.corejs.javascript.SymbolScriptable
public final class ProxyAutoConfig extends HtmlUnitScriptable
Provides an implementation of Proxy Auto-Config (PAC).
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
TIMEZONE_GMT
-
Constructor Summary
Constructors Modifier Constructor Description private
ProxyAutoConfig()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static long
convertAddr(java.lang.String ip)
Concatenates the four dot-separated bytes into one 4-byte word and converts it to decimal.static boolean
dateRange(java.lang.String value1, java.lang.Object value2, java.lang.Object value3, java.lang.Object value4, java.lang.Object value5, java.lang.Object value6, java.lang.Object value7)
Checks if today is included in the specified range.private static java.util.Calendar
dateRange_createCalendar(java.util.TimeZone timezone, int day, int month, int year)
private static int
dateRange_getMonth(java.lang.Object object)
private static int
dateRange_getYear(java.lang.Object object)
static boolean
dnsDomainIs(java.lang.String host, java.lang.String domain)
Returns true if the domain of hostname matches.static int
dnsDomainLevels(java.lang.String host)
Returns the number (integer) of DNS domain levels (number of dots) in the hostname.static java.lang.String
dnsResolve(java.lang.String host)
Resolves the given DNS hostname into an IP address, and returns it in the dot separated format as a string.private static int
getSmallInt(java.lang.Object object)
static boolean
isInNet(java.lang.String host, java.lang.String pattern, java.lang.String mask)
Returns true if the IP address of the host matches the specified IP address pattern.static boolean
isPlainHostName(java.lang.String host)
Returns true if there is no domain name in the hostname (no dots).static boolean
isResolvable(java.lang.String host)
Tries to resolve the hostname.static boolean
localHostOrDomainIs(java.lang.String host, java.lang.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 java.lang.String
myIpAddress()
Returns the IP address of the local host, as a string in the dot-separated integer format.static boolean
shExpMatch(java.lang.String str, java.lang.String shexp)
Matches the specified string against a shell expression, not regular expression.static boolean
timeRange(java.lang.String value1, java.lang.Object value2, java.lang.Object value3, java.lang.Object value4, java.lang.Object value5, java.lang.Object value6, java.lang.Object value7)
Checks if the time now is included in the specified range.private static java.util.Calendar
timeRange_createCalendar(java.util.TimeZone timezone, int hour, int minute, int second)
static boolean
weekdayRange(java.lang.String wd1, java.lang.Object wd2, java.lang.Object gmt)
Checks if today is included in the specified range.-
Methods inherited from class org.htmlunit.javascript.HtmlUnitScriptable
clone, equivalentValues, get, getBrowserVersion, getClassName, getDefaultValue, getDomNodeOrDie, getDomNodeOrNull, getPrototype, getScriptableFor, getStartingScope, getWindow, getWindow, getWithPreemption, has, hasInstance, initParentScope, makeScriptableFor, put, setClassName, setDomNode, setDomNode, setParentScope, setupPromise, setupRejectedPromise
-
Methods inherited from class org.htmlunit.corejs.javascript.ScriptableObject
applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, get, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, has, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putProperty, putProperty, putProperty, querySlot, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setPrototype, size
-
-
-
-
Field Detail
-
TIMEZONE_GMT
private static final java.lang.String TIMEZONE_GMT
- See Also:
- Constant Field Values
-
-
Method Detail
-
isPlainHostName
public static boolean isPlainHostName(java.lang.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(java.lang.String host, java.lang.String domain)
Returns true if the domain of hostname matches.- Parameters:
host
- the hostname from the URLdomain
- the domain name to test the hostname against- Returns:
- true if the domain of hostname matches.
-
localHostOrDomainIs
public static boolean localHostOrDomainIs(java.lang.String host, java.lang.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 URLhostdom
- 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(java.lang.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(java.lang.String host, java.lang.String pattern, java.lang.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 formatmask
- 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 java.lang.String dnsResolve(java.lang.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 java.lang.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(java.lang.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(java.lang.String str, java.lang.String shexp)
Matches the specified string against a shell expression, not regular expression.- Parameters:
str
- a string to matchshexp
- the shell expression- Returns:
- if the string matches
-
weekdayRange
public static boolean weekdayRange(java.lang.String wd1, java.lang.Object wd2, java.lang.Object gmt)
Checks if today is included in the specified range.- Parameters:
wd1
- week day 1wd2
- week day 2, optionalgmt
- string of "GMT", or not specified- Returns:
- if today is in range
-
dateRange
public static boolean dateRange(java.lang.String value1, java.lang.Object value2, java.lang.Object value3, java.lang.Object value4, java.lang.Object value5, java.lang.Object value6, java.lang.Object value7)
Checks if today is included in the specified range.- Parameters:
value1
- the value 1value2
- the value 2value3
- the value 3value4
- the value 4value5
- the value 5value6
- the value 6value7
- the value 7- Returns:
- if today is in range
-
dateRange_createCalendar
private static java.util.Calendar dateRange_createCalendar(java.util.TimeZone timezone, int day, int month, int year)
-
getSmallInt
private static int getSmallInt(java.lang.Object object)
-
dateRange_getMonth
private static int dateRange_getMonth(java.lang.Object object)
-
dateRange_getYear
private static int dateRange_getYear(java.lang.Object object)
-
timeRange
public static boolean timeRange(java.lang.String value1, java.lang.Object value2, java.lang.Object value3, java.lang.Object value4, java.lang.Object value5, java.lang.Object value6, java.lang.Object value7)
Checks if the time now is included in the specified range.- Parameters:
value1
- the value 1value2
- the value 2value3
- the value 3value4
- the value 4value5
- the value 5value6
- the value 6value7
- the value 7- Returns:
- if the time now is in the range
-
timeRange_createCalendar
private static java.util.Calendar timeRange_createCalendar(java.util.TimeZone timezone, int hour, int minute, int second)
-
convertAddr
public static long convertAddr(java.lang.String ip)
Concatenates the four dot-separated bytes into one 4-byte word and converts it to decimal.- Parameters:
ip
- any dotted address such as an IP address or mask.- Returns:
- concatenates the four dot-separated bytes into one 4-byte word and converts it to decimal.
-
-