com.cyscape.browserhawk
Class RuleEngine

java.lang.Object
  extended by com.cyscape.browserhawk.RuleEngine

public class RuleEngine
extends java.lang.Object

The RuleEngine class encapsulate rule logic to provide an easy way to ensure that each web site visitor meets your site's minimum browser and system requirements, and to provide automated self-help to those users who do not. See the "Rules Enforcement Technology" tutorial at http://cyscape.com for detailed information.


Method Summary
 ExtendedOptions getExtendedOptions()
          Returns an instance of ExtendedOptions based on the requirements laid out in the XML rules file -- which extended properties to test, which ports and fonts to test, what page message to use, etc.
static RuleEngine getFromFile(java.lang.String filename)
          Returns a RuleEngine instance from the given XML file.
static RuleEngine getFromString(java.lang.String contents)
          Returns a RuleEngine instance from the given XML string.
 java.lang.String getHtmlResult(BrowserInfo info, ExtendedBrowserInfo einfo, javax.servlet.http.HttpServletRequest req)
          Returns an HTML string holding the result of the rule execution.
 LogOptions getLogOptions()
          Returns an instance of LogOptions based on the requirements laid out in the XML rules file -- such as which properties to log.
 RuleEngineResult getResult(BrowserInfo info, ExtendedBrowserInfo einfo, javax.servlet.http.HttpServletRequest req)
          Returns a RuleEngineResult holding the result of the rule execution.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getFromFile

public static RuleEngine getFromFile(java.lang.String filename)
                              throws java.io.IOException
Returns a RuleEngine instance from the given XML file. The file must conform to the RET file format standards. The file's location may be given as an absolute path or a relative path. If relative, it is searched for in the WEB-INF/classes and classpath directories. If the file changes on disk, it's dynamically reloaded. There's a backing cache so calling this method frequently is fine. The same RuleEngine can be used simultaneously in many threads.

Requires BrowserHawk Enterprise Edition.

Parameters:
filename - Name of the XML file to load rules from
Returns:
A RuleEngine instance ready for execution
Throws:
java.io.IOException - Should there be trouble locating or reading the file
See Also:
getFromString(String)

getFromString

public static RuleEngine getFromString(java.lang.String contents)
Returns a RuleEngine instance from the given XML string. The string must conform to the RET file format standards. This method is useful if the rules are pulled from a place other than a file, such as a database. There's a backing cache so calling this method frequently is fine. The same RuleEngine can be used simultaneously in many threads.

Requires BrowserHawk Enterprise Edition.

Parameters:
contents - An XML string to load rules from
Returns:
A RuleEngine instance ready for execution
See Also:
getFromFile(String)

getExtendedOptions

public ExtendedOptions getExtendedOptions()
Returns an instance of ExtendedOptions based on the requirements laid out in the XML rules file -- which extended properties to test, which ports and fonts to test, what page message to use, etc. Execution code should use the returned object so that the code doesn't need to change when the XML changes.

Returns:
An ExtendedOptions instance based on the rules XML

getLogOptions

public LogOptions getLogOptions()
Returns an instance of LogOptions based on the requirements laid out in the XML rules file -- such as which properties to log. Execution code should use the returned object so that the code doesn't need to change when the XML changes.

Returns:
A LogOptions instance based on the rules XML

getHtmlResult

public java.lang.String getHtmlResult(BrowserInfo info,
                                      ExtendedBrowserInfo einfo,
                                      javax.servlet.http.HttpServletRequest req)
Returns an HTML string holding the result of the rule execution. The string will either be a generated HTML table or a <meta http-equiv='refresh'> tag requesting a redirect. You can use this method when no advanced control is required.

Parameters:
info - The BrowserInfo instance for the current client
einfo - The ExtendedBrowserInfo instance for the current client
req - The request object
Returns:
An HTML string holding the result of the rule execution, as a table or redirect
See Also:
getResult(BrowserInfo, ExtendedBrowserInfo, javax.servlet.http.HttpServletRequest)

getResult

public RuleEngineResult getResult(BrowserInfo info,
                                  ExtendedBrowserInfo einfo,
                                  javax.servlet.http.HttpServletRequest req)
Returns a RuleEngineResult holding the result of the rule execution. On the RuleEngineResult you can examine the generated HTML table or redirect URL and determine which and how many tests were pass, fail, warn, info, or suppress.

Parameters:
info - The BrowserInfo instance for the current client
einfo - The ExtendedBrowserInfo instance for the current client
req - The request object
Returns:
A RuleEngineResult holding information about the rule execution
See Also:
getHtmlResult(BrowserInfo, ExtendedBrowserInfo, javax.servlet.http.HttpServletRequest)