Java Code Examples for java.util.Map.get()

The following are Jave code examples for showing how to use get() of the java.util.Map 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: myfaces-trinidad   File: UIXComponentELTag.java   View Source Code Vote up 7 votes
/**
 * Checks if the current tag is a stamping tag. If so, a counter is incremented so that it can
 * be tracked when we are outside all stamping tags again.
 *
 * @see #_checkEndingStampingTag()
 * @see #isStampingTag()
 * @param facesContextAttributes
 */
private void _checkStartingStampingTag(
  Map<Object, Object> facesContextAttributes)
{
  if (isStampingTag())
  {
    AtomicInteger count = (AtomicInteger)facesContextAttributes.get(_STAMPING_COUNT_KEY);
    if (count == null)
    {
      // Use an atomic integer here so that we can increment and decrement the value without
      // having to store a new integer value into the map each time. This avoids the overhead
      // of the map.put operation.
      facesContextAttributes.put(_STAMPING_COUNT_KEY, new AtomicInteger(1));
    }
    else
    {
      // Only used on one thread, so use the safe methods for performance (only using the
      // atomic integer for higher performance than boxing int to Integer)
      count.set(count.get() + 1);
    }
  }
}
 
Example 2
Project: galop   File: TargetConfigurationFactoryImpl.java   View Source Code Vote up 7 votes
private InetAddress parseAddress(final Map<String, String> properties) throws InvalidConfigurationException {

        final String addressAsString = properties.get(TARGET_ADDRESS);

        if (addressAsString == null) {
            throw InvalidConfigurationException.missingProperty(TARGET_ADDRESS);
        }

        final InetAddress address;

        try {
            address = inetAddressFactory.createByName(addressAsString);
        } catch (final Exception ex) {
            throw new InvalidConfigurationException("Property " + TARGET_ADDRESS
                    + " is not a valid IP address or hostname: " + ex.getMessage());
        }

        return address;

    }
 
Example 3
Project: n4js   File: N4JSDReader.java   View Source Code Vote up 7 votes
/**
 * Adds test info to an identified element.
 */
private void addTestInfoForCodeElement(RepoRelativePath rrp, Doclet testMethodDoclet, FullMemberReference ref,
		TMember testMember, Map<String, SpecInfo> typesByName) {
	SpecInfo specInfo = typesByName.get(ref.fullTypeName());
	if (specInfo != null) {
		for (Type testee : specInfo.specElementRef.getTypes()) {
			if (testee instanceof ContainerType<?> && ref.memberNameSet()) {
				TMember testeeMember = getRefMember((ContainerType<?>) testee, ref);
				if (testeeMember != null) {
					specInfo.addMemberTestInfo(
							testeeMember,
							createTestSpecInfo(testeeMember.getName(), testMethodDoclet, testMember, rrp));
				}
				return;
			}
		}
		// Type, TFunction of TVariable
		specInfo.addTypeTestInfo(createTestSpecInfo(specInfo.specElementRef.identifiableElement.getName(),
				testMethodDoclet, testMember, rrp));
	} else {
		issueAcceptor.addWarning("Testee " + ref.fullTypeName() + " not found", testMember);
	}
}
 
Example 4
Project: chart-parser   File: WagerPayoffPools.java   View Source Code Vote up 7 votes
static ExoticPayoffPool parse(Map<String, List<ChartCharacter>> payoffGrid)
        throws ChartParserException {
    List<ChartCharacter> chartCharacters = payoffGrid.get("WagerType");
    String wagerType = Chart.convertToText(chartCharacters);
    WagerNameUnit wagerNameUnit = parseWagerType(wagerType);

    String winningNumbersPayoffText = Chart.convertToText(
            payoffGrid.get("WinningNumbersPayoff"));
    WinningNumbersPayoff winningNumbersPayoff =
            parseWinningNumbersAndPayoff(winningNumbersPayoffText);

    String poolText = Chart.convertToText(payoffGrid.get("Pool"));
    Double pool = parsePool(poolText);

    String carryoverText = Chart.convertToText(payoffGrid.get("Carryover"));
    Double carryover = parseCarryover(carryoverText);

    return new ExoticPayoffPool(wagerNameUnit, winningNumbersPayoff, pool, carryover);
}
 
Example 5
Project: azeroth   File: RedisBatchCommand.java   View Source Code Vote up 7 votes
/**
 * 指定组批量写入字符串
 * @param groupName 缓存组
 * @param keyValueMap
 * @return
 */
public static boolean setStringsWithGroup(String groupName, Map<String, Object> keyValueMap) {
    if (keyValueMap == null || keyValueMap.isEmpty()) { return false; }
    String[] keysValues = new String[keyValueMap.size() * 2];
    int index = 0;
    for (String key : keyValueMap.keySet()) {
        if (keyValueMap.get(key) == null) { continue; }
        keysValues[index++] = key;
        keysValues[index++] = keyValueMap.get(key).toString();
    }
    try {
        if (JedisProviderFactory.isCluster(groupName)) {
            return JedisProviderFactory.getMultiKeyJedisClusterCommands(groupName)
                    .mset(keysValues).equals(RESP_OK);
        } else {
            return JedisProviderFactory.getMultiKeyCommands(groupName).mset(keysValues)
                    .equals(RESP_OK);
        }
    } finally {
        JedisProviderFactory.getJedisProvider(groupName).release();
    }
}
 
Example 6
Project: nh-micro   File: MicroServiceTemplateSupport.java   View Source Code Vote up 7 votes
/**
 * ���id��ȡ��ݼ�¼
 * @param requestParamMap �ύ����
 * @param tableName ����� 
 * @return
 * @throws Exception
 */	
public Map getInfoByIdService(Map requestParamMap,String tableName){
	String tempKeyId=calcuIdKey();
	String id=(String) requestParamMap.get(tempKeyId);
	//add 20170831 ninghao
	Map filterViewRet=filterView4Select(tableName,requestParamMap,id,tempKeyId,TYPE_SELECT_ID);
	if(filterViewRet!=null ){
		return filterViewRet;
	}
	
	Map retMap=getInnerDao().queryObjJoinByBizId(tableName, id, tempKeyId);
	if(retMap==null){
		return null;
	}
	CheckModelTypeUtil.addMetaCols(retMap);
	CheckModelTypeUtil.changeNoStrCols(retMap);
	return retMap;
}
 
Example 7
Project: SER316-Ingolstadt   File: AgendaGenerator.java   View Source Code Vote up 6 votes
private static PriorityQueue sortStickers(){
    Map stickers = EventsManager.getStickers();
    PriorityQueue pQ = new PriorityQueue(stickers.size());
	for (Iterator i = stickers.keySet().iterator(); i.hasNext();) {
    	String id = (String)i.next();
    	Element el = (Element)stickers.get(id);
    	int j=2;
    	j=Integer.parseInt(el.getAttributeValue("priority"));
    	pQ.insertar(new Pair(el,j));
	}
	return pQ;
}
 
Example 8
Project: jmeter-bzm-plugins   File: JSONConverter.java   View Source Code Vote up 6 votes
private static JSONObject generateTimestamp(Map<String, Object> mainMetrics, int sampleCount) {
    JSONObject result = new JSONObject();

    result.put("sum", mainMetrics.get("sumTime"));
    result.put("n", sampleCount);

    long average = (long) mainMetrics.get("sumTime") / sampleCount;
    Map<String, Long> perc = getQuantiles((Long[]) mainMetrics.get("rtimes"), average);
    result.put("avg", average);
    result.put("std", perc.get("std"));
    result.put("min", perc.get("min"));
    result.put("max", perc.get("max"));

    return result;
}
 
Example 9
Project: github-test   File: Owners.java   View Source Code Vote up 6 votes
public void add(Map<String, Object> context) {
    String service = (String) context.get("service");
    if (service == null || service.length() == 0) {
        List<String> serviceList = Tool.sortSimpleName(new ArrayList<String>(providerService.findServices()));
        context.put("serviceList", serviceList);
    }
}
 
Example 10
Project: hadoop   File: AuthenticationFilterInitializer.java   View Source Code Vote up 6 votes
public static Map<String, String> getFilterConfigMap(Configuration conf,
    String prefix) {
  Map<String, String> filterConfig = new HashMap<String, String>();

  //setting the cookie path to root '/' so it is used for all resources.
  filterConfig.put(AuthenticationFilter.COOKIE_PATH, "/");

  for (Map.Entry<String, String> entry : conf) {
    String name = entry.getKey();
    if (name.startsWith(prefix)) {
      String value = conf.get(name);
      name = name.substring(prefix.length());
      filterConfig.put(name, value);
    }
  }

  //Resolve _HOST into bind address
  String bindAddress = conf.get(HttpServer2.BIND_ADDRESS);
  String principal = filterConfig.get(KerberosAuthenticationHandler.PRINCIPAL);
  if (principal != null) {
    try {
      principal = SecurityUtil.getServerPrincipal(principal, bindAddress);
    }
    catch (IOException ex) {
      throw new RuntimeException("Could not resolve Kerberos principal name: " + ex.toString(), ex);
    }
    filterConfig.put(KerberosAuthenticationHandler.PRINCIPAL, principal);
  }
  return filterConfig;
}
 
Example 11
Project: neoscada   File: AbstractBaseRule.java   View Source Code Vote up 6 votes
public void setPreFilter ( final Map<String, String> properties ) throws Exception
{
    final ConfigurationDataHelper cfg = new ConfigurationDataHelper ( properties );

    if ( properties != null )
    {
        setPreFilter ( properties.get ( "for.id" ), properties.get ( "for.type" ), properties.get ( "for.action" ) );
    }

    final String script = properties.get ( "filter.script" );
    if ( script != null && !script.isEmpty () )
    {
        this.scriptFilter = new ScriptExecutor ( this.engineManager, cfg.getString ( "filter.script.engine", "JavaScript" ), script, AbstractBaseRule.class.getClassLoader () );
    }
}
 
Example 12
Project: sunbird-utils   File: KeyCloakServiceImpl.java   View Source Code Vote up 6 votes
@Override
public String getEmailVerifiedUpdatedFlag(String userId) {
  UserResource resource =
      keycloak.realm(KeyCloakConnectionProvider.SSO_REALM).users().get(userId);
  UserRepresentation user = resource.toRepresentation();
  Map<String, List<String>> map = user.getAttributes();
  List<String> list = map.get(JsonKey.EMAIL_VERIFIED_UPDATED);
  if (!list.isEmpty()) {
    return list.get(0);
  } else {
    return "";
  }
}
 
Example 13
Project: EscapeLag   File: MonitorUtils.java   View Source Code Vote up 6 votes
public static Map<String, MonitorRecord> getEventTimingsByPlugin(Plugin plg) {
	Map<String, MonitorRecord> record = new HashMap<>();
	if (plg == null) {
		return record;
	}
	for (RegisteredListener listener : HandlerList.getRegisteredListeners(plg)) {
		try {
			FieldAccessor<EventExecutor> field = Reflection.getField(RegisteredListener.class, "executor",
					EventExecutor.class);
			EventExecutor executor = field.get(listener);
			if (executor instanceof EventExecutorInjector) {
				EventExecutorInjector eventExecutorInjector = (EventExecutorInjector) executor;
				String eventName = eventExecutorInjector.getEventName();
				if (eventName != null) {
					MonitorRecord monitorRecord = getMonitorRecord(eventName, eventExecutorInjector.getTotalTime(),
							eventExecutorInjector.getTotalCount(), eventExecutorInjector.getMaxExecuteTime());
					if (record.containsKey(eventName)) {
						MonitorRecord otherMonitorRecord = record.get(eventName);
						record.put(eventName, otherMonitorRecord.merge(monitorRecord));
					} else {
						record.put(eventName, monitorRecord);
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	return record;
}
 
Example 14
Project: BiglyBT   File: Set.java   View Source Code Vote up 6 votes
private void displayOptions(PrintStream out, StringPattern sp, boolean non_defaults)
{
	sp.setIgnoreCase(true);
	Iterator I = non_defaults?COConfigurationManager.getDefinedParameters().iterator():COConfigurationManager.getAllowedParameters().iterator();
	Map backmap = new HashMap();
	for (Iterator iter = ExternalUIConst.parameterlegacy.entrySet().iterator(); iter.hasNext();) {
		Map.Entry entry = (Map.Entry) iter.next();
		backmap.put( entry.getValue(), entry.getKey() );
	}
	TreeSet srt = new TreeSet();
	while (I.hasNext()) {
		String internal_name = (String) I.next();

		String	external_name = (String) backmap.get(internal_name);

		if ( external_name == null ){

			external_name = internal_name;
		}
		if( sp.matches(external_name) )
		{
			Parameter param = Parameter.get( internal_name, external_name );

			if ( non_defaults ){

				if ( !param.isDefault()){

					srt.add( param.getString( true ));
				}
			}else{

				srt.add( param.getString( false ));
			}
		}
	}
	I = srt.iterator();
	while (I.hasNext()) {
		out.println((String) I.next());
	}
}
 
Example 15
Project: Tarski   File: FixedMap.java   View Source Code Vote up 6 votes
/**
 * Constructs a new fixed map from the given map.
 * @ensures this.keys' = keys && this.map = map.map
 */
public FixedMap(Map<K, V> map) {
	this(map.keySet());
	for(int i = 0, size = map.size(); i < size; i++) {
		values[i] = map.get(keys[i]);
	}
}
 
Example 16
Project: Elasticsearch-Tutorial-zh-CN   File: DictSegment.java   View Source Code Vote up 5 votes
/**
 * 匹配词段
 * @param charArray
 * @param begin
 * @param length
 * @param searchHit
 * @return Hit 
 */
Hit match(char[] charArray , int begin , int length , Hit searchHit){
	
	if(searchHit == null){
		//如果hit为空,新建
		searchHit= new Hit();
		//设置hit的其实文本位置
		searchHit.setBegin(begin);
	}else{
		//否则要将HIT状态重置
		searchHit.setUnmatch();
	}
	//设置hit的当前处理位置
	searchHit.setEnd(begin);

       Character keyChar = Character.valueOf(charArray[begin]);
	DictSegment ds = null;
	
	//引用实例变量为本地变量,避免查询时遇到更新的同步问题
	DictSegment[] segmentArray = this.childrenArray;
	Map<Character , DictSegment> segmentMap = this.childrenMap;		
	
	//STEP1 在节点中查找keyChar对应的DictSegment
	if(segmentArray != null){
		//在数组中查找
		DictSegment keySegment = new DictSegment(keyChar);
		int position = Arrays.binarySearch(segmentArray, 0 , this.storeSize , keySegment);
		if(position >= 0){
			ds = segmentArray[position];
		}

	}else if(segmentMap != null){
		//在map中查找
		ds = (DictSegment)segmentMap.get(keyChar);
	}
	
	//STEP2 找到DictSegment,判断词的匹配状态,是否继续递归,还是返回结果
	if(ds != null){			
		if(length > 1){
			//词未匹配完,继续往下搜索
			return ds.match(charArray, begin + 1 , length - 1 , searchHit);
		}else if (length == 1){
			
			//搜索最后一个char
			if(ds.nodeState == 1){
				//添加HIT状态为完全匹配
				searchHit.setMatch();
			}
			if(ds.hasNextNode()){
				//添加HIT状态为前缀匹配
				searchHit.setPrefix();
				//记录当前位置的DictSegment
				searchHit.setMatchedDictSegment(ds);
			}
			return searchHit;
		}
		
	}
	//STEP3 没有找到DictSegment, 将HIT设置为不匹配
	return searchHit;		
}
 
Example 17
Project: alfresco-repository   File: CopyServiceImpl.java   View Source Code Vote up 5 votes
/**
 * Constructs the properties to copy that apply to the type and default aspects 
 */
private Map<QName, Serializable> buildCopyProperties(
        CopyDetails copyDetails,
        Set<QName> classQNames,
        Map<QName, CopyBehaviourCallback> callbacks)
{
    Map<QName, Serializable> sourceNodeProperties = copyDetails.getSourceNodeProperties();
    Map<QName, Serializable> copyProperties = new HashMap<QName, Serializable>(sourceNodeProperties.size(), 1.0F);
    Map<QName, Serializable> scratchProperties = new HashMap<QName, Serializable>(11);
    // Each defined callback gets a chance to say which properties get copied
    // Only model-defined properties are considered
    for (QName classQName : classQNames)
    {
        CopyBehaviourCallback callback = callbacks.get(classQName);
        if (callback == null)
        {
            throw new IllegalStateException("Source node class has no callback: " + classQName);
        }
        // Ignore if not present or if not scheduled for a copy
        if (!callback.getMustCopy(classQName, copyDetails))
        {
            continue;
        }
        // Get the dictionary definition
        ClassDefinition classDef = dictionaryService.getClass(classQName);
        if (classDef == null)
        {
            continue;
        }
        // Get the defined properties
        Map<QName, PropertyDefinition> propertyDefs = classDef.getProperties();
        // Extract these from the source nodes properties and store in a safe (modifiable) map
        scratchProperties.clear();
        for (QName propertyQName : propertyDefs.keySet())
        {
            if (sourceNodeProperties.containsKey(propertyQName))
            {
                Serializable value = sourceNodeProperties.get(propertyQName);
                scratchProperties.put(propertyQName, value);
            }
        }
        // What does the behaviour do with properties?
        Map<QName, Serializable> propsToCopy = callback.getCopyProperties(classQName, copyDetails, scratchProperties);
        
        // Add to the final properties
        copyProperties.putAll(propsToCopy);
    }
    // Done
    return copyProperties;
}
 
Example 18
Project: QDrill   File: ConvertHiveParquetScanToDrillParquetScan.java   View Source Code Vote up 5 votes
/**
 * Helper method which creates a DrillScalRel with native HiveScan.
 */
private DrillScanRel createNativeScanRel(final Map<String, String> partitionColMapping,
    final DrillScanRel hiveScanRel) throws Exception{

  final RelDataTypeFactory typeFactory = hiveScanRel.getCluster().getTypeFactory();
  final RelDataType varCharType = typeFactory.createSqlType(SqlTypeName.VARCHAR);

  final List<String> nativeScanColNames = Lists.newArrayList();
  final List<RelDataType> nativeScanColTypes = Lists.newArrayList();
  for (RelDataTypeField field : hiveScanRel.getRowType().getFieldList()) {
    final String dirColName = partitionColMapping.get(field.getName());
    if (dirColName != null) { // partition column
      nativeScanColNames.add(dirColName);
      nativeScanColTypes.add(varCharType);
    } else {
      nativeScanColNames.add(field.getName());
      nativeScanColTypes.add(field.getType());
    }
  }

  final RelDataType nativeScanRowType = typeFactory.createStructType(nativeScanColTypes, nativeScanColNames);

  // Create the list of projected columns set in HiveScan. The order of this list may not be same as the order of
  // columns in HiveScan row type. Note: If the HiveScan.getColumn() contains a '*', we just need to add it as it is,
  // unlike above where we expanded the '*'. HiveScan and related (subscan) can handle '*'.
  final List<SchemaPath> nativeScanCols = Lists.newArrayList();
  for(SchemaPath colName : hiveScanRel.getColumns()) {
    final String partitionCol = partitionColMapping.get(colName.getAsUnescapedPath());
    if (partitionCol != null) {
      nativeScanCols.add(SchemaPath.getSimplePath(partitionCol));
    } else {
      nativeScanCols.add(colName);
    }
  }

  final HiveScan hiveScan = (HiveScan) hiveScanRel.getGroupScan();
  final HiveDrillNativeParquetScan nativeHiveScan =
      new HiveDrillNativeParquetScan(
          hiveScan.getUserName(),
          hiveScan.hiveReadEntry,
          hiveScan.storagePlugin,
          nativeScanCols);

  return new DrillScanRel(
      hiveScanRel.getCluster(),
      hiveScanRel.getTraitSet(),
      hiveScanRel.getTable(),
      nativeHiveScan,
      nativeScanRowType,
      nativeScanCols);
}
 
Example 19
Project: alfresco-repository   File: InviteNominatedSender.java   View Source Code Vote up 5 votes
private NodeRef getWorkflowPackage(Map<String, String> properties)
{
    String packageRef = properties.get(WF_PACKAGE);
    return new NodeRef(packageRef);
}
 
Example 20
Project: hazelcast-docker-swarm-discovery-spi   File: SwarmDiscoveryUtil.java   View Source Code Vote up 5 votes
/**
 * Discover containers on the relevant networks that match the given
 * service criteria. 
 * 
 * @param docker
 * @param relevantNetIds2Networks
 * @param criteria
 * @return set of DiscoveredContainer instances
 * @throws Exception
 */
private Set<DiscoveredContainer> discoverContainersViaCriteria(DockerClient docker, 
		Map<String,Network> relevantNetIds2Networks, 
		Service.Criteria criteria) throws Exception {

	Set<DiscoveredContainer> discoveredContainers = new HashSet<DiscoveredContainer>();

	// find all relevant services given the criteria....
	List<Service> services = docker.listServices(criteria);
	
	for (Service service : services) {

		// crawl through all VIPs the service is on
		for (EndpointVirtualIp vip : service.endpoint().virtualIps()) {

			// does the service have a VIP on one of the networks we care about?
			if (relevantNetIds2Networks.containsKey(vip.networkId())) {
				
				// get the network object that the vip is on
				Network network = relevantNetIds2Networks.get(vip.networkId());
				
				logger.info("Found qualifying docker service["+service.spec().name()+"] "
						+ "on network: " + network.name() +"["+ network.id() + ":" +vip.addr() +"]");

				// if so, then lets find all its tasks (actual container instances of the service)
				List<Task> tasks = docker.listTasks(Task.Criteria.builder().serviceName(service.spec().name()).build());

				// for every task, lets get its network attachments
				for (Task task : tasks) {
					for (NetworkAttachment networkAttachment : task.networkAttachments()) {

						// if the network ID the task is = the current network we care about for 
						// the service.. then lets treat it as a "discovered container"
						// that we actually care about
						if (networkAttachment.network().id().equals(vip.networkId())) {
															
							// if container is in status 'running', then add it!									
							if (TaskStatus.TASK_STATE_RUNNING.equals(task.status().state())) {
							
								logger.info("Found qualifying docker service task[taskId: " +task.id() + ", container: "+task.status().containerStatus().containerId()+ ", state: " + task.status().state()+ "] "
										+ "on network: " + network.name() +"["+ network.id() + ":" + networkAttachment.addresses().iterator().next() +"]");																
							
								discoveredContainers.add(new DiscoveredContainer(network, service, task, networkAttachment));
							}
						}
					}
				}
			}
		}
	}

	return discoveredContainers;
}