private static GridFormatFactorySpi getFactoryForObject(URL id, File file) {
   for (GridFormatFactorySpi spi : factories.values()) {
     // we know that the factory is avaiable
     final AbstractGridFormat format = (AbstractGridFormat) spi.createFormat();
     if (file != null && format.accepts(file)) return spi;
     if (id != null && format.accepts(id)) return spi;
   }
   return null;
 }
Ejemplo n.º 2
0
  public void testIsAvailable() throws NoSuchAuthorityCodeException, FactoryException {
    GridFormatFinder.scanForPlugins();
    Iterator<GridFormatFactorySpi> list = GridFormatFinder.getAvailableFormats().iterator();
    boolean found = false;
    GridFormatFactorySpi fac = null;
    while (list.hasNext()) {
      fac = (GridFormatFactorySpi) list.next();

      if (fac instanceof ArcGridFormatFactory) {
        found = true;

        break;
      }
    }

    assertTrue("ArcGridFormatFactory not registered", found);
    assertTrue("ArcGridFormatFactory not available", fac.isAvailable());
    assertNotNull(new ArcGridFormatFactory().createFormat());
  }
 private static AbstractGridFormat getFormatForObject(URL id, File file) {
   final GridFormatFactorySpi spi = getFactoryForObject(id, file);
   return spi != null ? (AbstractGridFormat) spi.createFormat() : null;
 }