List of usage examples for java.util SortedSet add
boolean add(E e);
From source file:de.appsolve.padelcampus.controller.events.EventsBookingController.java
@RequestMapping(value = "{eventId}/confirm", method = POST) public ModelAndView confirmBooking(HttpServletRequest request) throws Exception { Booking booking = sessionUtil.getBooking(request); ModelAndView confirmView = getBookingConfirmView(booking); try {//from w ww .j a v a2s . co m if (booking == null) { throw new Exception(msg.get("SessionTimeout")); } String publicBooking = request.getParameter("public-booking"); Boolean isPublicBooking = !StringUtils.isEmpty(publicBooking) && publicBooking.equalsIgnoreCase("on"); booking.setPublicBooking(isPublicBooking); String cancellationPolicyCheckbox = request.getParameter("accept-cancellation-policy"); if (StringUtils.isEmpty(cancellationPolicyCheckbox) || !cancellationPolicyCheckbox.equals("on")) { throw new Exception(msg.get("BookingCancellationPolicyNotAccepted")); } if (booking.getConfirmed()) { throw new Exception(msg.get("BookingAlreadyConfirmed")); } isEventBookingPossible(booking); booking.setBlockingTime(new LocalDateTime()); booking.setUUID(BookingUtil.generateUUID()); if (booking.getCommunity() != null) { SortedSet<Player> communityPlayers = new TreeSet<>(); if (booking.getPlayerParticipates()) { communityPlayers.add(booking.getPlayer()); } communityPlayers.addAll(booking.getPlayers()); booking.getCommunity().setPlayers(communityPlayers); booking.setCommunity(communityDAO.saveOrUpdate(booking.getCommunity())); } bookingDAO.saveOrUpdate(booking); switch (booking.getPaymentMethod()) { case Cash: case ExternalVoucher: if (booking.getConfirmed()) { throw new Exception(msg.get("BookingAlreadyConfirmed")); } return new ModelAndView("redirect:/events/bookings/" + booking.getUUID() + "/success"); case PayPal: return bookingsPayPalController.redirectToPaypal(booking, request); case PayDirekt: return bookingsPayDirektController.redirectToPayDirekt(booking, request); case DirectDebit: return bookingsPayMillController.redirectToDirectDebit(booking); case CreditCard: return bookingsPayMillController.redirectToCreditCard(booking); case Voucher: return bookingsVoucherController.redirectToVoucher(booking); default: confirmView.addObject("error", booking.getPaymentMethod() + " not implemented"); return confirmView; } } catch (Exception e) { LOG.warn("Error while processing booking request: " + e.getMessage(), e); confirmView.addObject("error", e.getMessage()); return confirmView; } }
From source file:BoundedPriorityQueue.java
/** * Return the set of elements in this queue grearer than or equal * to the specified element according to the comparator for this * queue./*from www . j a va 2s . co m*/ * * <p>In violation of the {@link SortedSet} interface * specification, the result of this method is <b>not</b> a view * onto this queue, but rather a static snapshot of the queue. * * @param fromElement Inclusive lower bound on returned elements. * @return The set of elements greater than or equal to the lower bound. * @throws ClassCastException If the lower bound is not compatible with * this queue's comparator. * @throws NullPointerException If the lower bound is null. */ public SortedSet<E> tailSet(E fromElement) { SortedSet<E> result = new TreeSet<E>(); for (E e : this) { if (mComparator.compare(e, fromElement) >= 0) result.add(e); } return result; }
From source file:com.atlassian.connector.eclipse.internal.subclipse.ui.SubclipseTeamUiResourceConnector.java
public SortedSet<Long> getRevisionsForFile(IFile file, IProgressMonitor monitor) throws CoreException { Assert.isNotNull(file);/*from ww w . j a va2s. c om*/ ISVNLocalResource local = SVNWorkspaceRoot.getSVNResourceFor(file); try { monitor.beginTask("Getting Revisions for " + file.getName(), IProgressMonitor.UNKNOWN); SVNRevision revision = SVNRevision.HEAD; ISVNRemoteResource remoteResource = local.getRemoteResource(revision); GetLogsCommand getLogsCommand = new GetLogsCommand(remoteResource, revision, new SVNRevision.Number(0), SVNRevision.HEAD, false, 0, null, true); getLogsCommand.run(monitor); ILogEntry[] logEntries = getLogsCommand.getLogEntries(); SortedSet<Long> revisions = new TreeSet<Long>(); for (ILogEntry logEntrie : logEntries) { revisions.add(new Long(logEntrie.getRevision().getNumber())); } return revisions; } catch (Exception e) { throw new CoreException(new Status(IStatus.ERROR, AtlassianSubclipseCorePlugin.PLUGIN_ID, "Error while retrieving Revisions for file " + file.getName() + ".", e)); } }
From source file:com.revetkn.ios.analyzer.ArtworkAnalyzer.java
protected SortedSet<String> extractFilenames(Iterable<File> files) { SortedSet<String> filenames = new TreeSet<String>(); for (File file : files) filenames.add(file.getAbsolutePath()); return filenames; }
From source file:org.thevortex.lighting.jinks.client.AbstractWinkService.java
/** * {@inheritDoc}//from w w w. j a v a2 s .co m * <p> * Also initializes listening for events if not already started. This implies the * service subscription does not change over the run-time of the application. * </p> */ @Override public SortedSet<T> getAll() throws IOException { // TODO paginate SortedSet<T> result = new TreeSet<>(); Set<Subscription> itemSubscriptions = new HashSet<>(); Subscription serviceSubscription = null; ObjectNode data = (ObjectNode) client.doGet(ME + endpoint()); if (data.has("data")) { ArrayNode jsonList = (ArrayNode) data.get("data"); for (JsonNode jsonNode : jsonList) { T item = parseItem(jsonNode); if (item != null) { result.add(item); Subscription subscription = item.getSubscription(); if (subscription != null) itemSubscriptions.add(subscription); } } } if (data.has("subscription")) { serviceSubscription = WinkClient.MAPPER.convertValue(data.get("subscription"), Subscription.class); } // if the notifier is enabled, start it up if (enableNotify) notifier.init(serviceSubscription, itemSubscriptions); else if (notifier != null) notifier.close(); return result; }
From source file:cn.loveapple.client.android.database.impl.TemperatureDaoImpl.java
/** * ?????????//from w ww.j av a 2 s .c om * @param startDate * @return */ private SortedSet<String> createDateKey(String startDate) { SortedSet<String> result = new TreeSet<String>(); Date now = new Date(); Date start = DateUtil.paseDate(startDate, DateUtil.DATE_PTTERN_YYYYMMDD); Calendar date = Calendar.getInstance(); date.setTime(start); for (int i = 0; now.after(date.getTime()); i++, date.set(Calendar.DAY_OF_MONTH, date.get(Calendar.DAY_OF_MONTH) + 1)) { result.add(DateUtil.toDateString(date.getTime())); } return result; }
From source file:it.geosolutions.geofence.gui.server.service.impl.WorkspacesManagerServiceImpl.java
public PagingLoadResult<Layer> getLayers(int offset, int limit, String baseURL, GSInstance gsInstance, String workspace, String service) throws ApplicationException { List<Layer> layersListDTO = new ArrayList<Layer>(); layersListDTO.add(new Layer("*")); if ((baseURL != null) && !baseURL.equals("*") && !baseURL.contains("?") && (workspace != null) && (workspace.length() > 0)) { try {/*from w w w. ja v a 2 s . com*/ GeoServerRESTReader gsreader = new GeoServerRESTReader(baseURL, gsInstance.getUsername(), gsInstance.getPassword()); if (workspace.equals("*") && workspaceConfigOpts.isShowDefaultGroups() && service.equals("WMS")) { RESTAbstractList<NameLinkElem> layerGroups = gsreader.getLayerGroups(); if ((layerGroups != null)) { for (NameLinkElem lg : layerGroups) { // RESTLayerGroup group = gsreader.getLayerGroup(lg.getName()); // if (group != null) // { // layersListDTO.add(new Layer(group.getName())); // } layersListDTO.add(new Layer(lg.getName())); } } } else { SortedSet<String> sortedLayerNames = new TreeSet<String>(); RESTAbstractList<NameLinkElem> layers = gsreader.getLayers(); if (workspace.equals("*")) { // load all layers if (layers != null) for (NameLinkElem layerLink : layers) { sortedLayerNames.add(layerLink.getName()); } } else { if ((layers != null) && !layers.isEmpty()) { for (NameLinkElem layerNL : layers) { // next block is really too slow RESTLayer layer = gsreader.getLayer(layerNL.getName()); if (layer.getResourceUrl().contains("workspaces/" + workspace + "/")) { sortedLayerNames.add(layerNL.getName()); //layersListDTO.add(new Layer(layerNL.getName())); } } } } // return the sorted layers list for (String layerName : sortedLayerNames) { layersListDTO.add(new Layer(layerName)); } } } catch (MalformedURLException e) { logger.error(e.getLocalizedMessage(), e); throw new ApplicationException(e.getLocalizedMessage(), e); } } return new RpcPageLoadResult<Layer>(layersListDTO, 0, layersListDTO.size()); }
From source file:hu.bme.mit.sette.common.tasks.TestSuiteRunner.java
private SortedSet<Integer> linesToSortedSet(String lines) { SortedSet<Integer> sortedSet = new TreeSet<>(); for (String line : lines.split("\\s+")) { if (StringUtils.isBlank(line)) { continue; }/*from w w w. jav a 2 s. co m*/ sortedSet.add(Integer.parseInt(line)); } return sortedSet; }
From source file:com.revetkn.ios.analyzer.ArtworkAnalyzer.java
/** * @return All possible variants of the given image file. For example, an input of {@code background.png} would return * values like {@code background@2x.png}, {@code background~ipad.png}, etc. *//*from w w w .j ava 2 s. c om*/ SortedSet<String> imageFilenameVariants(String imageFilename) { SortedSet<String> filenameVariants = new TreeSet<String>(); filenameVariants.add(imageFilename); // Remove .png imageFilename = imageFilename.substring(0, imageFilename.lastIndexOf(".")); filenameVariants.add(imageFilename); // Remove @2x int lastIndexOf2x = imageFilename.lastIndexOf("@2x"); if (lastIndexOf2x >= 0) { imageFilename = imageFilename.substring(0, lastIndexOf2x); filenameVariants.add(imageFilename); } // Remove ~ipad int lastIndexOfIpad = imageFilename.lastIndexOf("~ipad"); if (lastIndexOfIpad >= 0) { imageFilename = imageFilename.substring(0, lastIndexOfIpad); filenameVariants.add(imageFilename); } // Remove ~iphone int lastIndexOfIphone = imageFilename.lastIndexOf("~iphone"); if (lastIndexOfIphone >= 0) { imageFilename = imageFilename.substring(0, lastIndexOfIphone); filenameVariants.add(imageFilename); } // We must be in our most basic form now, e.g. "ma" from original ma@2x~ipad.png. // Let's work back up and add all possible variants in case there were any wacky references to the image, like // "ma.png" filenameVariants.add(format("%s.png", imageFilename)); filenameVariants.add(format("%s~ipad.png", imageFilename)); filenameVariants.add(format("%s~iphone.png", imageFilename)); filenameVariants.add(format("%s@2x.png", imageFilename)); filenameVariants.add(format("%s@2x~ipad.png", imageFilename)); filenameVariants.add(format("%s@2x~iphone.png", imageFilename)); return filenameVariants; }
From source file:net.sf.commons.ssh.directory.Directory.java
private Map<String, Description> load() throws ParserConfigurationException, SAXException, IOException { final Document directoryDocument = getDocument("directory.xml"); final NodeList factories = directoryDocument.getElementsByTagName("factory"); //$NON-NLS-1$ //sort by priority SortedSet<Description> factoriesSet = new TreeSet<Description>(new Comparator<Description>() { @Override/* w w w. j a v a 2s.co m*/ public int compare(Description o1, Description o2) { return o1.getPriority().compareTo(o2.getPriority()); } }); for (int i = 0; i < factories.getLength(); i++) { final Element element = (Element) factories.item(i); final Description description = Description.loadDescription(element); factoriesSet.add(description); } final Map<String, Description> result = new LinkedHashMap<String, Description>(factories.getLength()); for (Description description : factoriesSet) { result.put(description.getClassName(), description); } return result; }