List of usage examples for java.util TreeMap TreeMap
public TreeMap()
From source file:com.google.cloud.metrics.MetricsUtilsTest.java
@Test public void testCreateVirtualPageTitle() { // We use a sorted map to ensure that the order of the entries is // consistent for simpler testing. Normally clients don't care about order. Map<String, String> metadata = new TreeMap<>(); metadata.put("key1", "value1"); metadata.put("key2", "value2"); // Test escaping behavior metadata.put("key3,=\\", "value3,=\\"); String result = MetricsUtils.buildVirtualPageTitle(metadata); assertThat(result).isEqualTo("key1=value1,key2=value2,key3\\,\\=\\\\=value3\\,\\=\\\\"); }
From source file:org.dspace.orm.dao.database.MetadataValueDao.java
private MetadataFieldRegistry getField(String field) { int pos = field.indexOf("."); String schemaName = field.substring(0, pos); String fieldName = field.substring(pos + 1); if (fields == null) fields = new TreeMap<String, MetadataFieldRegistry>(); if (!fields.containsKey(field)) { fields.put(field, fieldRegistry.selectByNameAndSchema(this.getSchema(schemaName), fieldName)); }/*from ww w . jav a2 s . c o m*/ return fields.get(field); }
From source file:com.artemisa.service.UserServiceImpl.java
public User findOneByUserName(String userName) throws HibernateException { Map<String, String> conditions = new TreeMap<>(); conditions.put("", "username = '" + userName + "'"); List<User> users = this.service.find(conditions); if (users != null) { return users.get(0); }//from w w w .java 2 s .co m return null; }
From source file:eionet.gdem.qa.engines.XGawkQueryEngineTest.java
@Test public void testGetShellCommandWithParams() throws Exception { String dataFile = "data.xml"; String scriptFile = "script.xml"; Map params = new TreeMap<String, String>(); params.put("param2", "param2value"); params.put("source_url", "http://localhost/dummy.xml"); XGawkQueryEngine engine = new XGawkQueryEngine(); String command = engine.getShellCommand(dataFile, scriptFile, params); assertEquals(/*ww w.ja v a2 s .c om*/ Properties.xgawkCommand + " -v param2=\"param2value\" -v source_url=\"http://localhost/dummy.xml\" " + "-f script.xml data.xml", command); }
From source file:com.octo.mbo.domain.ApproachingMatcher.java
/** * Sort the list of keys according to their distance with the reference key * @param keysOfSlides List of keys//from www . ja va2s. c om * @param key A reference key that will be compared to each String * @return A map whose index are the distances and values a list of keys for the corresponding distance. */ public SortedMap<Integer, Set<String>> sortByDistanceWithKey(Collection<String> keysOfSlides, String key) { assert keysOfSlides != null; assert key != null; SortedMap<Integer, Set<String>> keysSortedByDistance = new TreeMap<>(); for (String slideKey : keysOfSlides) { int distK2k = levenshteinDistance.apply(normalize(key), normalize(slideKey)); if (keysSortedByDistance.containsKey(distK2k)) { keysSortedByDistance.get(distK2k).add(slideKey); } else { keysSortedByDistance.put(distK2k, new HashSet<>((Collections.singletonList(slideKey)))); } } log.trace("Sort by least distance to '{}' after normalization : {}", key, keysSortedByDistance); return keysSortedByDistance; }
From source file:com.acc.storefront.interceptors.beforeview.DebugInfoBeforeViewHandler.java
@Override public void beforeView(final HttpServletRequest request, final HttpServletResponse response, final ModelAndView modelAndView) { final boolean showDebug = Config.getBoolean(SHOW_STOREFRONT_DEBUG_INFO_PROPERTY_KEY, false); // Store the show debug flag in a request attribute request.setAttribute(SHOW_STOREFRONT_DEBUG_INFO, Boolean.valueOf(showDebug)); if (showDebug) { final JaloSession currentSession = JaloSession.getCurrentSession(); final TreeMap<String, Object> attributeMap = new TreeMap<String, Object>(); // Build up the session attributes as a request attribute attributeMap.putAll(currentSession.getAttributes()); // Add the session id as an attribute attributeMap.put("JaloSession ID", currentSession.getSessionID()); request.setAttribute(JALO_SESSION_ATTRIBUTES, mapToString(attributeMap)); }/*from w w w . j a v a 2 s .co m*/ }
From source file:com.cyclopsgroup.tornado.ui.view.user.UserProfile.java
/** * Override method execute in class UserProfile * * @see com.cyclopsgroup.waterview.Module#execute(com.cyclopsgroup.waterview.RuntimeData, com.cyclopsgroup.waterview.Context) *//*from w ww. jav a 2s.c o m*/ public void execute(RuntimeData data, Context context) throws Exception { RuntimeUser user = RuntimeUser.getInstance(data); PersistenceManager persist = (PersistenceManager) lookup(PersistenceManager.ROLE); User u = (User) persist.load(User.class, user.getId()); context.put("userObject", u); TreeMap languages = new TreeMap(); TreeMap countries = new TreeMap(); Locale[] availableLocales = Locale.getAvailableLocales(); for (int i = 0; i < availableLocales.length; i++) { Locale locale = availableLocales[i]; DefaultSelectOption lang = new DefaultSelectOption(locale.getLanguage(), locale.getDisplayLanguage(data.getLocale()) + '(' + locale.getLanguage() + ')'); languages.put(locale.getLanguage(), lang); if (StringUtils.isNotEmpty(locale.getCountry())) { DefaultSelectOption cout = new DefaultSelectOption(locale.getCountry(), locale.getDisplayCountry(data.getLocale()) + '(' + locale.getCountry() + ')'); countries.put(locale.getCountry(), cout); } } context.put("countries", countries.values()); context.put("languages", languages.values()); }
From source file:com.qrmedia.commons.collections.MapUtilsTest.java
@Test public void toMap() { Map<String, Integer> expectedMap = new TreeMap<String, Integer>(); String key = "James Bond"; Integer value = 7;/*from www .j a v a 2s .c o m*/ expectedMap.put(key, value); assertEquals(expectedMap, MapUtils.toMap(key, value)); }
From source file:com.espertech.esper.schedule.SchedulingServiceImpl.java
/** * Constructor.//ww w . j ava2 s . c o m * @param timeSourceService time source provider */ public SchedulingServiceImpl(TimeSourceService timeSourceService) { this.timeHandleMap = new TreeMap<Long, SortedMap<ScheduleSlot, ScheduleHandle>>(); this.handleSetMap = new HashMap<ScheduleHandle, SortedMap<ScheduleSlot, ScheduleHandle>>(); // initialize time to just before now as there is a check for duplicate external time events this.currentTime = timeSourceService.getTimeMillis() - 1; }
From source file:com.gopivotal.cloudfoundry.test.core.RuntimeUtils.java
public Map<String, List<String>> requestHeaders(HttpServletRequest request) { Map<String, List<String>> headers = new TreeMap<>(); for (Enumeration<String> names = request.getHeaderNames(); names.hasMoreElements();) { String name = names.nextElement(); headers.put(name, getValuesAsList(request.getHeaders(name))); }// w w w . j a v a2s .c o m return headers; }