コード例 #1
0
  /**
   * Creates <code>HeadRule<code> which has default rules.
   * @return created rule instance
   */
  public static HeadRule createDefaultRule() {
    HeadRule instance = new HeadRule();
    InputStream rawIn = HeadRule.class.getClassLoader().getResourceAsStream(DEFAULT_RULE_PATH);
    Reader in = null;

    try {
      in = new InputStreamReader(rawIn, DEFAULT_RULE_ENCODING);
      instance.load(in);
    } catch (UnsupportedOperationException ex) {
      throw new RuntimeException(ex);
    } catch (IOException ex) {
      throw new RuntimeException(ex);
    } catch (InvalidFormatException ex) {
      throw new RuntimeException(ex);
    } finally {
      IOUtils.closeQuietly(in);
      IOUtils.closeQuietly(rawIn);
    }

    return instance;
  }
コード例 #2
0
 /**
  * Returns rule instance which is read from file.
  *
  * @param file
  * @return
  * @throws IOException
  * @throws InvalidFormatException
  */
 public static HeadRule getRule(File file) throws IOException, InvalidFormatException {
   HeadRule rule = new HeadRule();
   rule.load(file);
   return rule;
 }
コード例 #3
0
 /**
  * Returns rule instance which is read from <code>java.io.Reader</code> object.
  *
  * @param in
  * @return
  * @throws IOException
  * @throws InvalidFormatException
  */
 public static HeadRule getRule(Reader in) throws IOException, InvalidFormatException {
   HeadRule rule = new HeadRule();
   rule.load(in);
   return rule;
 }