private boolean include(MFile mfile) { if (includeFilters == null) return true; for (MFileFilter filter : includeFilters) { if (filter.accept(mfile)) return true; } return false; }
private boolean andFilter(MFile mfile) { if (andFilters == null) return true; for (MFileFilter filter : andFilters) { if (!filter.accept(mfile)) return false; } return true; }
private boolean exclude(MFile mfile) { if (excludeFilters == null) return false; for (MFileFilter filter : excludeFilters) { if (filter.accept(mfile)) return true; } return false; }
public boolean accept(MFile mfile) { for (MFileFilter filter : filters) { if (!filter.accept(mfile)) return false; } return true; }
public boolean accept(MFile mfile) { for (MFileFilter filter : filters) { if (!filter.accept(mfile)) return false; } return true; }
@Override public boolean accept(MFile mfile) { return !f.accept(mfile); } }
public boolean accept(MFile file) { return ((ff == null) || ff.accept(file)); }
public boolean accept(MFile file) { return ((ff == null) || ff.accept(file)); }
public boolean accept(MFile file) { return ((ff == null) || ff.accept(file)); }
public boolean hasNext() { while (true) { if (!iter.hasNext()) { nextMfile = null; return false; } nextMfile = iter.next(); if (filter == null || filter.accept(nextMfile)) return true; } }
public boolean hasNext() { while (true) { if (!iter.hasNext()) { nextMfile = null; return false; } nextMfile = iter.next(); if (filter == null || filter.accept(nextMfile)) return true; } }
public boolean hasNext() { while (true) { if (!dirStreamIterator.hasNext()) { nextMFile = null; return false; } try { Path nextPath = dirStreamIterator.next(); BasicFileAttributes attr = Files.readAttributes(nextPath, BasicFileAttributes.class); if (attr.isDirectory()) continue; // LOOK fix this if (attr.lastModifiedTime().toMillis() < lastModifiedTime) continue; nextMFile = new MFileOS7(nextPath, attr); } catch (IOException e) { throw new RuntimeException(e); } if (filter == null || filter.accept(nextMFile)) return true; } }
public boolean hasNext() { while (true) { if (debug && count % 100 == 0) System.out.printf("%d ", count); count++; if (!dirStreamIterator.hasNext()) { nextMFile = null; return false; } long now = System.currentTimeMillis(); try { Path nextPath = dirStreamIterator.next(); BasicFileAttributes attr = Files.readAttributes(nextPath, BasicFileAttributes.class); if (attr.isDirectory()) continue; long since = now - attr.lastModifiedTime().toMillis(); if (since < lastModifiedTime) continue; nextMFile = new MFileOS7(nextPath, attr); } catch (IOException e) { throw new RuntimeException(e); } if (filter == null || filter.accept(nextMFile)) return true; } }
@Test public void testParseCalendarDate() throws IOException { Formatter errlog = new Formatter(); CollectionSpecParser specp = new CollectionSpecParser("/data/ldm/pub/native/grid/NCEP/GFS/CONUS_95km/GFS_CONUS_95km_#yyyyMMdd_HHmm#.grib2", errlog); System.out.printf("errlog=%s%n", errlog); System.out.printf("specp=%s%n", specp); // test parsing assert specp.getRootDir().equals("/data/ldm/pub/native/grid/NCEP/GFS/CONUS_95km"); assert !specp.wantSubdirs(); assert specp.getFilter().toString().equals("GFS_CONUS_95km_..............grib2"); assert specp.getDateFormatMark().equals("GFS_CONUS_95km_#yyyyMMdd_HHmm"); // test filter MFileFilter mfilter = new WildcardMatchOnName(specp.getFilter()); String path = "/data/ldm/pub/native/grid/NCEP/GFS/CONUS_95km/GFS_CONUS_95km_20141203_0000.grib2"; MFile mfile = new MFileOS7(Paths.get(path), null); assert mfilter.accept(mfile); // 2014-12-03T16:43:59.433 -0700 ERROR - ucar.nc2.units.DateFromString - Must delineate Date between 2 '#' chars, dateFormatString = GFS_CONUS_95km_#yyyyMMdd_HHmm // test date extractor DateExtractor extractor = new DateExtractorFromName(specp.getDateFormatMark(), true); CalendarDate cd = extractor.getCalendarDate(mfile); assert cd != null : "date extractor failed"; System.out.printf("%s -> %s%n", path, cd); assert(cd.toString().equals("2014-12-03T00:00:00Z")); }