org.xwiki.gwt.wysiwyg.client.syntax.internal
Class DefaultSyntaxValidator

java.lang.Object
  extended by org.xwiki.gwt.wysiwyg.client.syntax.internal.DefaultSyntaxValidator
All Implemented Interfaces:
SyntaxValidator

public class DefaultSyntaxValidator
extends Object
implements SyntaxValidator

Base class for syntax-specific validators. It includes by default syntax-independent rules.


Constructor Summary
DefaultSyntaxValidator(String syntax)
          Creates a new validator for the given syntax.
 
Method Summary
 void addValidationRule(ValidationRule rule)
          Adds a new validation rule to the list of rules this syntax validator obeys.
 String getSyntax()
          
 boolean isValid(String feature, RichTextArea textArea)
          Verifies if a specific feature of the editor should be enabled, considering the current list of validation rules and the current state of the given text area.
 void removeValidationRule(ValidationRule rule)
          Removes the specified rule from the list of validation rules this syntax validator obeys.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultSyntaxValidator

public DefaultSyntaxValidator(String syntax)
Creates a new validator for the given syntax.

Parameters:
syntax - syntax
Method Detail

addValidationRule

public void addValidationRule(ValidationRule rule)
Adds a new validation rule to the list of rules this syntax validator obeys.

Specified by:
addValidationRule in interface SyntaxValidator
Parameters:
rule - The validation rule to be added.
See Also:
SyntaxValidator.addValidationRule(ValidationRule)

getSyntax

public String getSyntax()

Specified by:
getSyntax in interface SyntaxValidator
Returns:
A string identifier for the syntax characterized by the underlying validation rules.
See Also:
SyntaxValidator.getSyntax()

isValid

public boolean isValid(String feature,
                       RichTextArea textArea)
Verifies if a specific feature of the editor should be enabled, considering the current list of validation rules and the current state of the given text area.

Specified by:
isValid in interface SyntaxValidator
Parameters:
feature - The feature to be tested.
textArea - The text area whose current state should be considered.
Returns:
true if there's no rule that disables the specified feature.
See Also:
SyntaxValidator.isValid(String, RichTextArea)

removeValidationRule

public void removeValidationRule(ValidationRule rule)
Removes the specified rule from the list of validation rules this syntax validator obeys.

Specified by:
removeValidationRule in interface SyntaxValidator
Parameters:
rule - The validation rule to be removed.
See Also:
SyntaxValidator.removeValidationRule(ValidationRule)