org.jboss.seam.ui.validator
public class FormattedTextValidator extends Object implements javax.faces.validator.Validator, Serializable
The Seam Text parser has a disabled default error handler, catch exceptions as appropriate if you display Seam Text (see http://www.doc.ic.ac.uk/lab/secondyear/Antlr/err.html) and call the static convenience method FormattedTextValidator.getErrorMessage(originalText, recognitionException) if you want to display or log a nice error message.
Uses an instance of SeamTextParser by default, override if you require validation with your customized instance of SeamTextParser.
Constructor and Description |
---|
FormattedTextValidator() |
Modifier and Type | Method and Description |
---|---|
static String |
getErrorLocation(String originalText,
antlr.RecognitionException re,
int charsBefore,
int charsAfter)
Extracts the error from the RecognitionException and generates
a location of the error by extracting the original text at the exceptions
line and column.
|
static String |
getErrorMessage(String originalText,
antlr.RecognitionException re)
Extracts the error from the RecognitionException and generates
a message including the location of the error.
|
String |
getMismatchedTokenErrorMessage(String originalMessage,
String location)
Override (e.g.
|
String |
getNoViableAltErrorMessage(String originalMessage,
String location)
Override (e.g.
|
int |
getNumberOfCharsAfterErrorLocation() |
int |
getNumberOfCharsBeforeErrorLocation() |
String |
getParserErrorMessage(String originalText,
antlr.RecognitionException re) |
org.jboss.seam.text.SeamTextParser |
getSeamTextParser(String text)
Override to instantiate a custom SeamTextLexer and SeamTextParser.
|
String |
getSemanticErrorMessage(String originalMessage)
Override (e.g.
|
void |
validate(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component,
Object value)
Validate the given value as well-formed Seam Text.
|
public void validate(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, Object value) throws javax.faces.validator.ValidatorException
validate
in interface javax.faces.validator.Validator
javax.faces.validator.ValidatorException
public org.jboss.seam.text.SeamTextParser getSeamTextParser(String text)
text
- the raw markup textpublic String getParserErrorMessage(String originalText, antlr.RecognitionException re)
public int getNumberOfCharsBeforeErrorLocation()
public int getNumberOfCharsAfterErrorLocation()
public String getNoViableAltErrorMessage(String originalMessage, String location)
originalMessage
- the ANTLR parser error message of the RecognitionExceptionlocation
- a snippet that indicates the location in the original markup, might be nullpublic String getMismatchedTokenErrorMessage(String originalMessage, String location)
originalMessage
- the ANTLR parser error message of the RecognitionExceptionlocation
- a snippet that indicates the location in the original markup, might be nullpublic String getSemanticErrorMessage(String originalMessage)
originalMessage
- the ANTLR parser error message of the RecognitionExceptionpublic static String getErrorLocation(String originalText, antlr.RecognitionException re, int charsBefore, int charsAfter)
originalText
- the original Seam Text markup as fed into the parserre
- an ANTLR RecognitionException thrown by the parsercharsBefore
- characters before error location included in messagecharsAfter
- characters after error location included in messagepublic static String getErrorMessage(String originalText, antlr.RecognitionException re)
originalText
- the original Seam Text markup as fed into the parserre
- an ANTLR RecognitionException thrown by the parserCopyright © 2015 Seam Framework. All Rights Reserved.