List of usage examples for java.util LinkedHashMap put
V put(K key, V value);
From source file:models.security.SecurityRole.java
public static Map<String, String> options() { @SuppressWarnings("unchecked") final List<SecurityRole> securityRoles = find.findList(); final LinkedHashMap<String, String> options = new LinkedHashMap<String, String>(); for (final SecurityRole securityRole : securityRoles) { options.put(securityRole.id.toString(), securityRole.roleName); }//w w w .ja v a 2s.c o m return options; }
From source file:net.sourceforge.subsonic.controller.VideoPlayerController.java
public static Map<String, Integer> createSkipOffsets(int durationSeconds) { LinkedHashMap<String, Integer> result = new LinkedHashMap<String, Integer>(); for (int i = 0; i < durationSeconds; i += 60) { result.put(StringUtil.formatDuration(i), i); }//from w w w. j a v a2 s .com return result; }
From source file:Main.java
public static <K, V> void sortMap(LinkedHashMap<K, V> map, Comparator<Map.Entry<K, V>> c) { List<Map.Entry<K, V>> entries = new ArrayList<>(map.entrySet()); entries.sort(c);/*from w ww . j a va 2 s . co m*/ map.clear(); for (Map.Entry<K, V> e : entries) { map.put(e.getKey(), e.getValue()); } }
From source file:hudson.plugins.parameterizedtrigger.ParameterizedTriggerUtils.java
public static ParametersAction mergeParameters(ParametersAction base, ParametersAction overlay) { LinkedHashMap<String, ParameterValue> params = new LinkedHashMap<String, ParameterValue>(); for (ParameterValue param : base.getParameters()) params.put(param.getName(), param); for (ParameterValue param : overlay.getParameters()) params.put(param.getName(), param); return new ParametersAction(params.values().toArray(new ParameterValue[params.size()])); }
From source file:net.yacy.cora.federate.opensearch.SRURSSConnector.java
/** * send a query to a yacy public search interface * @param rssSearchServiceURL the target url base (everything before the ? that follows the SRU request syntax properties). can null, then the local peer is used * @param query the query as string/*w w w. java2s. c o m*/ * @param startRecord number of first record * @param maximumRecords maximum number of records * @param verify if true, result entries are verified using the snippet fetch (slow); if false simply the result is returned * @param global if true also search results from other peers are included * @return */ public static RSSFeed loadSRURSS(final String rssSearchServiceURL, final String query, final int startRecord, final int maximumRecords, final CacheStrategy cacheStrategy, final boolean global, final ClientIdentification.Agent agent) throws IOException { MultiProtocolURL uri = null; try { uri = new MultiProtocolURL(rssSearchServiceURL); } catch (final MalformedURLException e) { throw new IOException( "cora.Search failed asking peer '" + rssSearchServiceURL + "': bad url, " + e.getMessage()); } // send request byte[] result = new byte[0]; try { final LinkedHashMap<String, ContentBody> parts = new LinkedHashMap<String, ContentBody>(); parts.put("query", UTF8.StringBody(query)); parts.put("startRecord", UTF8.StringBody(Integer.toString(startRecord))); parts.put("maximumRecords", UTF8.StringBody(Long.toString(maximumRecords))); parts.put("verify", cacheStrategy == null ? UTF8.StringBody("false") : UTF8.StringBody(cacheStrategy.toName())); parts.put("resource", UTF8.StringBody(global ? "global" : "local")); parts.put("nav", UTF8.StringBody("none")); // result = HTTPConnector.getConnector(userAgent == null ? MultiProtocolURI.yacybotUserAgent : userAgent).post(new MultiProtocolURI(rssSearchServiceURL), (int) timeout, uri.getHost(), parts); final HTTPClient httpClient = new HTTPClient(agent); result = httpClient.POSTbytes(new MultiProtocolURL(rssSearchServiceURL), uri.getHost(), parts, false, false); final RSSReader reader = RSSReader.parse(RSSFeed.DEFAULT_MAXSIZE, result); if (reader == null) { throw new IOException("cora.Search failed asking peer '" + uri.getHost() + "': probably bad response from remote peer (1), reader == null"); } final RSSFeed feed = reader.getFeed(); if (feed == null) { // case where the rss reader does not understand the content throw new IOException("cora.Search failed asking peer '" + uri.getHost() + "': probably bad response from remote peer (2)"); } return feed; } catch (final IOException e) { throw new IOException("cora.Search error asking peer '" + uri.getHost() + "':" + e.toString()); } }
From source file:nz.net.orcon.kanban.controllers.RuleControllerTest.java
protected static Rule getTestRule(String ruleName, String conditionName, Operation operation, String value) throws JsonGenerationException, JsonMappingException, IOException { Map<String, Condition> conditions = new HashMap<String, Condition>(); Condition condition = new Condition(); condition.setFieldName(conditionName); condition.setOperation(operation);/*from w w w . j a v a 2 s . co m*/ condition.setValue(value); conditions.put(conditionName, condition); LinkedHashMap<String, String> properties = new LinkedHashMap<String, String>(); //fibre-template fields properties.put("title", "test-title"); properties.put("detail", "required"); properties.put("deadline", "2014-02-21"); properties.put("size", "3"); properties.put("priority", "1"); properties.put("productowner", "peter"); properties.put("developer", "kevin"); properties.put("system", "software"); Action action = new Action(); action.setName("testAction"); action.setType("execute"); action.setResource("testPlugin"); action.setProperties(properties); action.setOrder(1); action.setMethod("executeRule"); action.setResponse("samId"); List<String> parameterList = new ArrayList<String>(); parameterList.add("title"); parameterList.add("detail"); parameterList.add("deadline"); parameterList.add("size"); parameterList.add("priority"); parameterList.add("productowner"); parameterList.add("developer"); parameterList.add("system"); action.setParameters(parameterList); Map<String, Action> actions = new HashMap<String, Action>(); actions.put("testAction", action); Rule rule = new Rule(); rule.setName(ruleName); rule.setAutomationConditions(conditions); rule.setTaskConditions(null); rule.setActions(actions); return rule; }
From source file:de.iew.framework.security.access.RequestMapbuilder.java
/** * Builds a request web resource map data structure. * <p>//from w w w . j a va2s . co m * The data structure maps a {@link RequestMatcher} instance to the {@link WebResource} instance. * </p> * * @param requestMapEntries the request map entries. * @return the request web resource map */ public static LinkedHashMap<RequestMatcher, WebResource> buildRequestWebResourceMap( Collection<RequestMapEntry> requestMapEntries) { // Calculate the initial capacity for our LinkedHashMap float requestmapEntrySize = (float) requestMapEntries.size(); int mapInitialCapacity = (int) Math.ceil(requestmapEntrySize / REQUEST_MAP_LOAD_FACTOR); if (log.isDebugEnabled()) { log.debug("Initialisiere die LinkedHashMap mit einer Kapazitt von " + mapInitialCapacity + " Eintrgen."); } LinkedHashMap<RequestMatcher, WebResource> requestMap = new LinkedHashMap<RequestMatcher, WebResource>(); for (RequestMapEntry requestMapEntry : requestMapEntries) { requestMap.put(requestMapEntry.getRequestMatcher(), requestMapEntry.getWebResource()); } return requestMap; }
From source file:Main.java
public static <K, V> void putAt(LinkedHashMap<K, V> map, K key, V value, int pos) { Iterator<Entry<K, V>> ei = map.entrySet().iterator(); LinkedHashMap<K, V> pre = new LinkedHashMap<>(); LinkedHashMap<K, V> post = new LinkedHashMap<>(); for (int i = 0; i < pos; i++) { if (!ei.hasNext()) break; Entry<K, V> tmpE = ei.next(); pre.put(tmpE.getKey(), tmpE.getValue()); }//from ww w. j av a2 s .com // skip element at pos if (ei.hasNext()) ei.next(); while (ei.hasNext()) { Entry<K, V> tmpE = ei.next(); post.put(tmpE.getKey(), tmpE.getValue()); } map.clear(); map.putAll(pre); map.put(key, value); map.putAll(post); }
From source file:eu.project.ttc.utils.TermSuiteUtils.java
public static <T> LinkedHashMap<T, Integer> getCounters(Iterable<T> list) { Comparator<Entry<T, MutableInt>> comparator = new Comparator<Entry<T, MutableInt>>() { public int compare(Entry<T, MutableInt> o1, Entry<T, MutableInt> o2) { return ComparisonChain.start().compare(o2.getValue(), o1.getValue()).result(); };/*from ww w. j av a2 s .co m*/ }; Map<T, MutableInt> map = Maps.newHashMap(); for (T e : list) { MutableInt counter = map.get(e); if (counter == null) { counter = new MutableInt(0); map.put(e, counter); } counter.increment(); } List<Entry<T, MutableInt>> entries = Lists.newArrayList(map.entrySet()); Collections.sort(entries, comparator); LinkedHashMap<T, Integer> counters = Maps.newLinkedHashMap(); for (Entry<T, MutableInt> e : entries) counters.put(e.getKey(), e.getValue().intValue()); return counters; }
From source file:com.boozallen.cognition.ingest.storm.util.ConfigurationMapEntryUtils.java
/** * Extracts Map<String, String> from XML of the format: * <pre>//from w w w . ja va 2s . c om * {@code <mapName> * <entry> * <key>k0</key> * <value>v0</value> * </entry> * <entry> * <key>k1</key> * <value>v1</value> * </entry> * </mapName> * } * </pre> * * @param conf * @param mapName * @param entry * @param key * @param value * @return */ public static Map<String, String> extractSimpleMap(final Configuration conf, final String mapName, final String entry, final String key, final String value) { List<Object> fieldsList = conf.getList(mapName + "." + entry + "." + key); LinkedHashMap<String, String> map = new LinkedHashMap<String, String>(); for (int i = 0; i < fieldsList.size(); i++) { String relevanceField = conf.getString(mapName + "." + entry + "(" + i + ")." + value); map.put(fieldsList.get(i).toString(), relevanceField); } return map; }