List of usage examples for org.apache.commons.collections MapIterator hasNext
boolean hasNext();
From source file:com.projity.configuration.FieldDictionary.java
public static HashMap getAliasMap() { HashMap aliasMap = new HashMap(); MapIterator i = getInstance().map.mapIterator(); while (i.hasNext()) { Object key = i.next();/*from w w w . j a v a 2 s . c o m*/ Field field = (Field) i.getValue(); if (field.getAlias() != null) aliasMap.put(field.getId(), field.getAlias()); } return aliasMap; }
From source file:com.projity.field.StaticSelect.java
public String toString() { MapIterator i = stringMap.mapIterator(); StringBuffer result = new StringBuffer(); while (i.hasNext()) { i.next();// w ww.ja v a2 s . co m result.append("[key]" + i.getKey() + " [value]" + i.getValue() + "\n"); } return result.toString(); }
From source file:AIR.Common.Web.WebValueCollection.java
public String toString(boolean urlencoded, Map<String, Object> excludeKeys) { int count = this.size(); if (count == 0) { return ""; }/*from w w w. ja va 2 s . c o m*/ StringBuilder builder = new StringBuilder(); MapIterator iter = this.mapIterator(); while (iter.hasNext()) { String key = (String) iter.getKey(); if (((excludeKeys == null) || (key == null)) || (excludeKeys.get(key) == null)) { String str3; if (urlencoded) { try { byte[] utf8Bytes = key.getBytes("UTF8"); key = new String(utf8Bytes, "UTF8"); } catch (UnsupportedEncodingException e) { _logger.error(e.getMessage()); key = null; } } String str2 = !StringUtils.isEmpty(key) ? (key + "=") : ""; if (builder.length() > 0) { builder.append('&'); } Object value = iter.getValue(); if (value instanceof List) { List list = (List) value; int num3 = (list != null) ? list.size() : 0; if (num3 == 1) { builder.append(str2); str3 = list.get(0).toString(); if (urlencoded) { try { byte[] utf8Bytes = str3.getBytes("UTF8"); str3 = new String(utf8Bytes, "UTF8"); } catch (UnsupportedEncodingException e) { _logger.error(e.getMessage()); str3 = null; } } builder.append(str3); } else if (num3 == 0) { builder.append(str2); } else { for (int j = 0; j < num3; j++) { if (j > 0) { builder.append('&'); } builder.append(str2); str3 = list.get(j).toString(); if (urlencoded) { try { byte[] utf8Bytes = str3.getBytes("UTF8"); str3 = new String(utf8Bytes, "UTF8"); } catch (UnsupportedEncodingException e) { _logger.error(e.getMessage()); str3 = null; } } builder.append(str3); } } } else { builder.append(str2); str3 = value.toString(); if (urlencoded) { try { byte[] utf8Bytes = str3.getBytes("UTF8"); str3 = new String(utf8Bytes, "UTF8"); } catch (UnsupportedEncodingException e) { _logger.error(e.getMessage()); str3 = null; } } builder.append(str3); } } } return builder.toString(); }
From source file:com.quinsoft.zeidon.utils.TimedLruCache.java
@SuppressWarnings("unchecked") public void cleanup() { // Determine a time when objects haven't been accessed in a while and // need/*from www .j av a2s . c o m*/ // to be removed. long tooOld = System.currentTimeMillis() - timeToLiveInMillis; ArrayList<K> keysToDelete = null; synchronized (cacheMap) { MapIterator itr = cacheMap.mapIterator(); keysToDelete = new ArrayList<K>((cacheMap.size() / 2) + 1); while (itr.hasNext()) { K key = (K) itr.next(); CachedObject c = (CachedObject) itr.getValue(); if (c != null) { if (c.lastAccessed < tooOld) keysToDelete.add(key); else break; // All the rest of the objects are younger than // time-to-live. } } for (K k : keysToDelete) cacheMap.remove(k); } }
From source file:net.chat.utils.Cache.java
public void showAllCache() { synchronized (cacheMap) { MapIterator itr = cacheMap.mapIterator(); K key = null;/*from w w w . j av a 2s .com*/ CachedObject c = null; log.info(":"); while (itr.hasNext()) { key = (K) itr.next(); c = (CachedObject) itr.getValue(); log.info("key:" + key + ";value:" + c.getValue()); } } }
From source file:com.projity.configuration.FieldDictionary.java
/** Fill a collection with all fields that are applicable to one or more types * specified by clazz. The collection is sorted alpha-numerically by field name. * Lists by type should probably just be cached in static variables. * @param collection - collection to fill * @param clazz - array of class types/* w w w . j av a 2s .c om*/ */ public void populateListWithFieldsOfType(List list, Class[] clazz) { MapIterator i = map.mapIterator(); while (i.hasNext()) { Object key = i.next(); Field field = (Field) i.getValue(); if (field.isApplicable(clazz)) list.add(field); } Collections.sort(list); }
From source file:net.chat.utils.Cache.java
@SuppressWarnings("unchecked") public void cleanup() { long now = System.currentTimeMillis(); ArrayList<K> keysToDelete = null; synchronized (cacheMap) { MapIterator itr = cacheMap.mapIterator(); keysToDelete = new ArrayList<K>((cacheMap.size() / 2) + 1); K key = null;//w w w.j a va 2s . co m CachedObject c = null; while (itr.hasNext()) { key = (K) itr.next(); c = (CachedObject) itr.getValue(); if (c != null && (now > (timeToLiveInMillis + c.lastAccessed))) { keysToDelete.add(key); } } } for (K key : keysToDelete) { synchronized (cacheMap) { cacheMap.remove(key); } Thread.yield(); } }
From source file:metrics.sink.MetricsTable.java
private void printHeaders() { MapIterator columnMapIterator = columnMapping.mapIterator(); Row headerRow = currentSheet.createRow(0); rowCount++;/* w w w . j a va2s . c om*/ while (columnMapIterator.hasNext()) { Cell headerCell = headerRow.createCell((Integer) columnMapIterator.next()); headerCell.setCellValue((String) columnMapIterator.getValue()); } }
From source file:com.vinay.simpleadserver.cache.AdServerInMemoryCache.java
/** * * @return getAll() returns all the key/value pairs that have not expired * and are available in the cache.// w ww.jav a 2s. c om */ public Map<K, T> getAll() { MapIterator itr = adServerCacheMap.mapIterator(); Map<K, T> resultMap = new LinkedHashMap<>(); K key = null; AdServerCacheObject c = null; while (itr.hasNext()) { key = (K) itr.next(); c = (AdServerCacheObject) itr.getValue(); if (c != null && (System.currentTimeMillis() < (c.timeToLive + c.creationTime))) { resultMap.put(key, c.value); } } return resultMap; }
From source file:br.ufal.cideei.util.count.MetricsTable.java
private void printHeaders() { MapIterator columnMapIterator = columnMapping.orderedMapIterator(); Row headerRow = sheet.createRow(0);/*from w w w .j av a2 s . co m*/ rowCount++; while (columnMapIterator.hasNext()) { Cell headerCell = headerRow.createCell((Integer) columnMapIterator.next()); headerCell.setCellValue((String) columnMapIterator.getValue()); } }