/** * Returns all the {@link Format}s that can read the supplied {@link Object} o. * * @param o is the object to search a {@link Format} that is able to read * @return an unmodifiable {@link Set} comprising all the {@link Format} that can read the * {@link Object} o. */ public static synchronized Set<AbstractGridFormat> findFormats(Object o) { return findFormats(o, GeoTools.getDefaultHints()); }
final Set<AbstractGridFormat> formats = findFormats(o, hints);
/** * Returns all the {@link Format}s that can read the supplied {@link Object} * o. * * @param o * is the object to search a {@link Format} that is able to read * @return an unmodifiable {@link Set} comprising all the {@link Format} * that can read the {@link Object} o. */ public static synchronized Set<AbstractGridFormat> findFormats(Object o) { return findFormats(o, GeoTools.getDefaultHints()); }
/** * Returns a {@link Format} that is able to read a certain object. If no * {@link Format} is able to read such an {@link Object} we return an * {@link UnknownFormat} object. * * <p> * It is worth to point out that this method will try to convert each format * implementation to {@link AbstractGridFormat} because the original * {@link Format} interface did not allow for an accept method hence we had * to subclass the interface to add such method and we did so by the * {@link AbstractGridFormat} abstract class. * * @param o * the object to check for acceptance. * @return an {@link AbstractGridFormat} that has stated to accept this * {@link Object} o or <code>null</code> in no plugins was able to * accept it. */ public static synchronized Format findFormat(Object o) { final Set formats = findFormats(o); final Iterator it = formats.iterator(); if (it.hasNext()) return (Format) it.next(); return new UnknownFormat(); } }
/** * Returns a {@link Format} that is able to read a certain object. If no * {@link Format} is able to read such an {@link Object} we return an * {@link UnknownFormat} object. * * <p> * It is worth to point out that this method will try to convert each format * implementation to {@link AbstractGridFormat} because the original * {@link Format} interface did not allow for an accept method hence we had * to subclass the interface to add such method and we did so by the * {@link AbstractGridFormat} abstract class. * * @param o * the object to check for acceptance. * @param hints * the {@link Hints} to control the format search. * @return an {@link AbstractGridFormat} that has stated to accept this * {@link Object} o or <code>null</code> in no plugins was able to * accept it. */ public static synchronized AbstractGridFormat findFormat(Object o, Hints hints) { final Set<AbstractGridFormat> formats = findFormats(o,hints); final Iterator<AbstractGridFormat> it = formats.iterator(); if (it.hasNext()){ return (AbstractGridFormat) it.next(); } return new UnknownFormat(); } }
private static AbstractGridFormat prioritizedFindFormat(final URL input) { final AbstractGridFormat format = null; try { final Set<AbstractGridFormat> formats = GridFormatFinder.findFormats(input); if ((formats == null) || formats.isEmpty()) { LOGGER.warn("Unable to support raster file " + input.getPath());
/** * Get user to choose raster format. * * @param rasterFile the raster file * @param selectionPanel the selection panel * @return the abstract grid format */ public static AbstractGridFormat choose( File rasterFile, ChooseRasterFormatInterface selectionPanel) { if (rasterFile != null) { final Set<AbstractGridFormat> formats = GridFormatFinder.findFormats(rasterFile, GeoTools.getDefaultHints()); if (!classUndertest && (formats.size() > 1)) { if (selectionPanel != null) { AbstractGridFormat selectedFormat = selectionPanel.showPanel(formats); if (selectedFormat != null) { return selectedFormat; } } } // otherwise just pick the first final Iterator<AbstractGridFormat> it = formats.iterator(); if (it.hasNext()) { return it.next(); } } return new UnknownFormat(); }
Set<AbstractGridFormat> formats = GridFormatFinder.findFormats(file); AbstractGridFormat format = null;
Set<AbstractGridFormat> formats = GridFormatFinder.findFormats(file); AbstractGridFormat format = null;