Пример #1
0
  public void loadDiffableReaders() {
    List<Class<? extends DiffableReader>> drClasses =
        new PluginManager<DiffableReader>(DiffableReader.class).getPlugins();

    logger.info("Loading diffable modules:");
    for (Class<? extends DiffableReader> drClass : drClasses) {
      logger.info("\t" + drClass.getSimpleName());

      try {
        DiffableReader dr = drClass.newInstance();
        readers.put(dr.getName(), dr);
      } catch (InstantiationException e) {
        throw new ReviewedStingException(
            "Unable to instantiate module '" + drClass.getSimpleName() + "'");
      } catch (IllegalAccessException e) {
        throw new ReviewedStingException(
            "Illegal access error when trying to instantiate '" + drClass.getSimpleName() + "'");
      }
    }
  }
Пример #2
0
 public DiffElement createDiffableFromFile(File file, int maxElementsToRead) {
   DiffableReader reader = findReaderForFile(file);
   if (reader == null) throw new UserException("Unsupported file type: " + file);
   else return reader.readFromFile(file, maxElementsToRead);
 }
Пример #3
0
  /**
   * Returns a reader appropriate for this file, or null if no such reader exists
   *
   * @param file
   * @return
   */
  public DiffableReader findReaderForFile(File file) {
    for (DiffableReader reader : readers.values()) if (reader.canRead(file)) return reader;

    return null;
  }