List of usage examples for java.util SortedSet size
int size();
From source file:org.powertac.common.OrderbookTests.java
@Test public void testGetBids() { Orderbook ob = new Orderbook(timeslot, 20.1, now); ob.addBid(new OrderbookOrder(3.3, -20.0)).addBid(new OrderbookOrder(2.1, -18.2)) .addBid(new OrderbookOrder(5.6, -19.4)).addBid(new OrderbookOrder(6.2, null)); SortedSet<OrderbookOrder> bids = ob.getBids(); assertEquals("correct number", 4, bids.size()); assertEquals("correct first item price", null, bids.first().getLimitPrice()); assertEquals("correct last item price", -18.2, bids.last().getLimitPrice(), 1e-6); SortedSet<OrderbookOrder> asks = ob.getAsks(); assertEquals("no asks", 0, asks.size()); }
From source file:pl.otros.logview.gui.message.SoapFinderTest.java
@Test public void testFindSoap() throws Exception { String stringWithSoaps = IOUtils .toString(this.getClass().getClassLoader().getResourceAsStream("soap/stringWithSoap.txt")); SoapFinder finder = new SoapFinder(); SortedSet<SubText> findSoaps = finder.findSoaps(stringWithSoaps); // 60,300/*from w w w. j a va 2 s . co m*/ AssertJUnit.assertEquals(2, findSoaps.size()); SubText first = findSoaps.first(); stringWithSoaps.substring(first.getStart(), first.getEnd()); AssertJUnit.assertEquals(38, first.getStart()); AssertJUnit.assertEquals(299, first.getEnd()); SubText last = findSoaps.last(); stringWithSoaps.substring(last.getStart(), last.getEnd()); AssertJUnit.assertEquals(369, last.getStart()); AssertJUnit.assertEquals(645, last.getEnd()); }
From source file:com.joliciel.jochre.search.CoordinateStorageImpl.java
public List<Rectangle> getNearestRectangles(int offset) { int nearestOffset = -1; SortedSet<Integer> tailSet = wordOffsets.tailSet(offset); if (tailSet.size() > 0) { nearestOffset = tailSet.first(); } else {/*from ww w. jav a 2 s . c o m*/ SortedSet<Integer> headSet = wordOffsets.headSet(offset); nearestOffset = headSet.last(); } if (nearestOffset >= 0) { return this.getRectangles(nearestOffset); } return null; }
From source file:com.liveramp.hank.storage.cueball.CueballPartitionUpdater.java
@Override protected Integer detectCurrentVersionNumber() throws IOException { SortedSet<CueballFilePath> localBases = Cueball.getBases(localPartitionRoot); if (localBases.size() > 0) { return localBases.last().getVersion(); } else {/*from ww w . ja va 2s .c o m*/ return null; } }
From source file:org.sventon.service.javahl.JavaHLRepositoryServiceTest.java
@Test public void testGetLogEntries() throws Exception { final Map<String, String> propMap = new HashMap<String, String>(); final ChangePath cp1 = mock(ChangePath.class); final ChangePath cp2 = mock(ChangePath.class); final ChangePath[] changePaths = { cp1, cp2 }; final int rev = 4711; final Date date = new Date(); final String dateString = DateUtil.formatISO8601(date); MapUtils.putAll(propMap, new String[][] { { "svn:author", "daAuthor" }, { "svn:date", dateString }, { "svn:log", "Added new text in my finest file" } }); when(cp1.getPath()).thenReturn("/trunk/src/main/da/path/myfile.txt"); when(cp1.getAction()).thenReturn('M'); when(cp1.getCopySrcPath()).thenReturn(null); when(cp1.getCopySrcRevision()).thenReturn(-1L); when(cp2.getPath()).thenReturn("/branches/lemontree/src/main/da/path/myfile.txt"); when(cp2.getAction()).thenReturn('A'); when(cp2.getCopySrcPath()).thenReturn(null); when(cp2.getCopySrcRevision()).thenReturn(-1L); when(connection.getRepositoryRootUrl()).thenReturn(new SVNURL("svn://myhost/repro")); // Yiks! We probably need to refactor this later... // Matching for SVNClient.logMessages() is also a little bit too loose. doAnswer(new Answer() { @Override/* w ww. ja v a 2s. c o m*/ public Object answer(InvocationOnMock invocation) throws Throwable { Object[] args = invocation.getArguments(); final LogMessageCallback cb = (LogMessageCallback) args[8]; cb.singleMessage(changePaths, rev, propMap, false); return null; } }).when(client).logMessages(eq("svn://myhost/repro/da/path"), (Revision) any(), (RevisionRange[]) any(), eq(false), eq(false), eq(false), (String[]) any(), anyInt(), (LogMessageCallback) any()); final List<LogEntry> logEntries = service.getLogEntries(connection, null, 1, 100, "da/path", 100, false, false); // Verify number of LogEntries assertEquals(1, logEntries.size()); // Verify ChangePath final LogEntry logEntry = logEntries.get(0); final SortedSet<ChangedPath> changedPaths = logEntry.getChangedPaths(); assertEquals(2, changedPaths.size()); ChangedPath[] paths = new ChangedPath[2]; changedPaths.toArray(paths); assertEquals("/branches/lemontree/src/main/da/path/myfile.txt", paths[0].getPath()); assertEquals(ChangeType.ADDED, paths[0].getType()); assertEquals("/trunk/src/main/da/path/myfile.txt", paths[1].getPath()); assertEquals(ChangeType.MODIFIED, paths[1].getType()); //Verify Properties assertEquals("daAuthor", logEntry.getAuthor()); // TODO: check this! We fail because we're GMT+1&DLS and date is in UTC... //assertEquals(date, logEntry.getDate()); assertEquals("Added new text in my finest file", logEntry.getMessage()); assertEquals(4711, logEntry.getRevision()); }
From source file:ca.travelagency.invoice.destinations.DestinationFormPanel.java
private void initialize(DestinationsPanel destinationsPanel, InvoiceDestination invoiceDestination) { if (DaoEntityModelFactory.isPersisted(invoiceDestination)) { return;// ww w. j ava2 s . co m } SortedSet<InvoiceDestination> destinations = destinationsPanel.getDaoEntity().getInvoiceDestinations(); switch (destinations.size()) { case 0: invoiceDestination.setDeparturePlace(parameterRepository.getDefaultDeparturePlace()); break; case 1: InvoiceDestination first = destinations.first(); invoiceDestination.setDeparturePlace(first.getArrivalPlace()); invoiceDestination.setDepartureDate(DateUtils.addDays(first.getDepartureDate(), TRAVEL_DAY_RANGE)); invoiceDestination.setArrivalPlace(first.getDeparturePlace()); break; } }
From source file:org.sejda.impl.pdfbox.component.PdfHeaderFooterWriter.java
public void writeFooter(SetHeaderFooterParameters parameters) throws TaskIOException { PDFont font = defaultIfNull(getStandardType1Font(parameters.getFont()), PDType1Font.HELVETICA); BigDecimal fontSize = defaultIfNull(parameters.getFontSize(), BigDecimal.TEN); HorizontalAlign horAlignment = defaultIfNull(parameters.getHorizontalAlign(), HorizontalAlign.CENTER); VerticalAlign verAlignment = defaultIfNull(parameters.getVerticalAlign(), VerticalAlign.BOTTOM); SortedSet<Integer> pages = parameters.getPageRange().getPages(documentHandler.getNumberOfPages()); LOG.debug("Found {} pages to apply header or footer", pages.size()); Integer labelPageNumber = parameters.getNumbering().getLogicalPageNumber(); for (Integer pageNumber : pages) { String label = parameters.styledLabelFor(labelPageNumber); PDPage page = documentHandler.getPage(pageNumber); PDRectangle pageSize = page.findCropBox(); try {/* w w w .j ava 2 s . com*/ float stringWidth = font.getStringWidth(label) * fontSize.floatValue() / 1000f; float xPosition = horAlignment.position(pageSize.getWidth(), stringWidth, DEFAULT_MARGIN); float yPosition = verAlignment.position(pageSize.getHeight(), DEFAULT_MARGIN); PDPageContentStream contentStream = new PDPageContentStream( documentHandler.getUnderlyingPDDocument(), page, true, true); contentStream.beginText(); contentStream.setFont(font, fontSize.floatValue()); contentStream.moveTextPositionByAmount(xPosition, yPosition); contentStream.drawString(label); contentStream.endText(); contentStream.close(); } catch (IOException e) { throw new TaskIOException("An error occurred writing the header or footer of the page.", e); } labelPageNumber++; } }
From source file:uk.ac.ebi.atlas.experimentpage.baseline.BaselineExperimentController.java
private boolean allFactorsInSliceSelected(BaselineRequestPreferences preferences, BaselineExperiment experiment) { Set<Factor> selectedFilterFactors = filterFactorsConverter .deserialize(preferences.getSerializedFilterFactors()); SortedSet<Factor> allFactorsInSlice = experiment.getExperimentalFactors() .getComplementFactors(selectedFilterFactors); return (preferences.getQueryFactorValues().size() == allFactorsInSlice.size()); }
From source file:org.eclipse.skalli.model.ext.maven.internal.recommendedupdatesites.RecommendedUpdateSitesServiceImpl.java
@Override protected void validateEntity(RecommendedUpdateSites entity) throws ValidationException { SortedSet<Issue> issues = validate(entity, Severity.FATAL); if (issues.size() > 0) { throw new ValidationException( "Recommended update sites could not be saved because of the following reasons:", issues); }//from w w w .ja va 2 s .com }
From source file:org.drugis.mtc.gui.AnalysesModel.java
@Override public int getChildCount(Object parent) { if (parent == d_root) { return d_nodes.size(); }//from www .ja v a2 s . c o m if (parent instanceof ModelType) { SortedSet<MCMCPresentation> children = d_nodes.get(parent); return children == null ? 0 : children.size(); } return 0; }