Class RuleImporter


  • public class RuleImporter
    extends java.lang.Object
    Imports rule bases from various sources.
    Author:
    bratseth
    • Constructor Detail

      • RuleImporter

        public RuleImporter()
        Create a rule importer which will read from file
      • RuleImporter

        public RuleImporter​(SemanticRulesConfig config)
        Create a rule importer which will read from a config object
      • RuleImporter

        public RuleImporter​(boolean ignoreAutomatas)
      • RuleImporter

        public RuleImporter​(boolean ignoreAutomatas,
                            boolean ignoreIncludes)
      • RuleImporter

        public RuleImporter​(SemanticRulesConfig config,
                            boolean ignoreAutomatas,
                            boolean ignoreIncludes)
    • Method Detail

      • importFile

        public RuleBase importFile​(java.lang.String fileName)
                            throws java.io.IOException,
                                   ParseException
        Imports semantic rules from a file
        Parameters:
        fileName - the rule file to use
        Throws:
        java.io.IOException - if the file can not be read for some reason
        ParseException - if the file does not contain a valid semantic rule set
      • importFile

        public RuleBase importFile​(java.lang.String fileName,
                                   java.lang.String automataFile)
                            throws java.io.IOException,
                                   ParseException
        Imports semantic rules from a file
        Parameters:
        fileName - the rule file to use
        automataFile - the automata file to use, or null to not use any
        Throws:
        java.io.IOException - if the file can not be read for some reason
        ParseException - if the file does not contain a valid semantic rule set
      • importFile

        public RuleBase importFile​(java.lang.String fileName,
                                   java.lang.String automataFile,
                                   RuleBase ruleBase)
                            throws java.io.IOException,
                                   ParseException
        Imports semantic rules from a file
        Parameters:
        fileName - the rule file to use
        automataFile - the automata file to use, or null to not use any
        ruleBase - an existing rule base to import these rules into, or null to create a new
        Throws:
        java.io.IOException - if the file can not be read for some reason
        ParseException - if the file does not contain a valid semantic rule set
      • privateImportFile

        public RuleBase privateImportFile​(java.lang.String fileName,
                                          java.lang.String automataFile,
                                          RuleBase ruleBase)
                                   throws java.io.IOException,
                                          ParseException
        Throws:
        java.io.IOException
        ParseException
      • importDir

        public java.util.List<RuleBase> importDir​(java.lang.String ruleBaseDir)
                                           throws java.io.IOException,
                                                  ParseException
        Imports all the rule files (files ending by "sr") in the given directory
        Throws:
        java.io.IOException
        ParseException
      • include

        public void include​(java.lang.String ruleBaseName,
                            RuleBase ruleBase)
                     throws java.io.IOException,
                            ParseException
        Read and include a rule base in another
        Throws:
        java.io.IOException
        ParseException
      • setAutomata

        public void setAutomata​(RuleBase base,
                                java.lang.String automata)
      • importString

        public RuleBase importString​(java.lang.String string,
                                     java.lang.String automataFile)
                              throws java.io.IOException,
                                     ParseException
        Throws:
        java.io.IOException
        ParseException
      • importString

        public RuleBase importString​(java.lang.String string,
                                     java.lang.String automataFile,
                                     java.lang.String sourceName)
                              throws java.io.IOException,
                                     ParseException
        Throws:
        java.io.IOException
        ParseException
      • importString

        public RuleBase importString​(java.lang.String string,
                                     java.lang.String automataFile,
                                     java.lang.String sourceName,
                                     RuleBase ruleBase)
                              throws java.io.IOException,
                                     ParseException
        Throws:
        java.io.IOException
        ParseException
      • importFromReader

        public RuleBase importFromReader​(java.io.Reader reader,
                                         java.lang.String sourceInfo,
                                         java.lang.String automataFile)
                                  throws ParseException
        Throws:
        ParseException
      • importFromReader

        public RuleBase importFromReader​(java.io.Reader reader,
                                         java.lang.String sourceName,
                                         java.lang.String automataFile,
                                         RuleBase ruleBase)
                                  throws ParseException
        Imports rules from a reader
        Parameters:
        reader - the reader containing rules on the proper syntax
        sourceName - a string describing the source of the rules used for error messages
        ruleBase - an existing rule base to import the rules into, or null to create a new one
        Returns:
        the rule base containing the rules added from the reader
        Throws:
        ParseException - if the reader contains illegal rule syntax
      • privateImportFromReader

        public RuleBase privateImportFromReader​(java.io.Reader reader,
                                                java.lang.String sourceName,
                                                java.lang.String automataFile,
                                                RuleBase ruleBase)
                                         throws ParseException
        Returns an unitialized rule base
        Throws:
        ParseException