com.arsdigita.bebop.parameters
Class TidyHTMLValidationListener

java.lang.Object
  extended bycom.arsdigita.bebop.parameters.TidyHTMLValidationListener
All Implemented Interfaces:
EventListener, ParameterListener

public class TidyHTMLValidationListener
extends Object
implements ParameterListener

Verifies that the parameter's value is well-formed HTML by running it through JTidy.

Side effect: Tidy may raise errors and warnings. If errors are found, then the input HTML is broken in a way that Tidy cannot repair. If only warnings are found, Tidy will clean up the HTML. This validation listener will replace the original data with the tidied up version.(But only if the repair policy is set accordingly.) The user will be given a chance to examine and accept the changes that Tidy made. Note that only markup is changed. The actual text will not be lost as a result of replacement.

This validation listener will not pass until Tidy is satisfied with the user's HTML.

Issues: JTidy came to life a as port of Dave Ragget's HTML tidy C utility. As a result of its C heritage, JTidy doesn't use Java's built-in support for different character encodings. Rather than operating on Strings or writers and readers for working with character data, JTidy works directly with input/output streams. The resulting support for character encodings is limited to "ascii", "latin1", "raw", "utf8", "iso2022", and "mac". (See the quickref document distributed by the tidy project for an explanation of these encoding schemes. Although not necessarily directly applicable to JTidy, it provides a good overview.)

The bottom line is, JTidy does not behave like a "native" Java application when it comes to supporting character encodings. However, it is probably the most robust and widely used HTML validator written in Java. Therefore, we are providing a validation listener based on JTidy.

Since:
2002-08-16 21:46:25 -0400
Version:
$Id: //core-platform/dev/src/com/arsdigita/bebop/parameters/TidyHTMLValidationListener.java#12 $
Author:
Vadim Nasardinov (vadimn@redhat.com)

Field Summary
 
Fields inherited from interface com.arsdigita.bebop.event.ParameterListener
versionId
 
Constructor Summary
TidyHTMLValidationListener()
           
 
Method Summary
 boolean repairsOriginalData()
           
 void setRepairPolicy(boolean repairOriginalData)
          Specifies whether the original form data should be replaced with the tidied up version, if it fails to validate against JTidy.
 void validate(ParameterEvent e)
          Performs a validation check on the data objects associated with a specific parameter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TidyHTMLValidationListener

public TidyHTMLValidationListener()
Method Detail

setRepairPolicy

public void setRepairPolicy(boolean repairOriginalData)
Specifies whether the original form data should be replaced with the tidied up version, if it fails to validate against JTidy.

See Also:
repairsOriginalData()

repairsOriginalData

public boolean repairsOriginalData()
Returns:
defaults to true, unless modified via setRepairPolicy(boolean).
See Also:
setRepairPolicy(boolean)

validate

public void validate(ParameterEvent e)
Description copied from interface: ParameterListener
Performs a validation check on the data objects associated with a specific parameter. Validate should call ParameterData.addError() with a message regarding the nature of the error.

Specified by:
validate in interface ParameterListener


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 21 2004:2337 UTC