Java Code Examples for java.util.Map.Entry.getValue()

The following are Jave code examples for showing how to use getValue() of the java.util.Map.Entry class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: n4js   File: OsgiBinariesPreferenceStore.java   View Source Code Vote up 6 votes
@Override
public IStatus save() {
	try {
		final IEclipsePreferences node = InstanceScope.INSTANCE.getNode(QUALIFIER);
		for (final Entry<Binary, URI> entry : getOrCreateState().entrySet()) {
			final URI path = entry.getValue();
			if (null != path) {
				final File file = new File(path);
				if (file.isDirectory()) {
					node.put(entry.getKey().getId(), file.getAbsolutePath());
				}
			} else {
				// Set to default.
				node.put(entry.getKey().getId(), "");
			}
		}
		node.flush();
		return OK_STATUS;
	} catch (final BackingStoreException e) {
		final String message = "Unexpected error when trying to persist binary preferences.";
		LOGGER.error(message, e);
		return statusHelper.createError(message, e);
	}
}
 
Example 2
Project: MaxSim   File: GuardLoweringPhase.java   View Source Code Vote up 6 votes
@Override
protected void processNode(Node node) {
    if (node instanceof GuardNode) {
        processGuard(node);
    } else if (node instanceof Access) {
        processAccess((Access) node);
    }
    if (node instanceof StateSplit && ((StateSplit) node).stateAfter() != null) {
        nullGuarded.clear();
    } else {
        Iterator<Entry<ValueNode, GuardNode>> it = nullGuarded.entrySet().iterator();
        while (it.hasNext()) {
            Entry<ValueNode, GuardNode> entry = it.next();
            GuardNode guard = entry.getValue();
            if (guard.usages().contains(node)) {
                it.remove();
            }
        }
    }
}
 
Example 3
Project: Pluto-Android   File: ApiClient.java   View Source Code Vote up 6 votes
private static void showPostParams(int requestId, Map<String, Object> params) {
	String message = "Post." + requestId + ".Params:";
	StringBuilder stringBuilder = new StringBuilder();
	stringBuilder.append(message);
	String separator = "&";
	Iterator<Entry<String, Object>> it = params.entrySet().iterator();
	while (it.hasNext()) {
		Entry<String, Object> entry = it.next();
		String key = entry.getKey();
		Object value = entry.getValue();

		stringBuilder.append(separator);
		stringBuilder.append(String.format(Locale.getDefault(), "%s=%s", key, value));
	}
	//将第一个分隔符删除
	int separatorIndex;
	if ((separatorIndex = stringBuilder.indexOf(separator)) != -1) {
		stringBuilder.deleteCharAt(separatorIndex);
	}
	LogUtils.info(stringBuilder.toString());
}
 
Example 4
Project: s-store   File: CatalogMap.java   View Source Code Vote up 6 votes
/**
 * Remove a {@link CatalogType} object from this collection.
 * @param name The name of the object to remove.
 */
public boolean delete(String name) {
    try {
        if (m_items.containsKey(name) == false)
            throw new CatalogException("Catalog item '" + name + "' doesn't exists in " + m_parent);

        m_items.remove(name);

        // update versioning if needed
        updateVersioning();

        // assign a relative index to every child item
        int index = 1;
        for (Entry<String, T> e : m_items.entrySet()) {
            e.getValue().m_relativeIndex = index++;
        }
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
    
    m_fastArray = null;
    return (true);
}
 
Example 5
Project: datarouter   File: DatarouterHttpRequest.java   View Source Code Vote up 6 votes
private String getQueryString(){
	StringBuilder query = new StringBuilder();
	for(Entry<String,List<String>> param : queryParams.entrySet()){
		String key = param.getKey();
		if(key == null || key.trim().isEmpty()){
			continue;
		}
		String urlEncodedKey = urlEncode(key.trim());
		for(String value : param.getValue()){
			query.append('&').append(urlEncodedKey);
			if(value != null && !value.isEmpty()){
				query.append('=').append(urlEncode(value));
			}
		}
	}
	return "?" + query.substring(1);
}
 
Example 6
Project: acmeair   File: JtlTotals.java   View Source Code Vote up 6 votes
public String cntByTimeString() {
    DecimalFormat df = new DecimalFormat(DECIMAL_PATTERN);
    List<String> millisStr = new LinkedList<String>();
    
    Iterator <Entry<Integer,Integer>>iter = millisMap.entrySet().iterator();
    while(iter.hasNext()) {
        Entry<Integer,Integer> millisEntry = iter.next();
        Integer bucket = (Integer)millisEntry.getKey();
        Integer bucketCount = (Integer)millisEntry.getValue();
        
        int minMillis = bucket.intValue() * millisPerBucket;
        int maxMillis = (bucket.intValue() + 1) * millisPerBucket;
        
        millisStr.add(
          df.format(minMillis/MILLIS_PER_SECOND)+" s "+
          "- "+
          df.format(maxMillis/MILLIS_PER_SECOND)+" s "+
          "= " + bucketCount);
    }
    return millisStr.toString();
}
 
Example 7
Project: aws-sdk-java-v2   File: DynamoDbMapper.java   View Source Code Vote up 5 votes
public List<StringListMap<T>> subMaps(final int size, boolean perMap) {
    final LinkedList<StringListMap<T>> maps = new LinkedList<StringListMap<T>>();
    int index = 0;
    int count = 0;
    for (final Entry<String, List<T>> entry : entrySet()) {
        for (final T value : entry.getValue()) {
            if (index == maps.size()) {
                maps.add(new StringListMap<T>());
            }
            maps.get(index).add(entry.getKey(), value);
            index = perMap ? (++count / size) : (++index % size);
        }
    }
    return maps;
}
 
Example 8
Project: googles-monorepo-demo   File: ServiceManager.java   View Source Code Vote up 5 votes
ImmutableMultimap<State, Service> servicesByState() {
  ImmutableSetMultimap.Builder<State, Service> builder = ImmutableSetMultimap.builder();
  monitor.enter();
  try {
    for (Entry<State, Service> entry : servicesByState.entries()) {
      if (!(entry.getValue() instanceof NoOpService)) {
        builder.put(entry);
      }
    }
  } finally {
    monitor.leave();
  }
  return builder.build();
}
 
Example 9
Project: Equella   File: SettingsSection.java   View Source Code Vote up 5 votes
public Map<AbstractParentSettingsSection<?>, Set<String>> getSettingsMap()
{
	Map<AbstractParentSettingsSection<?>, Set<String>> settingsMap = Maps.newHashMap();

	for( Entry<String, Extension> extEntry : settingsExtensions.getExtensionMap().entrySet() )
	{
		Extension settingExt = extEntry.getValue();
		Collection<Parameter> groupParams = settingExt.getParameters("grouping");
		AbstractParentSettingsSection<?> bean = settingsExtensions.getBeanByExtension(settingExt);
		if( !Check.isEmpty(groupParams) )
		{
			for( Parameter groupParam : groupParams )
			{
				Set<String> groups = settingsMap.get(bean);
				if( groups == null )
				{
					groups = Sets.newHashSet();
					settingsMap.put(bean, groups);
				}
				groups.add(groupParam.valueAsString());
			}
		}
		else
		{
			settingsMap.put(bean, new HashSet<String>());
		}
	}

	return settingsMap;
}
 
Example 10
Project: diorite-configs-java8   File: CommentsWriter.java   View Source Code Vote up 5 votes
@SuppressWarnings("unchecked")
private void write(Map<String, MutablePair<String, ?>> map) throws IOException
{
    this.updateIndent(true);
    int keys = map.entrySet().size();
    int k = 0;
    for (Entry<String, MutablePair<String, ?>> entry : map.entrySet())
    {
        k += 1;
        MutablePair<String, ?> pair = entry.getValue();
        String comment = pair.getLeft();
        Map<String, MutablePair<String, ?>> rightMap = (Map<String, MutablePair<String, ?>>) pair.getRight();

        int rightKeys = (rightMap == null) ? 0 : rightMap.size();
        boolean newLine = keys > 3;
        if (comment != null)
        {
            this.writeComment(comment);
        }

        String key = entry.getKey();
        this.writeKey(key);
        if (rightMap != null)
        {
            this.write(rightMap);
        }
        if (newLine)
        {
            this.writeNewLine(false);
        }
    }
    this.writeNewLine(false);
    this.updateIndent(false);
}
 
Example 11
Project: s-store   File: PartitionPlan.java   View Source Code Vote up 5 votes
public Collection<Table> getChangedTableEntries(PartitionPlan other) {
    Set<Table> changed = new HashSet<Table>();
    for (Entry<Table, TableEntry> e : this.table_entries.entrySet()) {
        if (!other.table_entries.containsKey(e.getKey())) {
            changed.add(e.getKey());
        } else {
            TableEntry pe0 = e.getValue();
            TableEntry pe1 = other.table_entries.get(e.getKey());
            if (!pe0.equals(pe1))
                changed.add(e.getKey());
        }
    } // FOR
    return (changed);
}
 
Example 12
Project: aws-sdk-java-v2   File: FilterConditionTest.java   View Source Code Vote up 5 votes
@Test
public void testScanFilter_EXISTS() {
    ScanFilter ScanFilter = new ScanFilter("foo").exists();
    Entry<String, Condition> ddbscanFilter = toAttributeCondition(ScanFilter);
    String ddbscanFilter_attrName = ddbscanFilter.getKey();
    Condition ddbscanFilter_value = ddbscanFilter.getValue();

    Assert.assertEquals("foo", ddbscanFilter_attrName);
    Assert.assertEquals(ComparisonOperator.NOT_NULL, ddbscanFilter_value.comparisonOperator());
    Assert.assertEquals(null, ddbscanFilter_value.attributeValueList());
}
 
Example 13
Project: reading-and-annotate-rocketmq-3.4.6   File: RouteInfoManager.java   View Source Code Vote up 5 votes
public byte[] getHasUnitSubUnUnitTopicList() {
    TopicList topicList = new TopicList();
    try {
        try {
            this.lock.readLock().lockInterruptibly();
            Iterator<Entry<String, List<QueueData>>> topicTableIt =
                    this.topicQueueTable.entrySet().iterator();
            while (topicTableIt.hasNext()) {
                Entry<String, List<QueueData>> topicEntry = topicTableIt.next();
                String topic = topicEntry.getKey();
                List<QueueData> queueDatas = topicEntry.getValue();
                if (queueDatas != null && queueDatas.size() > 0
                        && !TopicSysFlag.hasUnitFlag(queueDatas.get(0).getTopicSynFlag())
                        && TopicSysFlag.hasUnitSubFlag(queueDatas.get(0).getTopicSynFlag())) {
                    topicList.getTopicList().add(topic);
                }
            }
        }
        finally {
            this.lock.readLock().unlock();
        }
    }
    catch (Exception e) {
        log.error("getAllTopicList Exception", e);
    }

    return topicList.encode();
}
 
Example 14
Project: beaker-notebook-archive   File: BasicObjectSerializer.java   View Source Code Vote up 5 votes
protected boolean isPrimitiveTypeMap(Object o) {
  if (!(o instanceof Map<?, ?>))
    return false;
  Map<?, ?> m = (Map<?, ?>) o;

  Set<?> eset = m.entrySet();
  for (Object entry : eset) {
    Entry<?, ?> e = (Entry<?, ?>) entry;
    if (e.getValue() != null && !isPrimitiveType(e.getValue().getClass().getName()))
      return false;
  }
  return true;
}
 
Example 15
Project: OpenJSharp   File: VetoableChangeSupport.java   View Source Code Vote up 5 votes
/**
 * @serialData Null terminated list of <code>VetoableChangeListeners</code>.
 * <p>
 * At serialization time we skip non-serializable listeners and
 * only serialize the serializable listeners.
 */
private void writeObject(ObjectOutputStream s) throws IOException {
    Hashtable<String, VetoableChangeSupport> children = null;
    VetoableChangeListener[] listeners = null;
    synchronized (this.map) {
        for (Entry<String, VetoableChangeListener[]> entry : this.map.getEntries()) {
            String property = entry.getKey();
            if (property == null) {
                listeners = entry.getValue();
            } else {
                if (children == null) {
                    children = new Hashtable<>();
                }
                VetoableChangeSupport vcs = new VetoableChangeSupport(this.source);
                vcs.map.set(null, entry.getValue());
                children.put(property, vcs);
            }
        }
    }
    ObjectOutputStream.PutField fields = s.putFields();
    fields.put("children", children);
    fields.put("source", this.source);
    fields.put("vetoableChangeSupportSerializedDataVersion", 2);
    s.writeFields();

    if (listeners != null) {
        for (VetoableChangeListener l : listeners) {
            if (l instanceof Serializable) {
                s.writeObject(l);
            }
        }
    }
    s.writeObject(null);
}
 
Example 16
Project: EasyTransaction   File: EasyTransSynchronizer.java   View Source Code Vote up 5 votes
@Override
public void beforeCommit(boolean readOnly) {
	//flush all the logs and execute all the compensable methods before commit
	LogProcessContext logProcessContext = getLogProcessContext();
	logProcessContext.getLogCache().flush(false);
	logProcessContext.getExecuteManager().excuteCahcheMehods();
	Map<Callable<?>, Exception> errorCalls = logProcessContext.getExecuteManager().getErrorCalls();
	if(errorCalls.size() != 0){
		Entry<Callable<?>, Exception> next = errorCalls.entrySet().iterator().next();
		throw new RuntimeException("Exist compensable method call Exception,rollback now...",next.getValue());
	}
}
 
Example 17
Project: oneops   File: CmsWoProvider.java   View Source Code Vote up 5 votes
private List<CmsRfcCI> getServicedBy(CmsRfcCI rfc) {

        List<CmsRfcCI> iaases = new ArrayList<>();

        CmsCI box = getBox(rfc.getCiId());

        List<CmsCIRelation> iaasList = cmProcessor.getFromCIRelations(box.getCiId(), "manifest.ServicedBy", "manifest.Iaas");
        for (CmsCIRelation rel : iaasList) {
            CmsRfcCI iaas = rfcUtil.mergeRfcAndCi(null, rel.getToCi(), "dj");
            iaas.getAttribute("services").setNewValue(rel.getAttribute("services").getDjValue());
            List<CmsCIRelation> keypairs = cmProcessor.getFromCIRelations(iaas.getCiId(), "manifest.Requires", "manifest.Keypair");
            if (keypairs.size() > 0) {
                CmsRfcAttribute prKeyAttr = new CmsRfcAttribute();
                prKeyAttr.setAttributeName("private_key");
                prKeyAttr.setNewValue(keypairs.get(0).getToCi().getAttribute("private").getDjValue());
                iaas.addAttribute(prKeyAttr);
            }
            //this is total HACK for Netscaler needs to be generalized
            List<CmsCIRelation> netscaler = cmProcessor.getFromCIRelations(iaas.getCiId(), "manifest.Requires", "manifest.Netscaler");
            if (netscaler.size() > 0) {
                for (Entry<String, CmsCIAttribute> attrEntry : netscaler.get(0).getToCi().getAttributes().entrySet()) {
                    CmsCIAttribute nsAttr = attrEntry.getValue();
                    CmsRfcAttribute iaasNsAttr = new CmsRfcAttribute();
                    iaasNsAttr.setAttributeName(nsAttr.getAttributeName());
                    iaasNsAttr.setNewValue(nsAttr.getDjValue());
                    iaas.addAttribute(iaasNsAttr);
                }
            }
            iaases.add(iaas);
        }
        return iaases;
    }
 
Example 18
Project: TrafficPetri   File: JSONObject.java   View Source Code Vote up 5 votes
/**
 * Construct a JSONObject from a Map.
 *
 * @param m
 *            A map object that can be used to initialize the contents of
 *            the JSONObject.
 */
public JSONObject(Map<?, ?> m) {
    if (m == null) {
        this.map = new HashMap<String, Object>();
    } else {
        this.map = new HashMap<String, Object>(m.size());
    	for (final Entry<?, ?> e : m.entrySet()) {
            final Object value = e.getValue();
            if (value != null) {
                this.map.put(String.valueOf(e.getKey()), wrap(value));
            }
        }
    }
}
 
Example 19
Project: Pogamut3   File: UT2004HideAndSeek.java   View Source Code Vote up 5 votes
protected UT2004HideAndSeekResult processResults(UCCWrapper ucc, UT2004Server server, UT2004Analyzer analyzer, Bots bots, List<IToken> winners, Map<IToken, HSBotRecord<PlayerMessage>> botRecords) {
	if (log != null && log.isLoggable(Level.FINE)) {
		log.fine(config.getMatchId().getToken() + ": Processing results...");
	}
	
	config.getHsConfig().setFixedSeekerName(origFixedSeekerName);
	
	UT2004HideAndSeekResult result = new UT2004HideAndSeekResult();
	
	// BOTS
	result.setBots(MyCollections.asList(bots.botId2UnrealId.keySet()));
	
	// BOT IDS
	result.setBotIds(bots.botId2UnrealId);
	
	// BOT OBSERVERS
	for (Entry<IToken, IUT2004AnalyzerObserver> entry : bots.botObservers.entrySet()) {
		if (!(entry.getValue() instanceof UT2004AnalyzerObsStats)) {
			throw new PogamutException("There is an observer of wrong class, expecting UT2004AnalyzerObsStats, got " + entry.getValue().getClass().getSimpleName() + "!", log, this);
		}
		result.getBotObservers().put(entry.getKey(), (UT2004AnalyzerObsStats)entry.getValue());
	}
	
	// WINNERS
	result.setWinners(winners);
	
	// MATCH TIME
	result.setMatchTime(((double)bots.matchEnd - (double)bots.matchStart) / (1000));
	
	// SCORES
	result.setScoreDetails(botRecords);
			
	if (log != null && log.isLoggable(Level.WARNING)) {
		log.warning(config.getMatchId().getToken() + ": Results processed, #Winners = " + result.getWinners().size() + ", Winners score = " + result.getWinnerScore());
	}
	
	return result;
}
 
Example 20
Project: fdt   File: FDTReaderSession.java   View Source Code Vote up 4 votes
public void startReading() {

        StringBuilder sb = new StringBuilder();

        sb.append(" Started DiskReaderTasks for the following partions [ ");
        int idx = 0;

        if (logger.isLoggable(Level.FINEST)) {
            logger.log(Level.FINEST, " partitionsMap is: " + partitionsMap);
        }

        for (Entry<Integer, LinkedList<FileSession>> entry : partitionsMap.entrySet()) {
            final int partitionID = entry.getKey().intValue();

            LinkedList<FileSession> files = entry.getValue();

            int realReadersCount = (readersCount < files.size()) ? readersCount : files.size();
            ArrayList<DiskReaderTask> readersTasks = new ArrayList<DiskReaderTask>(realReadersCount);

            ArrayList<LinkedList<FileSession>> fileSessionsReaders = new ArrayList<LinkedList<FileSession>>(
                    realReadersCount);

            if (logger.isLoggable(Level.FINE)) {
                logger.log(Level.FINE, " realReadersCount = " + realReadersCount + " for partitionID: " + partitionID);
            }

            if (realReadersCount > 1) {
                FileSession[] filesArray = files.toArray(new FileSession[files.size()]);
                Arrays.sort(filesArray, new FileSessionComparator());

                if (logger.isLoggable(Level.FINER)) {
                    logger.log(Level.FINER, "Sorted FileSession-s array: " + Arrays.toString(filesArray));
                }

                int ci = 0;
                for (FileSession fs : filesArray) {
                    LinkedList<FileSession> fsessions = (ci >= fileSessionsReaders.size()) ? null
                            : fileSessionsReaders.get(ci);

                    if (fsessions == null) {
                        fsessions = new LinkedList<FileSession>();
                        fileSessionsReaders.add(fsessions);
                    }

                    fsessions.add(fs);

                    if (logger.isLoggable(Level.FINEST)) {
                        logger.log(Level.FINEST, " Added FileSession: " + fs + " for DiskReaderTask idx =  " + ci);
                    }
                    ci = (ci + 1) % realReadersCount;
                }

            } else {
                fileSessionsReaders.add(files);
            }

            execService = Utils.getStandardExecService("DiskReaderTask for " + toString(), partitionsMap.size(),
                    (partitionsMap.size() * realReadersCount) + 5, Thread.NORM_PRIORITY);

            for (int i = 0; i < realReadersCount; i++) {
                final DiskReaderTask drTask = new DiskReaderTask(partitionID, idx++, fileSessionsReaders.get(i), this);
                readersTasks.add(drTask);
                execService.submit(drTask);
            }

            if (logger.isLoggable(Level.FINER)) {
                logger.log(Level.FINER, " ReadersTasks for partitionID: " + partitionID + ": " + readersTasks);
            }

            readersMap.put(partitionID, readersTasks);
            sb.append(partitionID).append(" ");
        }

        sb.append("] for FDTSession: ").append(sessionID);

        logger.log(Level.INFO, sb.toString());

    }