当前位置: 首页>>代码示例>>Java>>正文


Java Hashtable.containsKey方法代码示例

本文整理汇总了Java中java.util.Hashtable.containsKey方法的典型用法代码示例。如果您正苦于以下问题:Java Hashtable.containsKey方法的具体用法?Java Hashtable.containsKey怎么用?Java Hashtable.containsKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Hashtable的用法示例。


在下文中一共展示了Hashtable.containsKey方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: distFeaturesOnClients

import java.util.Hashtable; //导入方法依赖的package包/类
public int[] distFeaturesOnClients() {
    Hashtable<SGHFeature, Integer> count = new Hashtable<SGHFeature, Integer>();
    for (SGHClientApp c : clients) {
        for (SGHFeature f : c.featureSet) {
            if (!count.containsKey(f)) {
                count.put(f, 1);
            }
            else {
                count.put(f, count.get(f) + 1);
            }
        }
    }
    ArrayList<Integer> counts = new ArrayList<Integer>(count.values());
    Collections.sort(counts);
    int[] result = new int[counts.size()];
    for (int i=0; i<counts.size(); i++) result[counts.size()-i-1] = counts.get(i);
    return result;
}
 
开发者ID:ffleurey,项目名称:EvoServ,代码行数:19,代码来源:SGHSystem.java

示例2: cleanUnusedStyles

import java.util.Hashtable; //导入方法依赖的package包/类
/**
 * This method simply checks the style list and eliminate any style not referenced by any caption
 * This might come useful when default styles get created and cover too much.
 * It require a unique iteration through all captions.
 * 
 */
protected void cleanUnusedStyles(){
	//here all used styles will be stored
	Hashtable<String, Style> usedStyles = new Hashtable<>();
	//we iterate over the captions
	Iterator<Caption> itrC = captions.values().iterator();
	while(itrC.hasNext()){
		//new caption
    	Caption current = itrC.next();
    	//if it has a style
    	if(current.style != null){
    		String iD = current.style.iD;
    		//if we haven't saved it yet
    		if(!usedStyles.containsKey(iD))
    			usedStyles.put(iD, current.style);
    	}
	}
	//we saved the used styles
	this.styling = usedStyles;
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:26,代码来源:TimedTextObject.java

示例3: getParamsString

import java.util.Hashtable; //导入方法依赖的package包/类
private final String getParamsString(Hashtable excludeParams, HttpServletRequest request) {
	if (request == null)
		return null;

	Enumeration params = request.getParameterNames();
	String param;
	String vals[];
	StringBuffer addParams = new StringBuffer();
	try {
		while (params.hasMoreElements()) {
			param = (String) params.nextElement();
			if (!excludeParams.containsKey(param)) {
				vals = request.getParameterValues(param);
				for (int i = 0; i < vals.length; i++) {
					addParams.append("&" + param + "=" + URLEncoder.encode(vals[i], "utf-8"));
				}
			}
		}
	} catch (Exception e) {
		addParams.toString();
	}
	return addParams.toString();
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:24,代码来源:DDSAdminQueryAction.java

示例4: cosem

import java.util.Hashtable; //导入方法依赖的package包/类
public static void cosem(Resource cosemResource, Root root, Hashtable<String, MeterAsset> allMeterAssets) {
	HashSet<PhysicalDevice> devices = new HashSet<>();
	HashSet<MeterAssetPhysicalDevicePair> devicePairs = new HashSet<>();
	TreeIterator<EObject> cosemIterator = cosemResource.getAllContents();
	while (cosemIterator.hasNext()) {
		EObject eOb = cosemIterator.next();
		if (eOb instanceof PhysicalDevice) {
			PhysicalDevice device = (PhysicalDevice) eOb;
			devices.add(device);
			String idNs = device.getID();
			if (allMeterAssets.containsKey(idNs)) {
				MeterAssetPhysicalDevicePair pair = GluemodelFactory.eINSTANCE
						.createMeterAssetPhysicalDevicePair();
				pair.setB(device);
				pair.setA(allMeterAssets.get(idNs));
				devicePairs.add(pair);
			}
		}
	}

	root.getMeterAssetToPhysicalDevice().addAll(devicePairs);
}
 
开发者ID:SvenPeldszus,项目名称:rgse.ttc17.emoflon.tgg,代码行数:23,代码来源:GlueModelCreator.java

示例5: buildTrapEntries

import java.util.Hashtable; //导入方法依赖的package包/类
public void buildTrapEntries(Hashtable<InetAddress, Vector<String>> dest) {

        JDMHostTrap host= (JDMHostTrap) jjtGetParent();
        JDMTrapInterestedHost hosts= (JDMTrapInterestedHost) host.jjtGetParent();
        JDMTrapItem trap = (JDMTrapItem) hosts.jjtGetParent();
        JDMTrapCommunity community = trap.getCommunity();
        String comm = community.getCommunity();

        InetAddress add = null;
        try {
            add = java.net.InetAddress.getByName(getHname());
        } catch(UnknownHostException e) {
            if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
                SNMP_LOGGER.logp(Level.FINEST, Host.class.getName(),
                        "buildTrapEntries",
                        "Cannot create TRAP entry; got exception", e);
            }
            return;
        }

        Vector<String> list = null;
        if (dest.containsKey(add)){
            list = dest.get(add);
            if (!list.contains(comm)){
                list.addElement(comm);
            }
        } else {
            list = new Vector<String>();
            list.addElement(comm);
            dest.put(add,list);
        }
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:33,代码来源:Host.java

示例6: buildInformEntries

import java.util.Hashtable; //导入方法依赖的package包/类
public void buildInformEntries(Hashtable<InetAddress, Vector<String>> dest) {

        JDMHostInform host= (JDMHostInform) jjtGetParent();
        JDMInformInterestedHost hosts= (JDMInformInterestedHost) host.jjtGetParent();
        JDMInformItem inform = (JDMInformItem) hosts.jjtGetParent();
        JDMInformCommunity community = inform.getCommunity();
        String comm = community.getCommunity();

        InetAddress add = null;
        try {
            add = java.net.InetAddress.getByName(getHname());
        } catch(UnknownHostException e) {
            if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
                SNMP_LOGGER.logp(Level.FINEST, Host.class.getName(),
                        "buildTrapEntries",
                        "Cannot create INFORM entry; got exception", e);
            }
            return;
        }

        Vector<String> list = null;
        if (dest.containsKey(add)){
            list = dest.get(add);
            if (!list.contains(comm)){
                list.addElement(comm);
            }
        } else {
            list = new Vector<String>();
            list.addElement(comm);
            dest.put(add,list);
        }
    }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:33,代码来源:Host.java

示例7: restoreEnvironmentParameter

import java.util.Hashtable; //导入方法依赖的package包/类
private void restoreEnvironmentParameter(DirContext context,
        String parameterName, Hashtable<?, ?> preservedEnvironment) {
    try {
        context.removeFromEnvironment(parameterName);
        if (preservedEnvironment != null && preservedEnvironment.containsKey(parameterName)) {
            context.addToEnvironment(parameterName,
                    preservedEnvironment.get(parameterName));
        }
    } catch (NamingException e) {
        // Ignore
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:13,代码来源:JNDIRealm.java

示例8: parseQueryString

import java.util.Hashtable; //导入方法依赖的package包/类
/**
    * Parses a query string passed from the client to the
    * server and builds a <code>HashTable</code> object
    * with key-value pairs. 
    * The query string should be in the form of a string
    * packaged by the GET or POST method, that is, it
    * should have key-value pairs in the form <i>key=value</i>,
    * with each pair separated from the next by a &amp; character.
    *
    * <p>A key can appear more than once in the query string
    * with different values. However, the key appears only once in 
    * the hashtable, with its value being
    * an array of strings containing the multiple values sent
    * by the query string.
    * 
    * <p>The keys and values in the hashtable are stored in their
    * decoded form, so
    * any + characters are converted to spaces, and characters
    * sent in hexadecimal notation (like <i>%xx</i>) are
    * converted to ASCII characters.
    *
    * @param s		a string containing the query to be parsed
    *
    * @return		a <code>HashTable</code> object built
    * 			from the parsed key-value pairs
    *
    * @exception IllegalArgumentException if the query string is invalid
    */
   public static Hashtable<String, String[]> parseQueryString(String s) {

       String valArray[] = null;

       if (s == null) {
           throw new IllegalArgumentException();
       }

       Hashtable<String, String[]> ht = new Hashtable<String, String[]>();
       StringBuilder sb = new StringBuilder();
       StringTokenizer st = new StringTokenizer(s, "&");
       while (st.hasMoreTokens()) {
       String pair = st.nextToken();
       int pos = pair.indexOf('=');
       if (pos == -1) {
           // XXX
           // should give more detail about the illegal argument
           throw new IllegalArgumentException();
       }
       String key = parseName(pair.substring(0, pos), sb);
       String val = parseName(pair.substring(pos+1, pair.length()), sb);
       if (ht.containsKey(key)) {
           String oldVals[] = ht.get(key);
           valArray = new String[oldVals.length + 1];
           for (int i = 0; i < oldVals.length; i++) {
               valArray[i] = oldVals[i];
           }
           valArray[oldVals.length] = val;
       } else {
           valArray = new String[1];
           valArray[0] = val;
       }
       ht.put(key, valArray);
   }

return ht;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:66,代码来源:HttpUtils.java

示例9: getReward

import java.util.Hashtable; //导入方法依赖的package包/类
@Override
public void getReward(MissionInit missionInit, MultidimensionalReward reward) {
    super.getReward(missionInit, reward);
    try {
        Hashtable<String, Object> properties = MalmoMod.getPropertiesForCurrentThread();
        if (properties.containsKey("QuitCode")) {
            float reward_value = parseQuitCode((String) properties.get("QuitCode"));
            reward.add( this.params.getDimension(), reward_value);
        }
    } catch (Exception e) {
    }
}
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:13,代码来源:RewardForMissionEndImplementation.java

示例10: is16Hashtable

import java.util.Hashtable; //导入方法依赖的package包/类
public static boolean is16Hashtable(Hashtable<Object, Object> ht) {
    return ht.containsKey(DEFINED_KEY);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:4,代码来源:AttributeValues.java

示例11: processChildren

import java.util.Hashtable; //导入方法依赖的package包/类
/**
 * Given this target node, and the array of its source-level children, treat them as follows:
 * 1. The info for a source child who has the same class as this node, is added to this node.
 * Its own children are processed recursively by calling this same method.
 * 2. The first source child whose class is different and was not observed before (not contained
 * in uniqChildCache) is added to uniqChildCache, and to allSourceChildren.
 * 3. All other source children are added to allSourceChildren, but not to uniqChildCache.
 */
protected void processChildren(int dataOfs, int methodNodeOfs, int nChildren, IntVector allSourceChildren,
                               Hashtable uniqChildCache) {
    int thisNodeClassOrPackageId = getMethodIdForNodeOfs(dataOfs);

    int nCalls = 0;
    long time0 = 0;
    long time1 = 0;

    for (int i = 0; i < nChildren; i++) {
        int sourceChildOfs = sourceContainer.getChildOfsForNodeOfs(methodNodeOfs, i);
        int sourceChildClassOrPackageId = methodIdMap.getClassOrPackageIdForMethodId(sourceContainer.getMethodIdForNodeOfs(sourceChildOfs));

        if (sourceChildClassOrPackageId == thisNodeClassOrPackageId) { // A child node has the same class as this node
            nCalls += sourceContainer.getNCallsForNodeOfs(sourceChildOfs);
            time0 += sourceContainer.getSelfTime0ForNodeOfs(sourceChildOfs);

            if (collectingTwoTimeStamps) {
                time1 += sourceContainer.getSelfTime1ForNodeOfs(sourceChildOfs);
            }

            // sourceChild's children logically become this node's children now.
            int nSourceChildChildren = sourceContainer.getNChildrenForNodeOfs(sourceChildOfs);

            if (nSourceChildChildren > 0) {
                this.processChildren(dataOfs, sourceChildOfs, nSourceChildChildren, allSourceChildren, uniqChildCache);
            }
        } else { // A child node belongs to a different class

            Integer key = Integer.valueOf(sourceChildClassOrPackageId);

            if (!uniqChildCache.containsKey(key)) {
                uniqChildCache.put(key, key);
            }

            allSourceChildren.add(sourceChildOfs);
        }
    }

    nCalls += getNCallsForNodeOfs(dataOfs);
    time0 += getSelfTime0ForNodeOfs(dataOfs);

    if (collectingTwoTimeStamps) {
        time1 += getSelfTime1ForNodeOfs(dataOfs);
    }

    setNCallsForNodeOfs(dataOfs, nCalls);
    setSelfTime0ForNodeOfs(dataOfs, time0);

    if (collectingTwoTimeStamps) {
        setSelfTime1ForNodeOfs(dataOfs, time1);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:61,代码来源:CPUCCTClassContainer.java

示例12: parseStanzaTable

import java.util.Hashtable; //导入方法依赖的package包/类
/**
 * Parses stanza names and values from configuration file to
 * stanzaTable (Hashtable). Hashtable key would be stanza names,
 * (libdefaults, realms, domain_realms, etc), and the hashtable value
 * would be another hashtable which contains the key-value pairs under
 * a stanza name. The value of this sub-hashtable can be another hashtable
 * containing another sub-sub-section or a vector of strings for
 * final values (even if there is only one value defined).
 * <p>
 * For duplicates section names, the latter overwrites the former. For
 * duplicate value names, the values are in a vector in its appearing order.
 * </ol>
 * Please note that this behavior is Java traditional. and it is
 * not the same as the MIT krb5 behavior, where:<ol>
 * <li>Duplicated root sections will be merged
 * <li>For duplicated sub-sections, the former overwrites the latter
 * <li>Duplicate keys for values are always saved in a vector
 * </ol>
 * @param v the strings in the file, never null, might be empty
 * @throws KrbException if there is a file format error
 */
@SuppressWarnings("unchecked")
private Hashtable<String,Object> parseStanzaTable(List<String> v)
        throws KrbException {
    Hashtable<String,Object> current = stanzaTable;
    for (String line: v) {
        // There are 3 kinds of lines
        // 1. a = b
        // 2. a = {
        // 3. }
        if (line.equals("}")) {
            // Go back to parent, see below
            current = (Hashtable<String,Object>)current.remove(" PARENT ");
            if (current == null) {
                throw new KrbException("Unmatched close brace");
            }
        } else {
            int pos = line.indexOf('=');
            if (pos < 0) {
                throw new KrbException("Illegal config content:" + line);
            }
            String key = line.substring(0, pos).trim();
            String value = trimmed(line.substring(pos+1));
            if (value.equals("{")) {
                Hashtable<String,Object> subTable;
                if (current == stanzaTable) {
                    key = key.toLowerCase(Locale.US);
                }
                subTable = new Hashtable<>();
                current.put(key, subTable);
                // A special entry for its parent. Put whitespaces around,
                // so will never be confused with a normal key
                subTable.put(" PARENT ", current);
                current = subTable;
            } else {
                Vector<String> values;
                if (current.containsKey(key)) {
                    Object obj = current.get(key);
                    // If a key first shows as a section and then a value,
                    // this is illegal. However, we haven't really forbid
                    // first value then section, which the final result
                    // is a section.
                    if (!(obj instanceof Vector)) {
                        throw new KrbException("Key " + key
                                + "used for both value and section");
                    }
                    values = (Vector<String>)current.get(key);
                } else {
                    values = new Vector<String>();
                    current.put(key, values);
                }
                values.add(value);
            }
        }
    }
    if (current != stanzaTable) {
        throw new KrbException("Not closed");
    }
    return current;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:81,代码来源:Config.java

示例13: conflictInfo

import java.util.Hashtable; //导入方法依赖的package包/类
@Override
  public Hashtable conflictInfo(Collection hints) {
  	Hashtable conflictTable = new Hashtable();
  	Lock lock = currentSolution().getLock().readLock();
lock.lock();
try {
	HashSet done = new HashSet();
	for (Iterator i=hints.iterator();i.hasNext();) {
		Hint hint = (Hint)i.next();
		Placement p = hint.getPlacement((TimetableModel)currentSolution().getModel());
		if (p==null) continue;
        for (Constraint constraint: p.variable().hardConstraints()) {
            HashSet conflicts = new HashSet();
            constraint.computeConflicts(currentSolution().getAssignment(), p, conflicts);
            if (conflicts!=null && !conflicts.isEmpty()) {
            	for (Iterator j=conflicts.iterator();j.hasNext();) {
            		Placement conflict = (Placement)j.next();
            		Hint confHint = new Hint(this, conflict);
            		if (done.contains(confHint)) continue;
            		if (!conflictTable.containsKey(confHint)) {
            			String name = constraint.getName();
        				if (constraint instanceof RoomConstraint) {
        					name = "Room "+constraint.getName();
        				} else if (constraint instanceof InstructorConstraint) {
        					name = "Instructor "+constraint.getName();
        				} else if (constraint instanceof GroupConstraint) {
        					name = "Distribution "+constraint.getName();
        				} else if (constraint instanceof DepartmentSpreadConstraint) {
        					name = "Balancing of department "+constraint.getName();
        				} else if (constraint instanceof SpreadConstraint) {
        					name = "Same subpart spread "+constraint.getName();
        				} else if (constraint instanceof ClassLimitConstraint) {
        					name = "Class limit "+constraint.getName();
        				}
        				conflictTable.put(confHint, name);
            		}
            	}
            }
        }
        done.add(hint);
	}
} finally {
	lock.unlock();
}
return conflictTable;
  }
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:47,代码来源:TimetableSolver.java

示例14: esInputValidoDeEstado

import java.util.Hashtable; //导入方法依赖的package包/类
/**
 *  Determina si el input dado es uno de los inputs que se esperan en el estado
 *  dado
 *
 *@param  estado  Estado a evaluar
 *@param  input   Input que se desea comprobar
 *@return         Dice si es vlido o no
 */
public boolean esInputValidoDeEstado(String estado, String input)
{
	Hashtable inp = (Hashtable) inputsDeEstados.get(estado);
	return (inp.containsKey(input));
}
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:14,代码来源:TablaEstadosAutomataEF.java


注:本文中的java.util.Hashtable.containsKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。