List of usage examples for java.util SortedSet toArray
Object[] toArray();
From source file:Main.java
public static void main(String[] args) { MyObject a1 = new MyObject("a", 1); MyObject a2 = new MyObject("a", 2); MyObject a3 = new MyObject("a", 3); MyObject b1 = new MyObject("b", 1); MyObject b2 = new MyObject("b", 2); MyObject b2a = new MyObject("b", 2); MyObject nullLevel = new MyObject("a", null); MyObject nullName = new MyObject(null, 2); SortedSet<MyObject> set = new TreeSet<MyObject>(); set.add(a1);//from ww w. j a va 2 s . c o m set.add(a2); set.add(a3); set.add(b1); set.add(b2); set.add(b2a); set.add(nullLevel); set.add(nullName); System.out.println(Arrays.toString(set.toArray())); }
From source file:com.recomdata.export.ExportTable.java
public void setColumns(String patientIds1, String patientIds2) { columns.put("Gene", new ExportColumn("Gene", "Gene", "", "t")); // StringTokenizer st1 = new StringTokenizer(patientIds1, ","); // while (st1.hasMoreTokens()) { // String id = st1.nextToken(); // String label = "S1_" + id;//(ids1.size() + 1); // ids1.put(id, label); // columns.put(label, new ExportColumn(id, label, RATIO_PATTERN, "n")); // }//from w w w .j ava2 s. co m StringTokenizer st1 = new StringTokenizer(patientIds1, ","); SortedSet s1 = new TreeSet(); while (st1.hasMoreTokens()) { String id = st1.nextToken(); s1.add(id); } for (Object idO : s1.toArray()) { String id = idO.toString(); System.out.println("id: " + id); String label = "S1_" + id;//(ids1.size() + 1); ids1.put(id, label); columns.put(label, new ExportColumn(id, label, RATIO_PATTERN, "n")); } StringTokenizer st2 = new StringTokenizer(patientIds2, ","); while (st2.hasMoreTokens()) { String id = st2.nextToken(); String label = "S2_" + id;//(ids2.size() + 1); ids2.put(id, label); columns.put(label, new ExportColumn(id, label, RATIO_PATTERN, "n")); } }
From source file:com.google.gwt.emultest.java.util.TreeSetTest.java
/** * Verify that two SortedMaps are deeply equivalent. * * @param expected//from w w w . j a v a 2 s . com * @param actual */ private static <E> void _assertEquals(SortedSet<E> expected, SortedSet<E> actual) { _assertEquals((Set<E>) expected, (Set<E>) actual); // verify the order of the associated collections assertEquals(expected.toArray(), actual.toArray()); }
From source file:org.jclouds.aws.s3.xml.S3ParserTest.java
@Test public void testCanParseListAllMyBuckets() throws HttpException { SortedSet<BucketMetadata> s3Buckets = runParseListAllMyBuckets(); BucketMetadata container1 = s3Buckets.first(); assert container1.getName().equals("adrianjbosstest"); DateTime expectedDate1 = new DateTime("2009-03-12T02:00:07.000Z"); DateTime date1 = container1.getCreationDate(); assert date1.equals(expectedDate1); BucketMetadata container2 = (BucketMetadata) s3Buckets.toArray()[1]; assert container2.getName().equals("adrianjbosstest2"); DateTime expectedDate2 = new DateTime("2009-03-12T02:00:09.000Z"); DateTime date2 = container2.getCreationDate(); assert date2.equals(expectedDate2); assert s3Buckets.size() == 2; CanonicalUser owner = new CanonicalUser("e1a5f66a480ca99a4fdfe8e318c3020446c9989d7004e7778029fbcc5d990fa0"); assert container1.getOwner().equals(owner); assert container2.getOwner().equals(owner); }
From source file:com.zigabyte.stock.stratplot.StockMarketHistoryViewer.java
/** Refresh the stock list after the stock market history is changed. **/ private void refreshList() { if (this.stockMarketHistory != null && this.stockMarketHistory.size() > 0) { SortedSet<StockHistory> sortedStockHistories = new TreeSet<StockHistory>(TO_STRING_COMPARATOR); int index = 0; Calendar calendar = new GregorianCalendar(); for (StockHistory stockHistory : stockMarketHistory) { if (stockHistory.size() > 0) { calendar.clear();/*from ww w .j a v a 2s . c o m*/ calendar.setTime(stockHistory.get(0).getDate()); sortedStockHistories.add(stockHistory); } } stockList.setListData(sortedStockHistories.toArray()); } else { stockList.setListData(new Object[] {}); } }
From source file:com.espertech.esper.filter.TestFilterSpecParamComparator.java
public void testCompareAll() { SortedSet<FilterOperator> sorted = new TreeSet<FilterOperator>(comparator); for (int i = 0; i < FilterOperator.values().length; i++) { FilterOperator op = FilterOperator.values()[i]; sorted.add(op);//from w ww . j a v a2s. co m } assertEquals(FilterOperator.EQUAL, sorted.first()); assertEquals(FilterOperator.BOOLEAN_EXPRESSION, sorted.last()); assertEquals( "[EQUAL, IS, IN_LIST_OF_VALUES, RANGE_OPEN, RANGE_HALF_OPEN, RANGE_HALF_CLOSED, RANGE_CLOSED, LESS, LESS_OR_EQUAL, GREATER_OR_EQUAL, GREATER, NOT_RANGE_CLOSED, NOT_RANGE_HALF_CLOSED, NOT_RANGE_HALF_OPEN, NOT_RANGE_OPEN, NOT_IN_LIST_OF_VALUES, NOT_EQUAL, IS_NOT, BOOLEAN_EXPRESSION]", sorted.toString()); log.debug(".testCompareAll " + Arrays.toString(sorted.toArray())); }
From source file:org.kuali.kfs.coa.service.impl.ObjectCodeServiceImpl.java
/** * @see org.kuali.kfs.coa.service.ObjectCodeService#getObjectCodeNamesByCharts(java.lang.Integer, java.lang.String[], * java.lang.String)//from w w w. j a v a 2s .c o m */ @Override public String getObjectCodeNamesByCharts(Integer universityFiscalYear, String[] chartOfAccountCodes, String financialObjectCode) { String onlyObjectCodeName = ""; SortedSet<String> objectCodeNames = new TreeSet<String>(); List<String> objectCodeNameList = new ArrayList<String>(); for (String chartOfAccountsCode : chartOfAccountCodes) { ObjectCode objCode = this.getByPrimaryId(universityFiscalYear, chartOfAccountsCode, financialObjectCode); if (objCode != null) { onlyObjectCodeName = objCode.getFinancialObjectCodeName(); objectCodeNames.add(objCode.getFinancialObjectCodeName()); objectCodeNameList.add(chartOfAccountsCode + ": " + objCode.getFinancialObjectCodeName()); } else { onlyObjectCodeName = "Not Found"; objectCodeNameList.add(chartOfAccountsCode + ": Not Found"); } } if (objectCodeNames.size() > 1) { return StringUtils.join(objectCodeNames.toArray(), ", "); } else { return onlyObjectCodeName; } }
From source file:org.stockwatcher.data.cassandra.WatchListDAOImpl.java
@Override public void deleteWatchList(StatementOptions options, UUID id) { if (id == null) { throw new IllegalArgumentException("id argument is null"); }/* w w w . ja va 2s . com*/ try { // Get the stock symbols before we delete them from the watch list SortedSet<String> symbols = getWatchListStockSymbols(options, id); RegularStatement statement1 = delete().from("WatchListItem").where(eq("watchlist_id", id)); Batch batch = batch(statement1); RegularStatement statement2 = delete().from("WatchList").where(eq("watchlist_id", id)); batch.add(statement2); execute(batch, options); // Statements with counter column families cannot be executed in a batch if (!symbols.isEmpty()) { Statement statement3 = update("StockCount").with(decr("watch_count")) .where(in("stock_symbol", (Object[]) symbols.toArray())); execute(statement3, options); } } catch (DriverException e) { throw new DAOException(e); } }
From source file:com.redhat.rhn.frontend.xmlrpc.kickstart.profile.ProfileHandler.java
/** * Get custom options for a kickstart profile. * @param loggedInUser The current user/*from w ww. j a v a2 s . co m*/ * @param ksLabel the kickstart label * @return a list of hashes holding this info. * @throws FaultException A FaultException is thrown if * the profile associated with ksLabel cannot be found * * @xmlrpc.doc Get custom options for a kickstart profile. * @xmlrpc.param #session_key() * @xmlrpc.param #param("string","ksLabel") * * @xmlrpc.returntype * #array() * $KickstartCommandSerializer * #array_end() */ public Object[] getCustomOptions(User loggedInUser, String ksLabel) throws FaultException { KickstartData ksdata = KickstartFactory.lookupKickstartDataByLabelAndOrgId(ksLabel, loggedInUser.getOrg().getId()); if (ksdata == null) { throw new FaultException(-3, "kickstartProfileNotFound", "No Kickstart Profile found with label: " + ksLabel); } SortedSet options = ksdata.getCustomOptions(); return options.toArray(); }
From source file:com.google.gwt.emultest.java.util.TreeSetTest.java
/** * Test method for 'java.util.SortedSet.first()'. * * @see java.util.SortedSet#first()//w ww .jav a 2 s . c o m */ public void testFirst() { SortedSet<E> sortedSet = createNavigableSet(); // test with a single entry set sortedSet.add(getKeys()[0]); assertEquals(getKeys()[0], sortedSet.first()); // is it consistent with other methods assertEquals(sortedSet.toArray()[0], sortedSet.first()); assertEquals(getKeys()[0], sortedSet.last()); assertEquals(sortedSet.last(), sortedSet.first()); // test with two entry set sortedSet.add(getKeys()[1]); assertEquals(getKeys()[0], sortedSet.first()); assertFalse(getKeys()[1].equals(sortedSet.first())); // is it consistent with other methods assertEquals(sortedSet.toArray()[0], sortedSet.first()); assertFalse(getKeys()[0].equals(sortedSet.last())); assertFalse(sortedSet.last().equals(sortedSet.first())); }