public File getFileInput(Object input) { return super.getFileInput(input); }
public BaseProductFileFilter(BaseProductReaderPlugIn plugIn, int folderDepth) { super(plugIn.getFormatNames()[0], plugIn.getDefaultFileExtensions(), plugIn.getDescription(Locale.getDefault())); this.processed = new HashMap<>(); this.depth = folderDepth; }
VirtualDirEx virtualDir; try { virtualDir = getInput(input); if (virtualDir != null) { String[] files = null; File inputFile = getFileInput(input); if (inputFile.isFile() && Arrays.stream(patternList).anyMatch(p -> p.matcher(inputFile.getName()).matches())) {
protected BaseProductReaderPlugIn(String colorPaletteFilePathFromSources) { this.folderDepth = 1; String[] patternList = getMinimalPatternList(); for (String pattern : patternList) { this.folderDepth = Math.max(this.folderDepth, pattern.split("\\[/").length - 1); this.enforcer = ProductContentEnforcer.create(patternList, getExclusionPatternList()); registerRGBProfile();
@Override protected Product readProductNodesImpl() throws IOException { productDirectory = ((BaseProductReaderPlugIn)getReaderPlugIn()).getInput(getInput()); metadata = SpotSceneMetadata.create(productDirectory, this.logger); VolumeMetadata volumeMetadata = metadata.getVolumeMetadata(); SpotDimapProductReaderPlugin readerPlugIn = (SpotDimapProductReaderPlugin)getReaderPlugIn(); Path colorPaletteFilePath = readerPlugIn.getColorPaletteFilePath(); if (volumeMetadata != null) { if (SpotConstants.PROFILE_MULTI_VOLUME.equals(volumeMetadata.getProfileName())) { internalReader = new SpotDimapVolumeProductReader(readerPlugIn, colorPaletteFilePath); logger.info("Multi-volume product detected."); } else { if (!SpotConstants.PROFILE_VOLUME.equals(volumeMetadata.getProfileName())) { logger.warning("Metadata profile unknown, will use SPOTScene reader."); } else { logger.info("Single volume product detected."); } internalReader = new SpotDimapSimpleProductReader(readerPlugIn, colorPaletteFilePath); } } else { logger.warning("No volume metadata found. Will assume single volume product."); internalReader = new SpotDimapSimpleProductReader(readerPlugIn, colorPaletteFilePath); } internalReader.setMetadata(metadata); internalReader.setProductDirectory(productDirectory); return internalReader.readProductNodes(getInput(), null); }
@Override public boolean accept(File file) { boolean shouldAccept = super.accept(file); if (shouldAccept && file.isFile() && !VirtualDirEx.isPackedFile(file)) { File folder = file.getParentFile(); if (!processed.containsKey(folder)) { try { List<String> files = listFiles(folder, depth); shouldAccept = enforcer.isConsistent(files); processed.put(folder, shouldAccept); } catch (IOException e) { Logger.getLogger(BaseProductFileFilter.class.getName()).warning(e.getMessage()); } } else { shouldAccept = processed.get(folder); } } return shouldAccept; }
@Override protected Product readProductNodesImpl() throws IOException { input = ((BaseProductReaderPlugIn)getReaderPlugIn()).getInput(getInput()); File imageMetadataFile = null; String metaSubFolder = "";
public File getFileInput(Object input) { return super.getFileInput(input); }
@Override protected Product readProductNodesImpl() throws IOException { logger.info("Reading product metadata"); zipDir = ((BaseProductReaderPlugIn)getReaderPlugIn()).getInput(getInput()); File metadataFile = zipDir.getFile(SpotConstants.SPOTVIEW_METADATA_FILE); File imageMetadataFile = zipDir.getFile(SpotConstants.SPOTSCENE_METADATA_FILE);
/** * Returns an abstraction of the given input. * If the input is a (not compressed or packed) file, it returns a <code>com.bc.ceres.core.VirtualDir.File</code> object. * If the input is a folder, it returns a <code>com.bc.ceres.core.VirtualDir.Dir</code> object. * If the input is either a tar file or a tgz file, it returns a <code>org.sa.beam.dataio.VirtualDirEx.TarVirtualDir</code> object. * If the input is a compressed file, it returns a wrapper over a <code>com.bc.ceres.core.VirtualDir.Zip</code> object. * @param input The input object * @return An instance of a VirtualDir or VirtualDirEx implementations. * @throws IOException If unable to retrieve the parent of the input. */ public VirtualDirEx getInput(Object input) throws IOException { File inputFile = getFileInput(input); if (inputFile.isFile() && !VirtualDirEx.isPackedFile(inputFile)) { final File absoluteFile = inputFile.getAbsoluteFile(); inputFile = absoluteFile.getParentFile(); if (inputFile == null) { throw new IOException("Unable to retrieve parent to file: " + absoluteFile.getAbsolutePath()); } } return VirtualDirEx.create(inputFile); }