java.util.Hashtable#entrySet ( )源码实例Demo

下面列出了java.util.Hashtable#entrySet ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: jdk8u-dev-jdk   文件: PropertyChangeSupport.java
private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException {
    this.map = new PropertyChangeListenerMap();

    ObjectInputStream.GetField fields = s.readFields();

    @SuppressWarnings("unchecked")
    Hashtable<String, PropertyChangeSupport> children = (Hashtable<String, PropertyChangeSupport>) fields.get("children", null);
    this.source = fields.get("source", null);
    fields.get("propertyChangeSupportSerializedDataVersion", 2);

    Object listenerOrNull;
    while (null != (listenerOrNull = s.readObject())) {
        this.map.add(null, (PropertyChangeListener)listenerOrNull);
    }
    if (children != null) {
        for (Entry<String, PropertyChangeSupport> entry : children.entrySet()) {
            for (PropertyChangeListener listener : entry.getValue().getPropertyChangeListeners()) {
                this.map.add(entry.getKey(), listener);
            }
        }
    }
}
 
源代码2 项目: openjdk-8-source   文件: AttributeValues.java
public static AttributeValues
fromSerializableHashtable(Hashtable<Object, Object> ht)
{
    AttributeValues result = new AttributeValues();
    if (ht != null && !ht.isEmpty()) {
        for (Map.Entry<Object, Object> e: ht.entrySet()) {
            Object key = e.getKey();
            Object val = e.getValue();
            if (key.equals(DEFINED_KEY)) {
                result.defineAll(((Integer)val).intValue());
            } else {
                try {
                    EAttribute ea =
                        EAttribute.forAttribute((Attribute)key);
                    if (ea != null) {
                        result.set(ea, val);
                    }
                }
                catch (ClassCastException ex) {
                }
            }
        }
    }
    return result;
}
 
源代码3 项目: Java8CN   文件: VetoableChangeSupport.java
private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException {
    this.map = new VetoableChangeListenerMap();

    ObjectInputStream.GetField fields = s.readFields();

    @SuppressWarnings("unchecked")
    Hashtable<String, VetoableChangeSupport> children = (Hashtable<String, VetoableChangeSupport>)fields.get("children", null);
    this.source = fields.get("source", null);
    fields.get("vetoableChangeSupportSerializedDataVersion", 2);

    Object listenerOrNull;
    while (null != (listenerOrNull = s.readObject())) {
        this.map.add(null, (VetoableChangeListener)listenerOrNull);
    }
    if (children != null) {
        for (Entry<String, VetoableChangeSupport> entry : children.entrySet()) {
            for (VetoableChangeListener listener : entry.getValue().getVetoableChangeListeners()) {
                this.map.add(entry.getKey(), listener);
            }
        }
    }
}
 
源代码4 项目: openjdk-jdk8u   文件: VetoableChangeSupport.java
private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException {
    this.map = new VetoableChangeListenerMap();

    ObjectInputStream.GetField fields = s.readFields();

    @SuppressWarnings("unchecked")
    Hashtable<String, VetoableChangeSupport> children = (Hashtable<String, VetoableChangeSupport>)fields.get("children", null);
    this.source = fields.get("source", null);
    fields.get("vetoableChangeSupportSerializedDataVersion", 2);

    Object listenerOrNull;
    while (null != (listenerOrNull = s.readObject())) {
        this.map.add(null, (VetoableChangeListener)listenerOrNull);
    }
    if (children != null) {
        for (Entry<String, VetoableChangeSupport> entry : children.entrySet()) {
            for (VetoableChangeListener listener : entry.getValue().getVetoableChangeListeners()) {
                this.map.add(entry.getKey(), listener);
            }
        }
    }
}
 
源代码5 项目: wandora   文件: W2TTopic.java
@Override
public Set<Occurrence> getOccurrences() {
    try{
        HashSet<Occurrence> ret=new HashSet<Occurrence>();
        for(org.wandora.topicmap.Topic _type : t.getDataTypes()){
            W2TTopic type=new W2TTopic(tm,_type);
            Hashtable<org.wandora.topicmap.Topic,String> occs=t.getData(_type);

            for(Map.Entry<org.wandora.topicmap.Topic,String> e : occs.entrySet()){
                org.wandora.topicmap.Topic lang=e.getKey();
                ret.add(new W2TOccurrence(this,type,lang!=null?new W2TTopic(tm,lang):null));
            }
        }
        
        return ret;
    }catch(TopicMapException tme){
        throw new TMAPIRuntimeException(tme);
    }
}
 
源代码6 项目: TencentKona-8   文件: AttributeValues.java
public static AttributeValues
fromSerializableHashtable(Hashtable<Object, Object> ht)
{
    AttributeValues result = new AttributeValues();
    if (ht != null && !ht.isEmpty()) {
        for (Map.Entry<Object, Object> e: ht.entrySet()) {
            Object key = e.getKey();
            Object val = e.getValue();
            if (key.equals(DEFINED_KEY)) {
                result.defineAll(((Integer)val).intValue());
            } else {
                try {
                    EAttribute ea =
                        EAttribute.forAttribute((Attribute)key);
                    if (ea != null) {
                        result.set(ea, val);
                    }
                }
                catch (ClassCastException ex) {
                }
            }
        }
    }
    return result;
}
 
源代码7 项目: openjdk-jdk8u   文件: PropertyChangeSupport.java
private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException {
    this.map = new PropertyChangeListenerMap();

    ObjectInputStream.GetField fields = s.readFields();

    @SuppressWarnings("unchecked")
    Hashtable<String, PropertyChangeSupport> children = (Hashtable<String, PropertyChangeSupport>) fields.get("children", null);
    this.source = fields.get("source", null);
    fields.get("propertyChangeSupportSerializedDataVersion", 2);

    Object listenerOrNull;
    while (null != (listenerOrNull = s.readObject())) {
        this.map.add(null, (PropertyChangeListener)listenerOrNull);
    }
    if (children != null) {
        for (Entry<String, PropertyChangeSupport> entry : children.entrySet()) {
            for (PropertyChangeListener listener : entry.getValue().getPropertyChangeListeners()) {
                this.map.add(entry.getKey(), listener);
            }
        }
    }
}
 
源代码8 项目: pra   文件: Helper.java
public static List sortByValueThenKeyLength(Hashtable hash) {
	ArrayList alist = new ArrayList(hash.entrySet());
	Collections.sort(alist, new Comparator() {
		public int compare(Object o1, Object o2) {
			Comparable c1 = (Comparable) ((Map.Entry) o1).getValue();
			Comparable c2 = (Comparable) ((Map.Entry) o2).getValue();
			int result = c2.compareTo(c1);
			if (result == 0) {
				String s1 = (String) ((Map.Entry) o1).getKey();
				String s2 = (String) ((Map.Entry) o2).getKey();
				return new Integer(s2.length()).compareTo(new Integer(s1.length()));
			} else {
				return result;
			}
		}
	});
	return alist;
}
 
源代码9 项目: openprodoc   文件: PoolSessions.java
/**
 * 
 */
@Override 
public void run() 
{
while (true)
    {    
    Hashtable<String, CurrentSession> listOPSess = getListOPSess();
    for (Map.Entry<String, CurrentSession> entry : listOPSess.entrySet())
        {
        if (HasExpired(entry.getValue()))  
            DelSession(entry.getKey());
        }
    try {
    Thread.sleep(getTIMEOUT());
    } catch (InterruptedException e) 
        {
        }

    }

}
 
源代码10 项目: jdk8u60   文件: PropertyChangeSupport.java
private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException {
    this.map = new PropertyChangeListenerMap();

    ObjectInputStream.GetField fields = s.readFields();

    @SuppressWarnings("unchecked")
    Hashtable<String, PropertyChangeSupport> children = (Hashtable<String, PropertyChangeSupport>) fields.get("children", null);
    this.source = fields.get("source", null);
    fields.get("propertyChangeSupportSerializedDataVersion", 2);

    Object listenerOrNull;
    while (null != (listenerOrNull = s.readObject())) {
        this.map.add(null, (PropertyChangeListener)listenerOrNull);
    }
    if (children != null) {
        for (Entry<String, PropertyChangeSupport> entry : children.entrySet()) {
            for (PropertyChangeListener listener : entry.getValue().getPropertyChangeListeners()) {
                this.map.add(entry.getKey(), listener);
            }
        }
    }
}
 
源代码11 项目: openjdk-jdk9   文件: VetoableChangeSupport.java
private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException {
    this.map = new VetoableChangeListenerMap();

    ObjectInputStream.GetField fields = s.readFields();

    @SuppressWarnings("unchecked")
    Hashtable<String, VetoableChangeSupport> children = (Hashtable<String, VetoableChangeSupport>)fields.get("children", null);
    this.source = fields.get("source", null);
    fields.get("vetoableChangeSupportSerializedDataVersion", 2);

    Object listenerOrNull;
    while (null != (listenerOrNull = s.readObject())) {
        this.map.add(null, (VetoableChangeListener)listenerOrNull);
    }
    if (children != null) {
        for (Entry<String, VetoableChangeSupport> entry : children.entrySet()) {
            for (VetoableChangeListener listener : entry.getValue().getVetoableChangeListeners()) {
                this.map.add(entry.getKey(), listener);
            }
        }
    }
}
 
源代码12 项目: j2objc   文件: PropertyChangeSupport.java
private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException {
    this.map = new PropertyChangeListenerMap();

    ObjectInputStream.GetField fields = s.readFields();

    @SuppressWarnings("unchecked")
    Hashtable<String, PropertyChangeSupport> children = (Hashtable<String, PropertyChangeSupport>) fields.get("children", null);
    this.source = fields.get("source", null);
    fields.get("propertyChangeSupportSerializedDataVersion", 2);

    Object listenerOrNull;
    while (null != (listenerOrNull = s.readObject())) {
        this.map.add(null, (PropertyChangeListener)listenerOrNull);
    }
    if (children != null) {
        for (Entry<String, PropertyChangeSupport> entry : children.entrySet()) {
            for (PropertyChangeListener listener : entry.getValue().getPropertyChangeListeners()) {
                this.map.add(entry.getKey(), listener);
            }
        }
    }
}
 
源代码13 项目: micro-integrator   文件: CarbonContext.java
/**
 * Create filter from the bundle context adding class name and properties
 *
 * @param bundleContext BundleContext
 * @param clazz The type of the OSGi service
 * @param props attribute list that filter the service list
 * @return Filter
 * @throws InvalidSyntaxException
 */
protected Filter createFilter(BundleContext bundleContext, Class clazz, Hashtable<String, String> props)
        throws InvalidSyntaxException {
    StringBuilder buf = new StringBuilder();
    buf.append("(objectClass=" + clazz.getName() + ")");
    if (props != null && !props.isEmpty()) {
        buf.insert(0, "(&");
        for (Map.Entry<String, String> entry : props.entrySet()) {
            buf.append("(" + entry.getKey() + "=" + entry.getValue() + ")");
        }
        buf.append(")");
    }
    return bundleContext.createFilter(buf.toString());
}
 
源代码14 项目: openjdk-8   文件: SimpleSerialization.java
public static void main(final String[] args) throws Exception {
    Hashtable<String, String> h1 = new Hashtable<>();

    System.err.println("*** BEGIN TEST ***");

    h1.put("key", "value");

    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try (ObjectOutputStream oos = new ObjectOutputStream(baos)) {
        oos.writeObject(h1);
    }

    final byte[] data = baos.toByteArray();
    final ByteArrayInputStream bais = new ByteArrayInputStream(data);
    final Object deserializedObject;
    try (ObjectInputStream ois = new ObjectInputStream(bais)) {
        deserializedObject = ois.readObject();
    }

    if(!h1.getClass().isInstance(deserializedObject)) {
         throw new RuntimeException("Result not assignable to type of h1");
    }

    if (false == h1.equals(deserializedObject)) {
         Hashtable<String, String> d1 = (Hashtable<String, String>) h1;
        for(Map.Entry entry: h1.entrySet()) {
            System.err.println("h1.key::" + entry.getKey() + " d1.containsKey()::" + d1.containsKey((String) entry.getKey()));
            System.err.println("h1.value::" + entry.getValue() + " d1.contains()::" + d1.contains(entry.getValue()));
            System.err.println("h1.value == d1.value " + entry.getValue().equals(d1.get((String) entry.getKey())));
        }

        throw new RuntimeException(getFailureText(h1, deserializedObject));
    }
}
 
源代码15 项目: settlers-remake   文件: SimpleBuildingJob.java
private static void linkJobs(BuildingJobDataProvider provider, Hashtable<String, SimpleBuildingJob> converted) {
	Set<Entry<String, SimpleBuildingJob>> items = converted.entrySet();
	for (Entry<String, SimpleBuildingJob> item : items) {
		String name = item.getKey();
		SimpleBuildingJob job = item.getValue();
		BuildingJobData definition = provider.getJobData(name);

		job.failJob = converted.get(definition.getNextFailJob());
		job.successJob = converted.get(definition.getNextSucessJob());
		if (job.failJob == null || job.successJob == null) {
			throw new IllegalArgumentException("Next jobs were not found.");
		}
	}
}
 
源代码16 项目: TencentKona-8   文件: SimpleSerialization.java
public static void main(final String[] args) throws Exception {
    Hashtable<String, String> h1 = new Hashtable<>();

    System.err.println("*** BEGIN TEST ***");

    h1.put("key", "value");

    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try (ObjectOutputStream oos = new ObjectOutputStream(baos)) {
        oos.writeObject(h1);
    }

    final byte[] data = baos.toByteArray();
    final ByteArrayInputStream bais = new ByteArrayInputStream(data);
    final Object deserializedObject;
    try (ObjectInputStream ois = new ObjectInputStream(bais)) {
        deserializedObject = ois.readObject();
    }

    if(!h1.getClass().isInstance(deserializedObject)) {
         throw new RuntimeException("Result not assignable to type of h1");
    }

    if (false == h1.equals(deserializedObject)) {
         Hashtable<String, String> d1 = (Hashtable<String, String>) h1;
        for(Map.Entry entry: h1.entrySet()) {
            System.err.println("h1.key::" + entry.getKey() + " d1.containsKey()::" + d1.containsKey((String) entry.getKey()));
            System.err.println("h1.value::" + entry.getValue() + " d1.contains()::" + d1.contains(entry.getValue()));
            System.err.println("h1.value == d1.value " + entry.getValue().equals(d1.get((String) entry.getKey())));
        }

        throw new RuntimeException(getFailureText(h1, deserializedObject));
    }
}
 
源代码17 项目: Bytecoder   文件: Permissions.java
@java.io.Serial
private void readObject(ObjectInputStream in) throws IOException,
ClassNotFoundException {
    // Don't call defaultReadObject()

    // Read in serialized fields
    ObjectInputStream.GetField gfields = in.readFields();

    // Get allPermission
    allPermission = (PermissionCollection) gfields.get("allPermission", null);

    // Get permissions
    // writeObject writes a Hashtable<Class<?>, PermissionCollection> for
    // the perms key, so this cast is safe, unless the data is corrupt.
    @SuppressWarnings("unchecked")
    Hashtable<Class<?>, PermissionCollection> perms =
        (Hashtable<Class<?>, PermissionCollection>)gfields.get("perms", null);
    permsMap = new ConcurrentHashMap<>(perms.size()*2);
    permsMap.putAll(perms);

    // Check that Class is mapped to PermissionCollection containing
    // Permissions of the same class
    for (Map.Entry<Class<?>, PermissionCollection> e : perms.entrySet()) {
        Class<?> k = e.getKey();
        PermissionCollection v = e.getValue();
        Enumeration<Permission> en = v.elements();
        while (en.hasMoreElements()) {
            Permission p = en.nextElement();
            if (!k.equals(p.getClass())) {
                throw new InvalidObjectException("Permission with class " +
                    k + " incorrectly mapped to PermissionCollection " +
                    "containing Permission with " + p.getClass());
            }
        }
    }

    // Set hasUnresolved
    UnresolvedPermissionCollection uc =
    (UnresolvedPermissionCollection) permsMap.get(UnresolvedPermission.class);
    hasUnresolved = (uc != null && uc.elements().hasMoreElements());
}
 
源代码18 项目: Bytecoder   文件: CoreDocumentImpl.java
@SuppressWarnings("unchecked")
private void readObject(ObjectInputStream in)
                    throws IOException, ClassNotFoundException {
    // We have to read serialized fields first.
    ObjectInputStream.GetField gf = in.readFields();
    docType = (DocumentTypeImpl)gf.get("docType", null);
    docElement = (ElementImpl)gf.get("docElement", null);
    fFreeNLCache = (NodeListCache)gf.get("fFreeNLCache", null);
    encoding = (String)gf.get("encoding", null);
    actualEncoding = (String)gf.get("actualEncoding", null);
    version = (String)gf.get("version", null);
    standalone = gf.get("standalone", false);
    fDocumentURI = (String)gf.get("fDocumentURI", null);

    //userData is the original name. It has been changed to nodeUserData, refer to the corrsponding @serialField
    Hashtable<Node, Hashtable<String, UserDataRecord>> nud =
            (Hashtable<Node, Hashtable<String, UserDataRecord>>)gf.get("userData", null);

    Hashtable<String, Node> ids = (Hashtable<String, Node>)gf.get("identifiers", null);

    changes = gf.get("changes", 0);
    allowGrammarAccess = gf.get("allowGrammarAccess", false);
    errorChecking = gf.get("errorChecking", true);
    ancestorChecking = gf.get("ancestorChecking", true);
    xmlVersionChanged = gf.get("xmlVersionChanged", false);
    documentNumber = gf.get("documentNumber", 0);
    nodeCounter = gf.get("nodeCounter", 0);

    Hashtable<Node, Integer> nt = (Hashtable<Node, Integer>)gf.get("nodeTable", null);

    xml11Version = gf.get("xml11Version", false);

    //convert Hashtables back to HashMaps
    if (nud != null) {
        nodeUserData = new HashMap<>();
        for (Map.Entry<Node, Hashtable<String, UserDataRecord>> e : nud.entrySet()) {
            nodeUserData.put(e.getKey(), new HashMap<>(e.getValue()));
        }
    }

    if (ids != null) identifiers = new HashMap<>(ids);
    if (nt != null) nodeTable = new HashMap<>(nt);
}
 
源代码19 项目: unitime   文件: JenrlInfo.java
public JenrlInfo(Solver solver, JenrlConstraint jc) {
	super();
	Assignment<Lecture, Placement> assignment = solver.currentSolution().getAssignment();
	TimetableModel model = (TimetableModel)solver.currentSolution().getModel();
	Lecture first = (Lecture)jc.first();
	Placement firstPl = (Placement)assignment.getValue(first);
	Lecture second = (Lecture)jc.second();
	Placement secondPl = (Placement)assignment.getValue(second);
	if (solver!=null) {
		if (firstPl!=null)
			iFirst = new ClassAssignmentDetails(solver,first,firstPl,false);
		if (secondPl!=null)
			iSecond = new ClassAssignmentDetails(solver,second,secondPl,false);
	}
	if (firstPl==null || secondPl==null) return;
	setJenrl(jc.getJenrl());
	setIsSatisfied(jc.isInConflict(assignment));
	if (jc.isInConflict(assignment)) {
		setIsHard(first.areStudentConflictsHard(second));
		setIsFixed(first.nrTimeLocations()==1 && second.nrTimeLocations()==1);
		setIsDistance(StudentConflict.distance(model.getDistanceMetric(), firstPl, secondPl));
		setIsWorkDay(StudentConflict.workday(model.getStudentWorkDayLimit(), firstPl, secondPl));
		setIsCommited(jc.areStudentConflictsCommitted());
		if (isDistance())
			setDistance(Placement.getDistanceInMeters(model.getDistanceMetric(),firstPl,secondPl));
		StudentConflict imp = (StudentConflict)model.getCriterion(ImportantStudentConflict.class);
		setIsImportant(imp != null && imp.isApplicable(first, second) && imp.inConflict(firstPl, secondPl));
		setIsInstructor(jc.getNrInstructors() > 0);
	}
	Hashtable<String, Double> curriculum2nrStudents = new Hashtable<String, Double>();
	for (Student student: jc.first().sameStudents(jc.second())) {
		if (student.getCurriculum() == null || student.getCurriculum().isEmpty()) continue;
		for (String c: student.getCurriculum().split("\\|")) {
			Double nrStudents = curriculum2nrStudents.get(c);
			curriculum2nrStudents.put(student.getCurriculum(), jc.getJenrlWeight(student) + (nrStudents == null ? 0.0 : nrStudents));
		}
	}
	if (!curriculum2nrStudents.isEmpty()) {
		iCurriculum2nrStudents = new TreeSet<CurriculumInfo>();
		for (Map.Entry<String, Double> entry: curriculum2nrStudents.entrySet()) {
			iCurriculum2nrStudents.add(new CurriculumInfo(entry.getKey(), entry.getValue()));
		}
	}
}
 
源代码20 项目: openjdk-jdk9   文件: CoreDocumentImpl.java
@SuppressWarnings("unchecked")
private void readObject(ObjectInputStream in)
                    throws IOException, ClassNotFoundException {
    // We have to read serialized fields first.
    ObjectInputStream.GetField gf = in.readFields();
    docType = (DocumentTypeImpl)gf.get("docType", null);
    docElement = (ElementImpl)gf.get("docElement", null);
    fFreeNLCache = (NodeListCache)gf.get("fFreeNLCache", null);
    encoding = (String)gf.get("encoding", null);
    actualEncoding = (String)gf.get("actualEncoding", null);
    version = (String)gf.get("version", null);
    standalone = gf.get("standalone", false);
    fDocumentURI = (String)gf.get("fDocumentURI", null);

    //userData is the original name. It has been changed to nodeUserData, refer to the corrsponding @serialField
    Hashtable<Node, Hashtable<String, UserDataRecord>> nud =
            (Hashtable<Node, Hashtable<String, UserDataRecord>>)gf.get("userData", null);

    Hashtable<String, Node> ids = (Hashtable<String, Node>)gf.get("identifiers", null);

    changes = gf.get("changes", 0);
    allowGrammarAccess = gf.get("allowGrammarAccess", false);
    errorChecking = gf.get("errorChecking", true);
    ancestorChecking = gf.get("ancestorChecking", true);
    xmlVersionChanged = gf.get("xmlVersionChanged", false);
    documentNumber = gf.get("documentNumber", 0);
    nodeCounter = gf.get("nodeCounter", 0);

    Hashtable<Node, Integer> nt = (Hashtable<Node, Integer>)gf.get("nodeTable", null);

    xml11Version = gf.get("xml11Version", false);

    //convert Hashtables back to HashMaps
    if (nud != null) {
        nodeUserData = new HashMap<>();
        for (Map.Entry<Node, Hashtable<String, UserDataRecord>> e : nud.entrySet()) {
            nodeUserData.put(e.getKey(), new HashMap<>(e.getValue()));
        }
    }

    if (ids != null) identifiers = new HashMap<>(ids);
    if (nt != null) nodeTable = new HashMap<>(nt);
}