Example #1
0
 protected RuleType getRuleType_dfl(String str) throws ParserException {
   for (RuleType ruleType : RuleType.values()) {
     if (str.indexOf(ruleType.getSymbol()) >= 0) return ruleType;
   }
   throw new ParserException(
       ErrorMessage.RULE_UNRECOGNIZED_RULE_TYPE, null == str ? "" : str.trim());
 }
Example #2
0
 @Override
 public Object execute(Theory theory, List<Conclusion> conclusions, List<String> args) //
     throws ConfigurationException, ConsoleException {
   if (args.size() == 0) throw new IncorrectNoOfArgumentsException(0);
   Theory newTheory = (null == theory) ? new Theory() : theory;
   StringBuilder sb = new StringBuilder();
   for (String arg : args) {
     sb.append(arg).append(" ");
   }
   String arg = sb.toString().trim();
   try {
     RuleType ruleType = getRuleType_dfl(arg);
     System.out.println(ruleType.getLabel());
     switch (ruleType) {
       case LITERAL_VARIABLE_SET:
         addLiteralVariable(newTheory, arg);
         break;
       case FACT:
       case STRICT:
       case DEFEASIBLE:
       case DEFEATER:
         addRule(newTheory, arg);
         break;
       case SUPERIORITY:
         addSuperiority(newTheory, arg);
         break;
       case MODE_CONVERSION:
       case MODE_CONFLICT:
         addModeConversionAndModeRuleConflict(newTheory, arg);
         break;
       default:
         throw new CommandOptionException(
             COMMAND_NAME, ErrorMessage.CONSOLE_COMMAND_NULL_OPTION_INFORMATION);
     }
     return newTheory;
   } catch (ConsoleException e) {
     throw e;
   } catch (Exception e) {
     throw new ConsoleException(COMMAND_NAME, ErrorMessage.CONSOLE_ERROR_MESSAGE, e.getMessage());
   }
 }