List of usage examples for java.util HashSet isEmpty
public boolean isEmpty()
From source file:com.lynnlyc.web.taintanalysis.JSTaintAnalysis.java
public Set<List<Integer>> getTaintPathsTo(Integer sinkId) { HashSet<List<Integer>> paths = new HashSet<>(); HashSet<Integer> taintMarks = this.getTaintMarks(sinkId); if (taintMarks.isEmpty()) { List<Integer> path = new ArrayList<>(); path.add(sinkId);/*from w ww . j a v a2s.com*/ paths.add(path); } else { for (int mark : taintMarks) { Set<List<Integer>> prevPaths = getTaintPathsTo(mark); for (List<Integer> path : prevPaths) { path.add(sinkId); } paths.addAll(prevPaths); } } return paths; }
From source file:com.lynnlyc.web.taintanalysis.JSTaintAnalysis.java
public Set<List<Integer>> getTaintPathsFrom(Integer sourceId) { HashSet<List<Integer>> paths = new HashSet<>(); HashSet<Integer> markedSites = this.getMarkedSites(sourceId); if (markedSites.isEmpty()) { List<Integer> path = new ArrayList<>(); path.add(sourceId);//from w ww . j av a 2 s. c om paths.add(path); } else { for (int site : markedSites) { Set<List<Integer>> succPaths = getTaintPathsFrom(site); for (List<Integer> path : succPaths) { path.add(0, sourceId); } paths.addAll(succPaths); } } return paths; }
From source file:com.redhat.victims.plugin.jenkins.VictimsPostBuildScanner.java
/** * Creates and synchronises the database then checks supplied dependencies * against the vulnerability database./*from w w w . j a v a 2 s .co m*/ */ private void execute() throws AbortException { VictimsResultCache cache = ctx.getCache(); int cores = Runtime.getRuntime().availableProcessors(); ExecutorService executor = null; List<Future<FileStub>> jobs = null; PrintStream log = ctx.getLog(); boolean buildFailure = false; ArrayList<VulnerableDependencyException> vulnerabilities = new ArrayList<VulnerableDependencyException>(); try { // All files will be scanned for vulnerabilities and reported on at the end // rather than fail at the first one // Sync database updateDatabase(ctx); // Concurrency, yay! executor = Executors.newFixedThreadPool(cores); jobs = new ArrayList<Future<FileStub>>(); // Find all files under supplied path Collection<File> sources = listFiles(this.outputDir); log.println("Scanning Files:"); for (File f : sources) { if (printCheckedFiles) { log.println("\t- " + f.getAbsolutePath()); } FileStub fs; try { fs = new FileStub(f); } catch (Exception e) { log.println("ERROR : unable to generate filestub for file: " + f.getAbsolutePath()); continue; } String fsid = fs.getId(); // Check the cache if (cache.exists(fsid)) { HashSet<String> cves = cache.get(fsid); if (printCheckedFiles) { log.println("Cached: " + fsid); } /* Report vulnerabilities */ if (!cves.isEmpty()) { VulnerableDependencyException err = new VulnerableDependencyException(fs, Settings.FINGERPRINT, cves); vulnerabilities.add(err); log.println(err.getLogMessage()); if (err.isFatal(ctx)) { buildFailure = true; } } continue; } // Process dependencies that haven't been cached Callable<FileStub> worker = new VictimsCommand(ctx, fs); jobs.add(executor.submit(worker)); } executor.shutdown(); // Check the results for (Future<FileStub> future : jobs) { try { FileStub checked = future.get(); if (checked != null) { cache.add(checked.getId(), null); } } catch (InterruptedException ie) { log.println(ie.getMessage()); } catch (ExecutionException e) { Throwable cause = e.getCause(); if (cause instanceof VulnerableDependencyException) { VulnerableDependencyException vbe = (VulnerableDependencyException) cause; cache.add(vbe.getId(), vbe.getVulnerabilites()); // Add exception to list for logging as group vulnerabilities.add(vbe); log.println(vbe.getLogMessage()); if (vbe.isFatal(ctx)) { buildFailure = true; } } else { throw new VictimsBuildException(e.getCause().getMessage()); } } } } catch (VictimsException ve) { log.println("vic exception found: " + ve.getMessage()); throw new VictimsBuildException(ve.getMessage()); } finally { if (executor != null) { executor.shutdown(); } } if (!vulnerabilities.isEmpty()) { for (VulnerableDependencyException ex : vulnerabilities) { log.println(ex.getErrorMessage()); } } if (buildFailure) { throw new AbortException("Vulnerable jar found"); } }
From source file:org.nuxeo.binary.metadata.internals.BinaryMetadataServiceImpl.java
/** * @return Dirty metadata from metadata mapping contribution and handle async processes. */// w w w . j a v a 2 s .c o m public LinkedList<MetadataMappingDescriptor> getSyncMapping(DocumentModel doc, DocumentEventContext docCtx) { // Check if rules applying for this document. ActionContext actionContext = createActionContext(doc); Set<MetadataRuleDescriptor> ruleDescriptors = checkFilter(actionContext); Set<String> syncMappingDescriptorIds = new HashSet<>(); HashSet<String> asyncMappingDescriptorIds = new HashSet<>(); for (MetadataRuleDescriptor ruleDescriptor : ruleDescriptors) { if (ruleDescriptor.getIsAsync()) { asyncMappingDescriptorIds.addAll(ruleDescriptor.getMetadataMappingIdDescriptors()); continue; } syncMappingDescriptorIds.addAll(ruleDescriptor.getMetadataMappingIdDescriptors()); } // Handle async rules which should be taken into account in async listener. if (!asyncMappingDescriptorIds.isEmpty()) { docCtx.setProperty(BinaryMetadataConstants.ASYNC_MAPPING_RESULT, getMapping(asyncMappingDescriptorIds)); docCtx.setProperty(BinaryMetadataConstants.ASYNC_BINARY_METADATA_EXECUTE, Boolean.TRUE); } if (syncMappingDescriptorIds.isEmpty()) { return null; } return getMapping(syncMappingDescriptorIds); }
From source file:org.fusesource.meshkeeper.distribution.LaunchClient.java
/** * Releases previously reserved ports at the launcher. *//*from www .ja v a 2 s . c o m*/ public synchronized void releasePorts(String agentName, Collection<Integer> ports) throws Exception { agentName = agentName.toUpperCase(); HashSet<Integer> reserved = reservedPorts.get(agentName); if (reserved != null) { reserved.removeAll(ports); if (reserved.isEmpty()) { reservedPorts.remove(agentName); } } LaunchAgentService agent = getAgent(agentName); agent.releaseTcpPorts(ports); }
From source file:ch.ethz.dcg.jukefox.cli.CliJukefoxApplication.java
public void listLibraryPaths() { HashSet<String> paths = modelSettingsManager.getLibraryPaths(); if (paths.isEmpty()) { System.out.println("No paths stored in settings."); return;// ww w . j a v a 2s.c o m } Iterator<String> iterator = paths.iterator(); while (iterator.hasNext()) { System.out.println(iterator.next()); } }
From source file:com.ryan.ryanreader.fragments.CommentListingFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); if (info.position <= 0) return false; final Action action = Action.values()[item.getItemId()]; final RedditPreparedComment comment = (RedditPreparedComment) lv.getAdapter().getItem(info.position); switch (action) { case UPVOTE://from w w w . j a v a 2 s.co m comment.action(getSupportActivity(), RedditAPI.RedditAction.UPVOTE); break; case DOWNVOTE: comment.action(getSupportActivity(), RedditAPI.RedditAction.DOWNVOTE); break; case UNVOTE: comment.action(getSupportActivity(), RedditAPI.RedditAction.UNVOTE); break; case REPORT: new AlertDialog.Builder(getSupportActivity()).setTitle(R.string.action_report) .setMessage(R.string.action_report_sure) .setPositiveButton(R.string.action_report, new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int which) { comment.action(getSupportActivity(), RedditAPI.RedditAction.REPORT); // TODO update the view to show the result } }).setNegativeButton(R.string.dialog_cancel, null).show(); break; case REPLY: { final Intent intent = new Intent(getSupportActivity(), CommentReplyActivity.class); intent.putExtra("parentIdAndType", comment.idAndType); startActivity(intent); break; } case EDIT: { final Intent intent = new Intent(getSupportActivity(), CommentEditActivity.class); intent.putExtra("commentIdAndType", comment.idAndType); intent.putExtra("commentText", comment.src.body); startActivity(intent); break; } case COMMENT_LINKS: final HashSet<String> linksInComment = comment.computeAllLinks(); if (linksInComment.isEmpty()) { General.quickToast(getSupportActivity(), R.string.error_toast_no_urls_in_comment); } else { final String[] linksArr = linksInComment.toArray(new String[linksInComment.size()]); final AlertDialog.Builder builder = new AlertDialog.Builder(getSupportActivity()); builder.setItems(linksArr, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { LinkHandler.onLinkClicked(getSupportActivity(), linksArr[which], false); dialog.dismiss(); } }); final AlertDialog alert = builder.create(); alert.setTitle(R.string.action_comment_links); alert.setCanceledOnTouchOutside(true); alert.show(); } break; case SHARE: final Intent mailer = new Intent(Intent.ACTION_SEND); mailer.setType("text/plain"); mailer.putExtra(Intent.EXTRA_SUBJECT, "Comment by " + comment.src.author + " on Reddit"); // TODO this currently just dumps the markdown mailer.putExtra(Intent.EXTRA_TEXT, StringEscapeUtils.unescapeHtml4(comment.src.body)); startActivityForResult(Intent.createChooser(mailer, context.getString(R.string.action_share)), 1); break; case COPY: ClipboardManager manager = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE); // TODO this currently just dumps the markdown manager.setText(StringEscapeUtils.unescapeHtml4(comment.src.body)); break; case COLLAPSE: if (comment.getBoundView() != null) handleCommentVisibilityToggle(comment.getBoundView()); break; case USER_PROFILE: UserProfileDialog.newInstance(comment.src.author).show(getSupportActivity()); break; case PROPERTIES: CommentPropertiesDialog.newInstance(comment.src).show(getSupportActivity()); break; } return true; }
From source file:org.lol.reddit.fragments.CommentListingFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); if (info.position <= 0) { return false; }//from w w w .j a v a 2 s . c om final Object selectedObject = lv.getAdapter().getItem(info.position); if (!(selectedObject instanceof RedditCommentListItem) || !((RedditCommentListItem) selectedObject).isComment()) { return false; } final Action action = Action.values()[item.getItemId()]; final RedditPreparedComment comment = ((RedditCommentListItem) selectedObject).asComment(); switch (action) { case UPVOTE: comment.action(getSupportActivity(), RedditAPI.RedditAction.UPVOTE); break; case DOWNVOTE: comment.action(getSupportActivity(), RedditAPI.RedditAction.DOWNVOTE); break; case UNVOTE: comment.action(getSupportActivity(), RedditAPI.RedditAction.UNVOTE); break; case SAVE: comment.action(getSupportActivity(), RedditAPI.RedditAction.SAVE); break; case UNSAVE: comment.action(getSupportActivity(), RedditAPI.RedditAction.UNSAVE); break; case REPORT: new AlertDialog.Builder(getSupportActivity()).setTitle(R.string.action_report) .setMessage(R.string.action_report_sure) .setPositiveButton(R.string.action_report, new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int which) { comment.action(getSupportActivity(), RedditAPI.RedditAction.REPORT); } }).setNegativeButton(R.string.dialog_cancel, null).show(); break; case REPLY: { final Intent intent = new Intent(getSupportActivity(), CommentReplyActivity.class); intent.putExtra("parentIdAndType", comment.idAndType); startActivity(intent); break; } case EDIT: { final Intent intent = new Intent(getSupportActivity(), CommentEditActivity.class); intent.putExtra("commentIdAndType", comment.idAndType); intent.putExtra("commentText", StringEscapeUtils.unescapeHtml4(comment.src.body)); startActivity(intent); break; } case COMMENT_LINKS: final HashSet<String> linksInComment = comment.computeAllLinks(); if (linksInComment.isEmpty()) { General.quickToast(getSupportActivity(), R.string.error_toast_no_urls_in_comment); } else { final String[] linksArr = linksInComment.toArray(new String[linksInComment.size()]); final AlertDialog.Builder builder = new AlertDialog.Builder(getSupportActivity()); builder.setItems(linksArr, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { LinkHandler.onLinkClicked(getSupportActivity(), linksArr[which], false); dialog.dismiss(); } }); final AlertDialog alert = builder.create(); alert.setTitle(R.string.action_comment_links); alert.setCanceledOnTouchOutside(true); alert.show(); } break; case SHARE: final Intent mailer = new Intent(Intent.ACTION_SEND); mailer.setType("text/plain"); mailer.putExtra(Intent.EXTRA_SUBJECT, "Comment by " + comment.src.author + " on Reddit"); // TODO this currently just dumps the markdown mailer.putExtra(Intent.EXTRA_TEXT, StringEscapeUtils.unescapeHtml4(comment.src.body)); startActivityForResult( Intent.createChooser(mailer, getSupportActivity().getString(R.string.action_share)), 1); break; case COPY: ClipboardManager manager = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE); // TODO this currently just dumps the markdown manager.setText(StringEscapeUtils.unescapeHtml4(comment.src.body)); break; case COLLAPSE: if (comment.getBoundView() != null) { handleCommentVisibilityToggle(comment.getBoundView()); } else { General.quickToast(getSupportActivity(), "Error: Comment is no longer visible."); } break; case USER_PROFILE: LinkHandler.onLinkClicked(getSupportActivity(), new UserProfileURL(comment.src.author).toString()); break; case PROPERTIES: CommentPropertiesDialog.newInstance(comment.src).show(getSupportActivity()); break; case GO_TO_COMMENT: { PostCommentListingURL url = new PostCommentListingURL(null, comment.src.link_id, comment.idAlone, null, null, null); LinkHandler.onLinkClicked(getSupportActivity(), url.toString()); break; } case CONTEXT: { PostCommentListingURL url = new PostCommentListingURL(null, comment.src.link_id, comment.idAlone, 3, null, null); LinkHandler.onLinkClicked(getSupportActivity(), url.toString()); break; } } return true; }
From source file:fr.msch.wissl.server.TestIndexer.java
public void test() throws Exception { HttpClient client = new HttpClient(); // /indexer/status as user: 401 GetMethod get = new GetMethod(URL + "indexer/status"); get.addRequestHeader("sessionId", user_sessionId); client.executeMethod(get);//ww w. j a v a2s .c o m Assert.assertEquals(401, get.getStatusCode()); // /indexer/status as admin: 200 get = new GetMethod(URL + "indexer/status"); get.addRequestHeader("sessionId", admin_sessionId); client.executeMethod(get); Assert.assertEquals(200, get.getStatusCode()); JSONObject obj = new JSONObject(get.getResponseBodyAsString()); // won't try to check the actual content of this object, // since I can't predict easily and accurately if // the Indexer will be in Running or Sleeping state at a given time. assertTrue(obj.has("running")); assertTrue(obj.has("percentDone")); assertTrue(obj.has("secondsLeft")); assertTrue(obj.has("songsDone")); assertTrue(obj.has("songsTodo")); // /indexer/rescan as user: 401 PostMethod post = new PostMethod(URL + "indexer/rescan"); post.addRequestHeader("sessionId", user_sessionId); client.executeMethod(post); Assert.assertEquals(401, post.getStatusCode()); // /indexer/rescan as amdin post = new PostMethod(URL + "indexer/rescan"); post.addRequestHeader("sessionId", admin_sessionId); client.executeMethod(post); Assert.assertEquals(204, post.getStatusCode()); // /folders as user: 401 get = new GetMethod(URL + "folders"); get.addRequestHeader("sessionId", user_sessionId); client.executeMethod(get); Assert.assertEquals(401, get.getStatusCode()); // /folders: should be empty get = new GetMethod(URL + "folders"); get.addRequestHeader("sessionId", admin_sessionId); client.executeMethod(get); assertEquals(200, get.getStatusCode()); obj = new JSONObject(get.getResponseBodyAsString()); assertEquals(0, obj.getJSONArray("folders").length()); // /folders/listing as user: 401 get = new GetMethod(URL + "folders/listing"); get.addRequestHeader("sessionId", user_sessionId); client.executeMethod(get); Assert.assertEquals(401, get.getStatusCode()); // /folders/listing on some file that does not exist: 404 get = new GetMethod(URL + "folders/listing?directory=/does/not/exist"); get.addRequestHeader("sessionId", admin_sessionId); client.executeMethod(get); assertEquals(404, get.getStatusCode()); File exp_home = new File(System.getProperty("user.home")); // /folders/listing with no arg: homedir get = new GetMethod(URL + "folders/listing"); get.addRequestHeader("sessionId", admin_sessionId); client.executeMethod(get); assertEquals(200, get.getStatusCode()); obj = new JSONObject(get.getResponseBodyAsString()); assertEquals(File.separator, obj.getString("separator")); File dir = new File(obj.getString("directory")); assertEquals(exp_home.getAbsolutePath(), dir.getAbsolutePath()); assertEquals(exp_home.getParentFile().getAbsolutePath(), dir.getParentFile().getAbsolutePath()); assertTrue(obj.getJSONArray("listing").length() > 0); // /folders/listing with arg '$ROOT' get = new GetMethod(URL + "folders/listing?directory=$ROOT"); get.addRequestHeader("sessionId", admin_sessionId); client.executeMethod(get); Assert.assertEquals(200, get.getStatusCode()); obj = new JSONObject(get.getResponseBodyAsString()); assertEquals(File.separator, obj.getString("separator")); File[] dirs = File.listRoots(); assertEquals("", obj.getString("directory")); assertEquals("$ROOT", obj.getString("parent")); JSONArray arr = obj.getJSONArray("listing"); HashSet<String> hs = new HashSet<String>(arr.length()); for (int i = 0; i < arr.length(); i++) { hs.add(new File(arr.getString(i)).getAbsolutePath()); } for (File d : dirs) { // on windows, listRoots returns a bunch of drive names that don't exist if (d.exists()) { assertTrue(hs.remove(d.getAbsolutePath())); } } assertTrue(hs.isEmpty()); // lists test resources folder File f = new File("src/test/resources/data2"); get = new GetMethod(URL + "folders/listing?directory=" + URIUtil.encodeQuery(f.getAbsolutePath())); get.addRequestHeader("sessionId", admin_sessionId); client.executeMethod(get); obj = new JSONObject(get.getResponseBodyAsString()); assertEquals(File.separator, obj.getString("separator")); dir = new File(obj.getString("directory")); assertEquals(f.getAbsolutePath(), dir.getAbsolutePath()); assertEquals(f.getParentFile().getAbsolutePath(), dir.getParentFile().getAbsolutePath()); dirs = dir.listFiles(); arr = obj.getJSONArray("listing"); assertEquals(2, arr.length()); assertEquals(new File("src/test/resources/data2/sub1").getAbsolutePath(), arr.get(0)); assertEquals(new File("src/test/resources/data2/sub2").getAbsolutePath(), arr.get(1)); // /folders/add as user: 401 post = new PostMethod(URL + "folders/add"); post.addParameter("directory", "/"); post.addRequestHeader("sessionId", user_sessionId); client.executeMethod(post); Assert.assertEquals(401, post.getStatusCode()); // /folders/add : directory does not exist: 404 post = new PostMethod(URL + "folders/add"); post.addParameter("directory", "/does/not/exist"); post.addRequestHeader("sessionId", admin_sessionId); client.executeMethod(post); Assert.assertEquals(404, post.getStatusCode()); // /folders/add : not a directory: 400 post = new PostMethod(URL + "folders/add"); post.addParameter("directory", new File("src/test/resources/data/1.mp3").getAbsolutePath()); post.addRequestHeader("sessionId", admin_sessionId); client.executeMethod(post); Assert.assertEquals(400, post.getStatusCode()); // /folders/add "/src/test/resources/data" f = new File("src/test/resources/data"); RuntimeStats rt = new RuntimeStats(); rt.songCount.set(15); rt.albumCount.set(5); rt.artistCount.set(2); rt.playlistCount.set(0); rt.userCount.set(2); rt.playtime.set(15); rt.downloaded.set(0); this.addMusicFolder(f.getAbsolutePath(), rt); // check /folders get = new GetMethod(URL + "folders"); get.addRequestHeader("sessionId", admin_sessionId); client.executeMethod(get); assertEquals(200, get.getStatusCode()); obj = new JSONObject(get.getResponseBodyAsString()); assertEquals(f.getAbsolutePath(), obj.getJSONArray("folders").getString(0)); // /folders/add "/src/test/resources/data2/sub1" f = new File("src/test/resources/data2/sub1"); rt.songCount.addAndGet(3); rt.albumCount.addAndGet(1); rt.artistCount.addAndGet(1); rt.playtime.addAndGet(3); this.addMusicFolder(f.getAbsolutePath(), rt); // /folders/add "/src/test/resources/data2/" f = new File("src/test/resources/data2/"); rt.songCount.addAndGet(6); rt.playtime.addAndGet(6); this.addMusicFolder(f.getAbsolutePath(), rt); // check /folders get = new GetMethod(URL + "folders"); get.addRequestHeader("sessionId", admin_sessionId); client.executeMethod(get); assertEquals(200, get.getStatusCode()); obj = new JSONObject(get.getResponseBodyAsString()); arr = obj.getJSONArray("folders"); assertEquals(3, arr.length()); for (int i = 0; i < 3; i++) { String s = new File(arr.getString(i)).getAbsolutePath(); String s1 = new File("src/test/resources/data").getAbsolutePath(); String s2 = new File("src/test/resources/data2/sub1").getAbsolutePath(); String s3 = new File("src/test/resources/data2").getAbsolutePath(); assertTrue(s.equals(s1) || s.equals(s2) || s.equals(s3)); } // /folders/remove as user: 401 post = new PostMethod(URL + "folders/remove"); post.addParameter("directory[]", "/"); post.addRequestHeader("sessionId", user_sessionId); client.executeMethod(post); Assert.assertEquals(401, post.getStatusCode()); // /folders/remove unknown dir: 400 post = new PostMethod(URL + "folders/remove"); post.addParameter("directory[]", "/does/not/exist"); post.addRequestHeader("sessionId", admin_sessionId); client.executeMethod(post); Assert.assertEquals(400, post.getStatusCode()); // /folders/remove "/src/test/resources/data","src/test/resources/data2" post = new PostMethod(URL + "folders/remove"); f = new File("src/test/resources/data"); post.addParameter("directory[]", f.getAbsolutePath()); f = new File("src/test/resources/data2"); post.addParameter("directory[]", f.getAbsolutePath()); post.addRequestHeader("sessionId", admin_sessionId); client.executeMethod(post); assertEquals(204, post.getStatusCode()); rt.songCount.set(3); rt.albumCount.set(1); rt.artistCount.set(1); rt.userCount.set(2); rt.playtime.set(3); rt.downloaded.set(0); this.checkStats(rt); // /folders/remove "/src/test/resources/data/sub1" post = new PostMethod(URL + "folders/remove"); f = new File("src/test/resources/data2/sub1"); post.addParameter("directory[]", f.getAbsolutePath()); post.addRequestHeader("sessionId", admin_sessionId); client.executeMethod(post); assertEquals(204, post.getStatusCode()); rt.songCount.set(0); rt.albumCount.set(0); rt.artistCount.set(0); rt.userCount.set(2); rt.playtime.set(0); rt.downloaded.set(0); this.checkStats(rt); // /folders: should be empty get = new GetMethod(URL + "folders"); get.addRequestHeader("sessionId", admin_sessionId); client.executeMethod(get); assertEquals(200, get.getStatusCode()); obj = new JSONObject(get.getResponseBodyAsString()); assertEquals(0, obj.getJSONArray("folders").length()); }
From source file:org.ramadda.geodata.cdmdata.GridPointOutputHandler.java
/** * Get the grid dates/*from ww w . j a v a2 s. c om*/ * * @param dataset the dataset * * @return the dates or null */ public static List<CalendarDate> getGridDates(GridDataset dataset) { List<CalendarDate> gridDates = new ArrayList<CalendarDate>(); if (dataset == null) { return gridDates; } List<GridDatatype> grids = dataset.getGrids(); HashSet<CalendarDate> dateHash = new HashSet<CalendarDate>(); List<CoordinateAxis1DTime> timeAxes = new ArrayList<CoordinateAxis1DTime>(); for (GridDatatype grid : grids) { GridCoordSystem gcs = grid.getCoordinateSystem(); CoordinateAxis1DTime timeAxis = gcs.getTimeAxis1D(); if ((timeAxis != null) && !timeAxes.contains(timeAxis)) { timeAxes.add(timeAxis); List<CalendarDate> timeDates = timeAxis.getCalendarDates(); for (CalendarDate timeDate : timeDates) { dateHash.add(timeDate); } } } if (!dateHash.isEmpty()) { gridDates = Arrays.asList(dateHash.toArray(new CalendarDate[dateHash.size()])); Collections.sort(gridDates); } return gridDates; }