List of usage examples for java.util TreeMap put
public V put(K key, V value)
From source file:org.andrico.andrico.facebook.FBBase.java
/** * Generate a URL authorizing a requested extended preference. * //from w w w .jav a2 s. c o m * @param Which preference to generate the request URL for. * @return */ public Uri authorizeExtendedPreferenceUrl(String extPerm, String next, String nextCancel) { TreeMap<String, String> parameters = new TreeMap<String, String>(); parameters.put("api_key", mApiKey); parameters.put("ext_perm", extPerm); parameters.put("popup", "1"); parameters.put("v", "1.0"); if (next != null) { parameters.put("next", next); } if (nextCancel != null) { parameters.put("next_cancel", nextCancel); } Uri url = Uri.withAppendedPath(WWW_URI, "authorize.php?" + FBMethod.urlParameters(parameters)); Log.e(LOG, "Generated setStatus authorization URL: " + url); return url; }
From source file:org.spirit.spring.BotListAdminController.java
protected ModelAndView getModelAndView(Object rubyResult, String defaultView) { String viewName = null;/* w w w . j a v a 2 s.c om*/ if (BotListBaseForm.class.isAssignableFrom(rubyResult.getClass())) { // Or use the Base Class Form to get the view name. BotListBaseForm form = (BotListBaseForm) rubyResult; if (form.getViewName() != null) { viewName = form.getViewName(); } } if (viewName == null) { viewName = defaultView; } TreeMap result = new TreeMap(); result.put(getCommandName(), rubyResult); return new ModelAndView(viewName, result); }
From source file:com.xpn.xwiki.objects.classes.GroupsClass.java
@Override public void displayEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {// w w w .j a v a 2 s . com select select = new select(prefix + name, 1); select.setMultiple(isMultiSelect()); select.setSize(getSize()); select.setName(prefix + name); select.setID(prefix + name); select.setDisabled(isDisabled()); List<String> list; if (isUsesList()) { list = getList(context); } else { list = new ArrayList<String>(); } List<String> selectlist; BaseProperty prop = (BaseProperty) object.safeget(name); if (prop == null) { selectlist = new ArrayList<String>(); } else { selectlist = getListFromString((String) prop.getValue()); } list.remove("XWiki.XWikiAllGroup"); list.add(0, "XWiki.XWikiAllGroup"); if (!context.isMainWiki()) { list.remove("xwiki:XWiki.XWikiAllGroup"); list.add(1, "xwiki:XWiki.XWikiAllGroup"); } // Add options from Set for (String value : selectlist) { if (!list.contains(value)) { list.add(value); } } // Sort the group list TreeMap<String, String> map = new TreeMap<String, String>(); for (String value : list) { map.put(getText(value, context), value); } for (Map.Entry<String, String> entry : map.entrySet()) { String display = entry.getKey(); String value = entry.getValue(); option option = new option(display, value); option.addElement(display); if (selectlist.contains(value)) { option.setSelected(true); } select.addElement(option); } buffer.append(select.toString()); if (!isUsesList()) { input in = new input(); in.setName(prefix + "newgroup"); in.setID(prefix + "newgroup"); in.setSize(15); in.setDisabled(isDisabled()); buffer.append("<br />"); buffer.append(in.toString()); if (!isDisabled()) { button button = new button(); button.setTagText("Add"); button.setOnClick("addGroup(this.form,'" + prefix + "'); return false;"); buffer.append(button.toString()); } } input in = new input(); in.setType("hidden"); in.setName(prefix + name); in.setDisabled(isDisabled()); buffer.append(in.toString()); }
From source file:com.edmunds.etm.runtime.api.ApplicationSeries.java
/** * Adds or replaces the specified application version in this series. * * @param application the application to add or replace * @return the previous application of the same version, or null if there was no entry for the version *///www.ja v a 2s . c om public ApplicationSeries addOrReplace(Application application) { Validate.notNull(application); if (!application.getName().equals(name)) { String message = String.format("Application name '%s' does not match series name '%s'", application.getName(), name); throw new IllegalArgumentException(message); } final Application previous = applicationsByVersion.get(application.getVersion()); // If the previous version of this app was active so should this version be. if (previous != null && previous.isActive()) { application = new Application(application, true); } // Create a mutable copy of the active versions map. final TreeMap<ApplicationVersion, Application> temp = Maps.newTreeMap(applicationsByVersion); // Add the new version. temp.put(application.getVersion(), application); // Activate if necessary updateActiveVersion(temp); // Wrap the mapping in a new application series. return new ApplicationSeries(name, temp); }
From source file:org.opendatakit.common.android.data.ColorRule.java
public TreeMap<String, Object> getJsonRepresentation() { TreeMap<String, Object> map = new TreeMap<String, Object>(); map.put("mValue", mValue); map.put("mElementKey", mElementKey); map.put("mOperator", mOperator.name()); map.put("mId", mId); map.put("mForeground", mForeground); map.put("mBackground", mBackground); return map;//from ww w .j av a 2s .c o m }
From source file:jef.jre5support.Headers.java
public String toValueString() { TreeMap<String, String> m = new TreeMap<String, String>(); for (String s : map.keySet()) { m.put(s, map.get(s).get(0)); }//from w ww. j a v a 2s. c o m return StringUtils.join(m.values(), ","); }
From source file:org.powertac.producer.ProducerServiceTest.java
@Before public void setUp() { customerRepo.recycle();/* w w w .ja va 2 s .c o m*/ brokerRepo.recycle(); tariffRepo.recycle(); reset(mockTariffSubscriptionRepo); randomSeedRepo.recycle(); timeslotRepo.recycle(); weatherReportRepo.recycle(); weatherReportRepo.runOnce(); producerService.clearConfiguration(); reset(mockAccounting); reset(mockServerProperties); // create a Competition, needed for initialization comp = Competition.newInstance("producer-test"); broker1 = new Broker("Joe"); // now = new DateTime(2009, 10, 10, 0, 0, 0, 0, // DateTimeZone.UTC).toInstant(); now = comp.getSimulationBaseTime(); timeService.setCurrentTime(now); timeService.setClockParameters(now.toInstant().getMillis(), 720l, 60 * 60 * 1000); exp = now.plus(TimeService.WEEK * 10); defaultTariffSpec = new TariffSpecification(broker1, PowerType.PRODUCTION).withExpiration(exp) .addRate(new Rate().withValue(0.5)); defaultTariff = new Tariff(defaultTariffSpec); defaultTariff.init(); defaultTariff.setState(Tariff.State.OFFERED); tariffRepo.setDefaultTariff(defaultTariffSpec); when(mockTariffMarket.getDefaultTariff(PowerType.FOSSIL_PRODUCTION)).thenReturn(defaultTariff); when(mockTariffMarket.getDefaultTariff(PowerType.RUN_OF_RIVER_PRODUCTION)).thenReturn(defaultTariff); when(mockTariffMarket.getDefaultTariff(PowerType.SOLAR_PRODUCTION)).thenReturn(defaultTariff); when(mockTariffMarket.getDefaultTariff(PowerType.WIND_PRODUCTION)).thenReturn(defaultTariff); accountingArgs = new ArrayList<Object[]>(); // mock the AccountingService, capture args doAnswer(new Answer<Object>() { public Object answer(InvocationOnMock invocation) { Object[] args = invocation.getArguments(); accountingArgs.add(args); return null; } }).when(mockAccounting).addTariffTransaction(isA(TariffTransaction.Type.class), isA(Tariff.class), isA(CustomerInfo.class), anyInt(), anyDouble(), anyDouble()); // Set up serverProperties mock config = new Configurator(); doAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) { Object[] args = invocation.getArguments(); config.configureSingleton(args[0]); return null; } }).when(mockServerProperties).configureMe(anyObject()); TreeMap<String, String> map = new TreeMap<String, String>(); map.put("common.competition.expectedTimeslotCount", "1440"); Configuration mapConfig = new MapConfiguration(map); config.setConfiguration(mapConfig); config.configureSingleton(comp); }
From source file:captureplugin.drivers.defaultdriver.configpanels.ChannelTableModel.java
/** * Updates the List of Channels/*from www. j a v a 2 s . c om*/ */ private void updateChannels() { PluginManager pl = Plugin.getPluginManager(); if (pl == null) { return; } TreeMap<Channel, String> channels = mData.getChannels(); final Channel[] channelArray = pl.getSubscribedChannels(); for (Channel channel : channelArray) { if (!channels.containsKey(channel)) { channels.put(channel, ""); } } mData.setChannels(channels); mChannelRows = new ArrayList<Channel>(mData.getChannels().keySet()); Collections.sort(mChannelRows, new Comparator<Channel>() { public int compare(Channel a, Channel b) { return ArrayUtils.indexOf(channelArray, a) - ArrayUtils.indexOf(channelArray, b); } }); }
From source file:org.motrice.jmx.BasicAppManagement.java
/** * Return all loggers as a map where the key is the full logger name, * the value is a logger./*from w w w . ja v a2 s . com*/ */ private SortedMap<String, Logger> doGetLoggers() { TreeMap<String, Logger> map = new TreeMap<String, Logger>(); for (Enumeration e = LogManager.getCurrentLoggers(); e.hasMoreElements();) { Logger log = (Logger) e.nextElement(); if (log.getLevel() != null) { map.put(log.getName(), log); } } return map; }
From source file:com.sfs.whichdoctor.xml.writer.helper.AccreditationXmlHelper.java
/** * Output the training summary as an XML string. * * @param trainingSummary the training summary * @param type the type//from w w w . j a v a2 s . c om * * @return the xml string */ public static String getSummaryXml(final TreeMap<String, AccreditationBean[]> trainingSummary, final String type) { final XmlWriter xmlwriter = new XmlWriter(); if (trainingSummary.size() > 0) { int totalCore = 0; int totalNonCore = 0; TreeMap<String, ArrayList<AccreditationBean[]>> summaryTreemap = new TreeMap<String, ArrayList<AccreditationBean[]>>(); for (String summaryKey : trainingSummary.keySet()) { AccreditationBean[] details = trainingSummary.get(summaryKey); AccreditationBean core = details[0]; AccreditationBean nonCore = details[1]; totalCore += core.getWeeksCertified(); totalNonCore += nonCore.getWeeksCertified(); if (StringUtils.isNotBlank(core.getSpecialtyType())) { ArrayList<AccreditationBean[]> summaries = new ArrayList<AccreditationBean[]>(); if (!summaryTreemap.containsKey(core.getSpecialtyType())) { /* New type of specialty */ summaries.add(details); } else { /* Existing specialty */ summaries = summaryTreemap.get(core.getSpecialtyType()); summaries.add(details); } summaryTreemap.put(core.getSpecialtyType(), summaries); } } xmlwriter.writeEntity("trainingSummary"); xmlwriter.writeAttribute("type", type); xmlwriter.writeAttribute("totalCore", Formatter.getWholeMonths(totalCore)); xmlwriter.writeAttribute("totalNonCore", Formatter.getWholeMonths(totalNonCore)); xmlwriter.writeEntity("specialtyTraining"); for (String specialtyType : summaryTreemap.keySet()) { ArrayList<AccreditationBean[]> summaries = summaryTreemap.get(specialtyType); int typeCoreWeeks = 0; int typeNCWeeks = 0; if (summaries != null) { // For each accredited specialty create an element xmlwriter.writeEntity("specialty"); xmlwriter.writeEntity("subtypes"); String division = ""; String abbreviation = ""; String specialtytype = ""; String typeAbbreviation = ""; for (Object[] summary : summaries) { boolean blSubType = false; AccreditationBean core = (AccreditationBean) summary[0]; AccreditationBean nonCore = (AccreditationBean) summary[1]; division = core.getAccreditationClass(); abbreviation = core.getAbbreviation(); specialtytype = core.getSpecialtyType(); typeAbbreviation = core.getSpecialtyTypeAbbreviation(); if (StringUtils.isNotBlank(core.getSpecialtySubType())) { blSubType = true; xmlwriter.writeEntity("subtype"); xmlwriter.writeEntity("name").writeText(core.getSpecialtySubType()).endEntity(); xmlwriter.writeEntity("coreMonths") .writeText(Formatter.getWholeMonths(core.getWeeksCertified())).endEntity(); xmlwriter.writeEntity("nonCoreMonths") .writeText(Formatter.getWholeMonths(nonCore.getWeeksCertified())).endEntity(); xmlwriter.endEntity(); typeCoreWeeks += core.getWeeksCertified(); typeNCWeeks += nonCore.getWeeksCertified(); } if (!blSubType) { xmlwriter.writeEntity("subtype"); xmlwriter.writeEntity("coreMonths") .writeText(Formatter.getWholeMonths(core.getWeeksCertified())).endEntity(); xmlwriter.writeEntity("nonCoreMonths") .writeText(Formatter.getWholeMonths(nonCore.getWeeksCertified())).endEntity(); xmlwriter.endEntity(); typeCoreWeeks += core.getWeeksCertified(); typeNCWeeks += nonCore.getWeeksCertified(); } } xmlwriter.endEntity(); xmlwriter.writeEntity("division").writeText(division).endEntity(); xmlwriter.writeEntity("abbreviation").writeText(abbreviation).endEntity(); xmlwriter.writeEntity("type").writeText(specialtytype).endEntity(); xmlwriter.writeEntity("typeAbbreviation").writeText(typeAbbreviation).endEntity(); xmlwriter.writeEntity("coreMonths").writeText(Formatter.getWholeMonths(typeCoreWeeks)) .endEntity(); xmlwriter.writeEntity("nonCoreMonths").writeText(Formatter.getWholeMonths(typeNCWeeks)) .endEntity(); xmlwriter.endEntity(); } } xmlwriter.endEntity(); xmlwriter.endEntity(); } return xmlwriter.getXml(); }