 |
Gridarta Editor
|
Go to the documentation of this file.
20 package net.sf.gridarta.var.crossfire.model.validation.checks;
22 import java.util.Collection;
23 import java.util.HashMap;
24 import java.util.HashSet;
25 import java.util.Locale;
27 import java.util.Map.Entry;
28 import java.util.regex.Matcher;
29 import java.util.regex.Pattern;
33 import org.apache.log4j.Category;
34 import org.apache.log4j.Logger;
35 import org.jetbrains.annotations.NotNull;
61 private final Collection<String>
keywords =
new HashSet<>();
79 if (
LOG.isDebugEnabled()) {
89 if (
LOG.isDebugEnabled()) {
104 if (
LOG.isDebugEnabled()) {
105 LOG.debug(
"event: match");
108 for (
final String matchKeyword : matchKeywords) {
109 if (matchKeyword.isEmpty()) {
110 generator.errorKeywordError(
"empty keyword in '@match'");
111 }
else if (matchKeyword.equals(
"*")) {
113 generator.errorKeywordError(
"duplicate '@match *'. The second one will never match");
118 generator.errorKeywordError(
"keyword '" + matchKeyword +
"' in '@match' after '@match *'. The keyword will never match");
120 if (!
keywords.add(matchKeyword.toLowerCase(Locale.ROOT))) {
121 generator.errorKeywordError(
"duplicate keyword '" + matchKeyword +
"' in '@match'. The second one will never match");
134 if (!command.equals(
"@reply") && !command.equals(
"@question")) {
135 throw new IllegalArgumentException(
"invalid command: " + command);
137 if (
LOG.isDebugEnabled()) {
138 LOG.debug(
"event: reply " + command +
" " + keyword);
142 if (matcher.find()) {
143 generator.errorKeywordError(
"the word '" + keyword +
"' uses upper-case letters. Matches are case-insensitive, therefore replies and questions should be specified in lower-case letters only");
146 replyKeywords.put(keyword.toLowerCase(Locale.ROOT), command);
154 if (
LOG.isDebugEnabled()) {
155 LOG.debug(
"event: eof");
158 for (
final Entry<String, String> e :
replyKeywords.entrySet()) {
159 final String keyword = e.getKey();
161 final String command = e.getValue();
162 generator.errorKeywordError(
"keyword '" + keyword +
"' in '" + command +
"' does not appear in any @match line");
KeywordValidator()
Creates a new instance.
void match(@NotNull final ErrorGenerator< G, A, R > generator, @NotNull final Iterable< String > matchKeywords)
Processes a @match line.
final Collection< String > keywords
All keywords that occurred in @match lines so far.
Generator for SuspiciousMsgChecker related error messages.
Base package of all Gridarta classes.
void reply(@NotNull final ErrorGenerator< G, A, R > generator, @NotNull final String command, @NotNull final String keyword)
Processes a @reply or @question line.
Reflects a game object (object on a map).
static final Category LOG
The Logger for printing log messages.
Checks that the matched keywords are correct.
static final Pattern PATTERN_UPPER_CASE_LETTER
Matches any upper-case ASCI letter.
GameObjects are the objects based on Archetypes found on maps.
Implements Crossfire archetypes.
MapArchObject contains the specific meta data about a map that is stored in the map-arch,...
Interface for MapArchObjects.
boolean matchAllKeyword
Whether the '*' keyword occurred so far.
void reset()
Resets the checker state.
Handles the Crossfire GameObjects.
void eof(@NotNull final ErrorGenerator< G, A, R > generator)
Will be called at the end of processing.
final Map< String, String > replyKeywords
All keywords that occurred in @reply or @question lines so far.