public abstract class Validator extends Object
Modifier and Type | Field and Description |
---|---|
protected static DictionaryLoader<Map<String,String>> |
KEY_VALUE
Resource Extractor loads key-value dictionary
|
protected static DictionaryLoader<Set<ExpressionRule>> |
RULE
Resource Extractor loads rule dictionary
|
protected static DictionaryLoader<Set<String>> |
WORD_LIST
Resource Extractor loads word list
|
protected static DictionaryLoader<Set<String>> |
WORD_LIST_LOWERCASED
Resource Extractor loads word list while lowercasting lines
|
Constructor and Description |
---|
Validator() |
Modifier and Type | Method and Description |
---|---|
protected void |
addError(String message,
Sentence sentenceWithError)
create a ValidationError for the specified position with specified message
|
protected void |
addErrorWithPosition(String message,
Sentence sentenceWithError,
int start,
int end)
create a ValidationError for the specified position with specified message
|
protected void |
addLocalizedError(Sentence sentenceWithError,
Object... args)
create a ValidationError for the specified position with localized default error message
|
protected void |
addLocalizedError(String messageKey,
Sentence sentenceWithError,
Object... args)
create a ValidationError for the specified position with localized message with specified message key
|
protected void |
addLocalizedErrorFromToken(Sentence sentenceWithError,
TokenElement token)
create a ValidationError using the details within the given token & localized message
|
protected void |
addLocalizedErrorWithPosition(Sentence sentenceWithError,
int start,
int end,
Object... args)
create a ValidationError for the specified position with default localized error message
|
protected void |
addLocalizedErrorWithPosition(String messageKey,
Sentence sentenceWithError,
int start,
int end,
Object... args)
create a ValidationError for the specified position with specified message key
|
protected void |
addValidationError(Sentence sentenceWithError,
Object... args)
Deprecated.
use
addLocalizedError(Sentence, Object...) instead |
protected void |
addValidationError(String messageKey,
Sentence sentenceWithError,
Object... args)
Deprecated.
use
addLocalizedError(String, Sentence, Object...) instead |
protected void |
addValidationErrorFromToken(Sentence sentenceWithError,
TokenElement token)
Deprecated.
|
protected void |
addValidationErrorWithPosition(Sentence sentenceWithError,
Optional<LineOffset> start,
Optional<LineOffset> end,
Object... args)
Deprecated.
|
protected void |
addValidationErrorWithPosition(String messageKey,
Sentence sentenceWithError,
Optional<LineOffset> start,
Optional<LineOffset> end,
Object... args)
Deprecated.
|
protected Optional<String> |
getConfigAttribute(String attributeName) |
protected String |
getConfigAttribute(String attributeName,
String defaultValue) |
protected boolean |
getConfigAttributeAsBoolean(String attributeName,
boolean defaultValue) |
protected double |
getConfigAttributeAsDouble(String attributeName,
double defaultValue) |
protected int |
getConfigAttributeAsInt(String attributeName,
int defaultValue) |
Map<String,String> |
getConfigAttributes()
Return the configuration attributes
|
protected String |
getLocalizedErrorMessage(String key,
Object... args)
returns localized error message for the given key formatted with argument
|
List<String> |
getSupportedLanguages()
Return an array of languages supported by this validator
Validator provides empty implementation. |
protected SymbolTable |
getSymbolTable() |
protected void |
init()
Validation initialization, called after the configuration and symbol tables have been assigned
|
void |
preValidate(Section section)
Process input blocks before run validation.
|
void |
preValidate(Sentence sentence)
Process input blocks before run validation.
|
void |
setErrorList(List<ValidationError> errors) |
void |
validate(Document document)
validate the input document and returns the invalid points.
|
void |
validate(Section section)
validate the input document and returns the invalid points.
|
void |
validate(Sentence sentence)
validate the input document and returns the invalid points.
|
protected static final DictionaryLoader<Map<String,String>> KEY_VALUE
protected static final DictionaryLoader<Set<ExpressionRule>> RULE
protected static final DictionaryLoader<Set<String>> WORD_LIST
protected static final DictionaryLoader<Set<String>> WORD_LIST_LOWERCASED
public void setErrorList(List<ValidationError> errors)
public void preValidate(Sentence sentence)
sentence
- input sentencepublic void preValidate(Section section)
section
- input sectionpublic void validate(Document document)
Validator
provides empty implementation. Validator implementation validates documents can override this method.document
- inputpublic void validate(Sentence sentence)
Validator
provides empty implementation. Validator implementation validates sentences can override this method.sentence
- inputpublic void validate(Section section)
Validator
provides empty implementation. Validator implementation validates sections can override this method.section
- inputpublic List<String> getSupportedLanguages()
Validator
provides empty implementation. Validator implementation validates sections can override this method.public Map<String,String> getConfigAttributes()
protected void init() throws RedPenException
RedPenException
protected int getConfigAttributeAsInt(String attributeName, int defaultValue)
protected boolean getConfigAttributeAsBoolean(String attributeName, boolean defaultValue)
protected double getConfigAttributeAsDouble(String attributeName, double defaultValue)
protected SymbolTable getSymbolTable()
protected void addError(String message, Sentence sentenceWithError)
message
- messagesentenceWithError
- sentenceprotected void addErrorWithPosition(String message, Sentence sentenceWithError, int start, int end)
message
- messagesentenceWithError
- sentencestart
- start positionend
- end positionprotected void addLocalizedError(Sentence sentenceWithError, Object... args)
sentenceWithError
- sentenceargs
- objects to formatprotected void addLocalizedError(String messageKey, Sentence sentenceWithError, Object... args)
messageKey
- messageKeysentenceWithError
- sentenceargs
- objects to formatprotected void addLocalizedErrorFromToken(Sentence sentenceWithError, TokenElement token)
sentenceWithError
- sentencetoken
- the TokenElement that has the errorprotected void addLocalizedErrorWithPosition(Sentence sentenceWithError, int start, int end, Object... args)
sentenceWithError
- sentencestart
- start position in parsed sentenceend
- end position in parsed sentenceargs
- objects to formatprotected void addLocalizedErrorWithPosition(String messageKey, Sentence sentenceWithError, int start, int end, Object... args)
messageKey
- messageKeysentenceWithError
- sentencestart
- start position in parsed sentenceend
- end position in parsed sentenceargs
- objects to formatprotected String getLocalizedErrorMessage(String key, Object... args)
key
- message keyargs
- objects to formatprotected void addValidationError(Sentence sentenceWithError, Object... args)
addLocalizedError(Sentence, Object...)
insteadsentenceWithError
- sentenceargs
- objects to formatprotected void addValidationError(String messageKey, Sentence sentenceWithError, Object... args)
addLocalizedError(String, Sentence, Object...)
insteadmessageKey
- messageKeysentenceWithError
- sentenceargs
- objects to formatprotected void addValidationErrorFromToken(Sentence sentenceWithError, TokenElement token)
addLocalizedErrorFromToken(Sentence, TokenElement)
insteadsentenceWithError
- sentencetoken
- the TokenElement that has the errorprotected void addValidationErrorWithPosition(Sentence sentenceWithError, Optional<LineOffset> start, Optional<LineOffset> end, Object... args)
addLocalizedErrorWithPosition(Sentence, int, int, Object...)
insteadsentenceWithError
- sentencestart
- start positionend
- end positionargs
- objects to formatprotected void addValidationErrorWithPosition(String messageKey, Sentence sentenceWithError, Optional<LineOffset> start, Optional<LineOffset> end, Object... args)
addLocalizedErrorWithPosition(String, Sentence, int, int, Object...)
insteadmessageKey
- messageKeysentenceWithError
- sentencestart
- start positionend
- end positionargs
- objects to formatCopyright © 2015. All rights reserved.