Exemple #1
0
        /**
         * <p>This method first determines the type of line<br>
         * Based on the type of line it process each input line
         * </p>
         * @param line
         * @return error Errorcodes
         * @see ConversationLine.Type
         * @see ConversationLine#getLineType(String)
         */

        private ErrorCodes validate(String line)
        {
            ErrorCodes error = ErrorCodes.SUCCESS_OK;

            ConversationLine.Type lineType = this.conversationLine.getLineType(line);

            switch (lineType)
            {
            case ConversationLine.Type.ASSIGNED:
                processAssignmentLine(line);
                break;

            case ConversationLine.Type.CREDITS:
                processCreditsLine(line);
                break;

            case ConversationLine.Type.QUESTION_HOW_MUCH:
                processHowMuchQuestion(line);
                break;

            case ConversationLine.Type.QUESTION_HOW_MANY:
                processHowManyCreditsQuestion(line);
                break;

            default: error = ErrorCodes.NO_IDEA; break;
            }

            return(error);
        }
Exemple #2
0
        /**
         * <p>This method returns the line type for the a particular line</p>
         * @param line String
         * @return lineType ConversationLine.Type
         */
        public ConversationLine.Type getLineType(String line)
        {
            line = line.Trim();
            ConversationLine.Type result = Type.NOMATCH;

            bool matched = false;

            for (int i = 0; i < linefilter.Length && !matched; i++)
            {
                Regex regex = new Regex(@linefilter[i].getPattern());
                Match match = regex.Match(line);
                if (match.Success)
                {
                    matched = true;
                    result  = linefilter[i].getType();
                }
            }

            return(result);
        }
Exemple #3
0
 public LineFilter(ConversationLine.Type type, String pattern)
 {
     this.type    = type;
     this.pattern = pattern;
 }