public void testClone() { LinkedMap map = new LinkedMap(10); map.put("1", "1"); Map cloned = (Map) map.clone(); assertEquals(map.size(), cloned.size()); assertSame(map.get("1"), cloned.get("1")); }
nameMap.put(nodeName, entry); entries.put(id, entry);
public void addChildWindow(HstComponentWindow child) { if (this.childWindowMap == null) { this.childWindowMap = new LinkedMap(); } HstComponentWindow old = (HstComponentWindow) this.childWindowMap.put(child.getName(), child); if (old != null) { log.error("Ambiguous components configuration because component sibblings found with same name: '{}'. " + "The first one is replaced. This should not be possible. You can report the HST2 team so they can fix this.", child.getName() ); } if (this.childWindowMapByReferenceName == null) { this.childWindowMapByReferenceName = new LinkedMap(); } this.childWindowMapByReferenceName.put(child.getReferenceName(), child); }
nameMap.put(nodeName, entry); entries.put(id, entry);
/** * Insert a replica into an evictable map. * * If an element already exists with this eviction time, we add a nanosecond * to it until we find an unused key. * * @param evictionTimeNs The eviction time in absolute nanoseconds. * @param replica The replica to insert. * @param map The map to insert it into. */ private void insertEvictable(Long evictionTimeNs, ShortCircuitReplica replica, LinkedMap map) { while (map.containsKey(evictionTimeNs)) { evictionTimeNs++; } Preconditions.checkState(null == replica.getEvictableTimeNs()); replica.setEvictableTimeNs(evictionTimeNs); map.put(evictionTimeNs, replica); }
private void put(Object key, Entry<? extends ItemInfo> entry) { entries.remove(key); if (entries.size() >= cacheSize) { entries.remove(entries.firstKey()); // xxx AbstractLinkedMap#firstKey() Javadoc is wrong. See COLLECTIONS-353 } entries.put(key, entry); }
private void put(Object key, Entry<? extends ItemInfo> entry) { entries.remove(key); if (entries.size() >= cacheSize) { entries.remove(entries.firstKey()); // xxx AbstractLinkedMap#firstKey() Javadoc is wrong. See COLLECTIONS-353 } entries.put(key, entry); }
/** * Parse the parameter declarations. */ private LinkedMap bindParameterTypes() { ctx.lock(); try { if (_params != null) return _params; String params = ctx.getParameterDeclaration(); if (params == null) return EMPTY_PARAMS; List decs = Filters.parseDeclaration(params, ',', "parameters"); if (_params == null) _params = new LinkedMap((int) (decs.size() / 2 * 1.33 + 1)); String name; Class cls; for (int i = 0; i < decs.size(); i += 2) { name = (String) decs.get(i); cls = ctx.classForName(name, null); if (cls == null) throw new UserException(_loc.get("bad-param-type", name)); _params.put(decs.get(i + 1), cls); } return _params; } finally { ctx.unlock(); } }
public synchronized void setChatTyper(final String playerName) { if (AppPreferences.getTypingNotificationDuration() == 0) { turnOffUpdates(); chatTypingNotificationTimers.clear(); } else { MapTool.getFrame().getChatTimer().start(); MapTool.getFrame().getChatTypingPanel().setVisible(true); chatTypingNotificationTimers.put(playerName, System.currentTimeMillis()); setChanged(); notifyObservers(); } }
parameterTypes = new LinkedMap(6); if (!parameterTypes.containsKey(id)) parameterTypes.put(id, TYPE_OBJECT);
heExisting.merge(he); } else { eventMap.put(he.id, he);
heExisting.merge(he); } else { eventMap.put(he.id, he);
protected void setImplicitTypes(Value val1, Value val2, Class expected) { super.setImplicitTypes(val1, val2, expected); // as well as setting the types for conversions, we also need to // ensure that any parameters are declared with the correct type, // since the JPA spec expects that these will be validated Parameter param = val1 instanceof Parameter ? (Parameter) val1 : val2 instanceof Parameter ? (Parameter) val2 : null; Path path = val1 instanceof Path ? (Path) val1 : val2 instanceof Path ? (Path) val2 : null; // we only check for parameter-to-path comparisons if (param == null || path == null || parameterTypes == null) return; FieldMetaData fmd = path.last(); if (fmd == null) return; Class type = path.isXPath() ? path.getType() : fmd.getType(); if (type == null) return; String paramName = param.getParameterName(); if (paramName == null) return; // make sure we have already declared the parameter if (parameterTypes.containsKey(paramName)) parameterTypes.put(paramName, type); }
public void setSavepoint(String name) { beginOperation(true); try { assertActiveTransaction(); if (_savepoints != null && _savepoints.containsKey(name)) throw new UserException(_loc.get("savepoint-exists", name)); if (hasFlushed() && !_spm.supportsIncrementalFlush()) throw new UnsupportedException(_loc.get ("savepoint-flush-not-supported")); OpenJPASavepoint save = _spm.newSavepoint(name, this); if (_savepoints == null || _savepoints.isEmpty()) { save.save(getTransactionalStates()); _savepoints = new LinkedMap(); } else { if (_savepointCache == null) save.save(Collections.EMPTY_LIST); else { save.save(_savepointCache); _savepointCache.clear(); } } _savepoints.put(name, save); } catch (OpenJPAException ke) { throw ke; } catch (Exception e) { throw new GeneralException(e); } finally { endOperation(); } }
public void setSavepoint(String name) { beginOperation(true); try { assertActiveTransaction(); if (_savepoints != null && _savepoints.containsKey(name)) throw new UserException(_loc.get("savepoint-exists", name)); if (hasFlushed() && !_spm.supportsIncrementalFlush()) throw new UnsupportedException(_loc.get ("savepoint-flush-not-supported")); OpenJPASavepoint save = _spm.newSavepoint(name, this); if (_savepoints == null || _savepoints.isEmpty()) { save.save(getTransactionalStates()); _savepoints = new LinkedMap(); } else { if (_savepointCache == null) save.save(Collections.EMPTY_SET); else { save.save(_savepointCache); _savepointCache.clear(); } } _savepoints.put(name, save); } catch (OpenJPAException ke) { throw ke; } catch (Exception e) { throw new GeneralException(e); } finally { endOperation(); } }
public void setSavepoint(String name) { beginOperation(true); try { assertActiveTransaction(); if (_savepoints != null && _savepoints.containsKey(name)) throw new UserException(_loc.get("savepoint-exists", name)); if (hasFlushed() && !_spm.supportsIncrementalFlush()) throw new UnsupportedException(_loc.get ("savepoint-flush-not-supported")); OpenJPASavepoint save = _spm.newSavepoint(name, this); if (_savepoints == null || _savepoints.isEmpty()) { save.save(getTransactionalStates()); _savepoints = new LinkedMap(); } else { if (_savepointCache == null) save.save(Collections.EMPTY_SET); else { save.save(_savepointCache); _savepointCache.clear(); } } _savepoints.put(name, save); } catch (OpenJPAException ke) { throw ke; } catch (Exception e) { throw new GeneralException(e); } finally { endOperation(); } }
public void setSavepoint(String name) { beginOperation(true); try { assertActiveTransaction(); if (_savepoints != null && _savepoints.containsKey(name)) throw new UserException(_loc.get("savepoint-exists", name)); if (hasFlushed() && !_spm.supportsIncrementalFlush()) throw new UnsupportedException(_loc.get ("savepoint-flush-not-supported")); OpenJPASavepoint save = _spm.newSavepoint(name, this); if (_savepoints == null || _savepoints.isEmpty()) { save.save(getTransactionalStates()); _savepoints = new LinkedMap(); } else { if (_savepointCache == null) save.save(Collections.EMPTY_SET); else { save.save(_savepointCache); _savepointCache.clear(); } } _savepoints.put(name, save); } catch (OpenJPAException ke) { throw ke; } catch (Exception e) { throw new GeneralException(e); } finally { endOperation(); } }
public void setSavepoint(String name) { beginOperation(true); try { assertActiveTransaction(); if (_savepoints != null && _savepoints.containsKey(name)) throw new UserException(_loc.get("savepoint-exists", name)); if (hasFlushed() && !_spm.supportsIncrementalFlush()) throw new UnsupportedException(_loc.get ("savepoint-flush-not-supported")); OpenJPASavepoint save = _spm.newSavepoint(name, this); if (_savepoints == null || _savepoints.isEmpty()) { save.save(getTransactionalStates()); _savepoints = new LinkedMap(); } else { if (_savepointCache == null) save.save(Collections.EMPTY_SET); else { save.save(_savepointCache); _savepointCache.clear(); } } _savepoints.put(name, save); } catch (OpenJPAException ke) { throw ke; } catch (Exception e) { throw new GeneralException(e); } finally { endOperation(); } }