/** * Processes the source reader stripping off comment lines and noting prefix * definitions (@prefix) and rule inclusion commands (@include). * Returns a parser which is bound to the stripped source text with * associated prefix and rule inclusion definitions. */ public static Parser rulesParserFromReader( BufferedReader src) { return rulesParserFromReader(src,BuiltinRegistry.theRegistry); }
/** * Processes the source reader stripping off comment lines and noting prefix * definitions (@prefix) and rule inclusion commands (@include). * Returns a parser which is bound to the stripped source text with * associated prefix and rule inclusion definitions. */ public static Parser rulesParserFromReader( BufferedReader src) { return rulesParserFromReader(src,BuiltinRegistry.theRegistry); }
/** * Open a resource file and read it all into a single string. * Treats lines starting with # as comment lines, as per stringFromReader */ public static Rule.Parser loadRuleParserFromResourceFile( String filename ) { return Rule.rulesParserFromReader( FileUtils.openResourceFile( filename ) ); }
/** * Open a resource file and read it all into a single string. * Treats lines starting with # as comment lines, as per stringFromReader */ public static Rule.Parser loadRuleParserFromResourceFile( String filename ) { return Rule.rulesParserFromReader( FileUtils.openResourceFile( filename ) ); }
/** * Load a set of rule definitions including processing of * comment lines and any initial prefix definition lines. * Also notes the prefix definitions for adding to a later inf model. */ public static List<Rule> loadRules(BufferedReader src, Map<String, String> prefixes) { Rule.Parser parser = Rule.rulesParserFromReader(src); List<Rule> rules = Rule.parseRules(parser); prefixes.putAll(parser.getPrefixMap()); return rules; }
/** * Load a set of rule definitions including processing of * comment lines and any initial prefix definition lines. * Also notes the prefix definitions for adding to a later inf model. */ public static List<Rule> loadRules(BufferedReader src, Map<String, String> prefixes) { Rule.Parser parser = Rule.rulesParserFromReader(src); List<Rule> rules = Rule.parseRules(parser); prefixes.putAll(parser.getPrefixMap()); return rules; }
/** * Answer the list of rules parsed from the given URL. * @throws RulesetNotFoundException */ public static List<Rule> rulesFromURL( String uri,BuiltinRegistry registry) { BufferedReader br = null; try { InputStream in = FileManager.get().open(uri); if (in == null) throw new RulesetNotFoundException( uri ); br = FileUtils.asBufferedUTF8( in ); return parseRules( Rule.rulesParserFromReader( br ) ); } finally { if (br != null) try { br.close(); } catch (IOException e2) {} } }
/** * Answer the list of rules parsed from the given URL. * @throws RulesetNotFoundException */ public static List<Rule> rulesFromURL( String uri,BuiltinRegistry registry) { BufferedReader br = null; try { InputStream in = FileManager.get().open(uri); if (in == null) throw new RulesetNotFoundException( uri ); br = FileUtils.asBufferedUTF8( in ); return parseRules( Rule.rulesParserFromReader( br ) ); } finally { if (br != null) try { br.close(); } catch (IOException e2) {} } }