/** * Sets the value at the specified index. * * @param index the index of the value to set * @param value the new value to set * @return the previous value at that index * @throws IndexOutOfBoundsException if the index is invalid * @since 3.2 */ public V setValue(final int index, final V value) { final K key = insertOrder.get(index); return put(key, value); }
@Override public void putAll(final Map<? extends K, ? extends V> map) { for (final Map.Entry<? extends K, ? extends V> entry : map.entrySet()) { put(entry.getKey(), entry.getValue()); } }
/** * Puts the values contained in a supplied Map into the Map starting at * the specified index. * * @param index the index in the Map to start at. * @param map the Map containing the entries to be added. * @throws IndexOutOfBoundsException if the index is out of range [0, size] */ public void putAll(int index, final Map<? extends K, ? extends V> map) { if (index < 0 || index > insertOrder.size()) { throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + insertOrder.size()); } for (final Map.Entry<? extends K, ? extends V> entry : map.entrySet()) { final K key = entry.getKey(); final boolean contains = containsKey(key); // The return value of put is null if the key did not exist OR the value was null // so it cannot be used to determine whether the key was added put(index, entry.getKey(), entry.getValue()); if (!contains) { // if no key was replaced, increment the index index++; } else { // otherwise put the next item after the currently inserted key index = indexOf(entry.getKey()) + 1; } } }
@Override protected void handleResponse(Response response, Request<List<Message>> request) { if (!response.isOk()) { request.onFailure(response); return; } EntityBuilder builder = api.get().getEntityBuilder(); LinkedList<Message> msgs = new LinkedList<>(); JSONArray historyJson = response.getArray(); for (int i = 0; i < historyJson.length(); i++) msgs.add(builder.createMessage(historyJson.getJSONObject(i))); for (Iterator<Message> it = msgs.descendingIterator(); it.hasNext();) { Message m = it.next(); history.put(0, m.getIdLong(), m); } request.onSuccess(msgs); } };
@Override protected void handleResponse(Response response, Request<List<Message>> request) { if (!response.isOk()) { request.onFailure(response); return; } EntityBuilder builder = api.get().getEntityBuilder(); LinkedList<Message> msgs = new LinkedList<>(); JSONArray historyJson = response.getArray(); for (int i = 0; i < historyJson.length(); i++) msgs.add(builder.createMessage(historyJson.getJSONObject(i))); msgs.forEach(msg -> history.put(msg.getIdLong(), msg)); request.onSuccess(msgs); } };
@Override protected void handleResponse(Response response, Request<MessageHistory> request) { if (!response.isOk()) { request.onFailure(response); return; } final MessageHistory result = new MessageHistory(channel); final JSONArray array = response.getArray(); final EntityBuilder builder = api.get().getEntityBuilder(); for (int i = 0; i < array.length(); i++) { try { JSONObject obj = array.getJSONObject(i); result.history.put(obj.getLong("id"), builder.createMessage(obj, channel, false)); } catch (JSONException | NullPointerException e) { LOG.warn("Encountered exception in MessagePagination", e); } } request.onSuccess(result); } }
VClassGroup group = (VClassGroup)classGroupIt.next(); List classes = group.getVitroClassList(); optGroupMap.put(group.getPublicName(),FormUtils.makeOptionListFromBeans(classes,"URI","Name",individualForEditing.getVClassURI(),null,false)); dpMap.put(d.getURI(), d); dpMap.put(existingDp.getURI(), existingDp);