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

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

源代码1 项目: jdk8u-jdk   文件: 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;
}
 
private Set<String> removeFromLocationToPids(ServiceReference<?> sr)
{
  HashSet<String> res = new HashSet<String>();
  if (sr != null) {
    Bundle bundle = sr.getBundle();
    final String bundleLocation = bundle.getLocation();
    final Hashtable<String, TreeSet<ServiceReference<?>>> pidsForLocation =
      locationToPids.get(bundleLocation);
    for (final Iterator<Entry<String, TreeSet<ServiceReference<?>>>> it =
      pidsForLocation.entrySet().iterator(); it.hasNext();) {
      final Entry<String, TreeSet<ServiceReference<?>>> entry = it.next();
      TreeSet<ServiceReference<?>> ssrs = entry.getValue();
      if (ssrs.remove(sr)) {
        res.add(entry.getKey());
        if (ssrs.isEmpty()) {
          it.remove();
        }
      }
    }
    if (pidsForLocation.isEmpty()) {
      locationToPids.remove(bundleLocation);
    }
  }
  return res;
}
 
源代码3 项目: 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;
}
 
源代码4 项目: openjdk-jdk9   文件: SCDynamicStoreConfig.java
@SuppressWarnings("unchecked")
private static Hashtable<String, Object> convertNativeConfig(
        Hashtable<String, Object> stanzaTable) throws IOException {
    // convert SCDynamicStore realm structure to Java realm structure
    Hashtable<String, ?> realms =
            (Hashtable<String, ?>) stanzaTable.get("realms");
    if (realms == null || realms.isEmpty()) {
        throw new IOException(
                "SCDynamicStore contains an empty Kerberos setting");
    }
    stanzaTable.remove("realms");
    Hashtable<String, Object> realmsTable = convertRealmConfigs(realms);
    stanzaTable.put("realms", realmsTable);
    WrapAllStringInVector(stanzaTable);
    if (DEBUG) System.out.println("stanzaTable : " + stanzaTable);
    return stanzaTable;
}
 
源代码5 项目: Bytecoder   文件: 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;
}
 
public static DataSource lookupDataSource(String dataSourceName, final Hashtable<Object, Object> jndiProperties) {
    try {
        if (jndiProperties == null || jndiProperties.isEmpty()) {
            return (DataSource) InitialContext.doLookup(dataSourceName);
        }
        final InitialContext context = new InitialContext(jndiProperties);
        return (DataSource) context.doLookup(dataSourceName);
    } catch (Exception e) {
        throw new RuntimeException("Error in looking up data source: " + e.getMessage(), e);
    }
}
 
源代码7 项目: j2objc   文件: HashtableTest.java
/**
 * java.util.Hashtable#isEmpty()
 */
public void test_isEmpty() {
    // Test for method boolean java.util.Hashtable.isEmpty()

    assertTrue("isEmpty returned incorrect value", !ht10.isEmpty());
    assertTrue("isEmpty returned incorrect value",
            new java.util.Hashtable().isEmpty());

    final Hashtable ht = new Hashtable();
    ht.put("0", "");
    Thread t1 = new Thread() {
        public void run() {
            while (!ht.isEmpty())
                ;
            ht.put("final", "");
        }
    };
    t1.start();
    for (int i = 1; i < 10000; i++) {
        synchronized (ht) {
            ht.remove(String.valueOf(i - 1));
            ht.put(String.valueOf(i), "");
        }
        int size;
        if ((size = ht.size()) != 1) {
            String result = "Size is not 1: " + size + " " + ht;
            // terminate the thread
            ht.clear();
            fail(result);
        }
    }
    // terminate the thread
    ht.clear();
}
 
源代码8 项目: jdk8u60   文件: CoreDocumentImpl.java
/**
 * Call user data handlers when a node is deleted (finalized)
 * @param n The node this operation applies to.
 * @param c The copy node or null.
 * @param operation The operation - import, clone, or delete.
     * @param handlers Data associated with n.
    */
    void callUserDataHandlers(Node n, Node c, short operation,Hashtable userData) {
    if (userData == null || userData.isEmpty()) {
        return;
    }
    Enumeration keys = userData.keys();
    while (keys.hasMoreElements()) {
        String key = (String) keys.nextElement();
        UserDataRecord r = (UserDataRecord) userData.get(key);
        if (r.fHandler != null) {
            r.fHandler.handle(operation, key, r.fData, n, c);
        }
    }
}
 
源代码9 项目: unitime   文件: ProjectedStudentCourseDemands.java
@Override
public float getProjection(String areaAbbv, String clasfCode, String majorCode) {
	if (iAreaClasfMajor2Proj.isEmpty()) return 1.0f;
	Hashtable<String,Hashtable<String, Float>> clasf2major2proj = (areaAbbv == null ? null : iAreaClasfMajor2Proj.get(areaAbbv));
	if (clasf2major2proj == null || clasf2major2proj.isEmpty()) return 1.0f;
	Hashtable<String, Float> major2proj = (clasfCode == null ? null : clasf2major2proj.get(clasfCode));
	if (major2proj == null) return 1.0f;
	Float projection = (majorCode == null ? null : major2proj.get(majorCode));
	if (projection == null)
		projection = major2proj.get("");
	return (projection == null ? 1.0f : projection);
}
 
源代码10 项目: unitime   文件: ReservationServlet.java
private float getProjection(Hashtable<String,HashMap<String, Float>> clasf2major2proj, String majorCode, String clasfCode) {
	if (clasf2major2proj == null || clasf2major2proj.isEmpty()) return 1.0f;
	HashMap<String, Float> major2proj = clasf2major2proj.get(clasfCode);
	if (major2proj == null) return 1.0f;
	Float projection = major2proj.get(majorCode);
	if (projection == null)
		projection = major2proj.get("");
	return (projection == null ? 1.0f : projection);
}
 
源代码11 项目: carbon-device-mgt   文件: NotificationDAOUtil.java
public static DataSource lookupDataSource(String dataSourceName,
                                          final Hashtable<Object, Object> jndiProperties) {
	try {
		if (jndiProperties == null || jndiProperties.isEmpty()) {
			return (DataSource) InitialContext.doLookup(dataSourceName);
		}
		final InitialContext context = new InitialContext(jndiProperties);
		return (DataSource) context.lookup(dataSourceName);
	} catch (Exception e) {
		throw new RuntimeException("Error in looking up data source: " + e.getMessage(), e);
	}
}
 
/**
 * Returns the HTML text for the list of services deployed.
 * This can be delegated to another Class as well
 * where it will handle more options of GET messages.
 *
 * @param prefix to be used for the Service names
 * @return the HTML to be displayed as a String
 */
protected String getServicesHTML(String prefix) {

    Map services = cfgCtx.getAxisConfiguration().getServices();
    Hashtable erroneousServices = cfgCtx.getAxisConfiguration().getFaultyServices();
    boolean servicesFound = false;

    StringBuffer resultBuf = new StringBuffer();
    resultBuf.append("<html><head><title>Axis2: Services</title></head>" + "<body>");

    if ((services != null) && !services.isEmpty()) {

        servicesFound = true;
        resultBuf.append("<h2>" + "Deployed services" + "</h2>");

        for (Object service : services.values()) {

            AxisService axisService = (AxisService) service;
            Parameter isHiddenService = axisService.getParameter(
                    NhttpConstants.HIDDEN_SERVICE_PARAM_NAME);
            Parameter isAdminService = axisService.getParameter("adminService");
            boolean isClientSide = axisService.isClientSide();

            boolean isSkippedService = (isHiddenService != null &&
                    JavaUtils.isTrueExplicitly(isHiddenService.getValue())) || (isAdminService != null &&
                    JavaUtils.isTrueExplicitly(isAdminService.getValue())) || isClientSide;
            if (axisService.getName().startsWith("__") || isSkippedService) {
                continue;    // skip private services
            }

            Iterator iterator = axisService.getOperations();
            resultBuf.append("<h3><a href=\"").append(prefix).append(axisService.getName()).append(
                    "?wsdl\">").append(axisService.getName()).append("</a></h3>");

            if (iterator.hasNext()) {
                resultBuf.append("Available operations <ul>");

                for (; iterator.hasNext();) {
                    AxisOperation axisOperation = (AxisOperation) iterator.next();
                    resultBuf.append("<li>").append(
                            axisOperation.getName().getLocalPart()).append("</li>");
                }
                resultBuf.append("</ul>");
            } else {
                resultBuf.append("No operations specified for this service");
            }
        }
    }

    if ((erroneousServices != null) && !erroneousServices.isEmpty()) {
        servicesFound = true;
        resultBuf.append("<hr><h2><font color=\"blue\">Faulty Services</font></h2>");
        Enumeration faultyservices = erroneousServices.keys();

        while (faultyservices.hasMoreElements()) {
            String faultyserviceName = (String) faultyservices.nextElement();
            resultBuf.append("<h3><font color=\"blue\">").append(
                    faultyserviceName).append("</font></h3>");
        }
    }

    if (!servicesFound) {
        resultBuf.append("<h2>There are no services deployed</h2>");
    }

    resultBuf.append("</body></html>");
    return resultBuf.toString();
}
 
源代码13 项目: SendBird-Android   文件: GroupChatFragment.java
/**
 * Sends a File Message containing an image file.
 * Also requests thumbnails to be generated in specified sizes.
 *
 * @param uri The URI of the image, which in this case is received through an Intent request.
 */
private void sendFileWithThumbnail(Uri uri) {
    if (mChannel == null) {
        return;
    }

    // Specify two dimensions of thumbnails to generate
    List<FileMessage.ThumbnailSize> thumbnailSizes = new ArrayList<>();
    thumbnailSizes.add(new FileMessage.ThumbnailSize(240, 240));
    thumbnailSizes.add(new FileMessage.ThumbnailSize(320, 320));

    Hashtable<String, Object> info = FileUtils.getFileInfo(getActivity(), uri);

    if (info == null || info.isEmpty()) {
        Toast.makeText(getActivity(), getString(R.string.wrong_file_info), Toast.LENGTH_LONG).show();
        return;
    }
    final String name;
    if (info.containsKey("name")) {
        name = (String) info.get("name");
    } else {
        name = "Sendbird File";
    }
    final String path = (String) info.get("path");
    final File file = new File(path);
    final String mime = (String) info.get("mime");
    final int size = (int) info.get("size");

    if (path == null || path.equals("")) {
        Toast.makeText(getActivity(), getString(R.string.wrong_file_path), Toast.LENGTH_LONG).show();
    } else {
        BaseChannel.SendFileMessageHandler fileMessageHandler = new BaseChannel.SendFileMessageHandler() {
            @Override
            public void onSent(FileMessage fileMessage, SendBirdException e) {
                mMessageCollection.handleSendMessageResponse(fileMessage, e);
                mMessageCollection.fetchAllNextMessages(null);
                if (e != null) {
                    Log.d("MyTag", "onSent: " + getActivity());
                    if (getActivity() != null) {
                        Toast.makeText(getActivity(), getString(R.string.sendbird_error_with_code, e.getCode(), e.getMessage()), Toast.LENGTH_SHORT).show();
                    }
                }
            }
        };

        // Send image with thumbnails in the specified dimensions
        FileMessage tempFileMessage = mChannel.sendFileMessage(file, name, mime, size, "", null, thumbnailSizes, fileMessageHandler);

        mChatAdapter.addTempFileMessageInfo(tempFileMessage, uri);

        if (mMessageCollection != null) {
            mMessageCollection.appendMessage(tempFileMessage);
        }
    }
}
 
源代码14 项目: openjdk-systemtest   文件: NioApp.java
public void Compare(String p_CFHT_strFilename, Hashtable<Object, Integer> p_CFHT_htHashTable) {
	try {
		int nRecordNumber = 0;
		int nCount = 1;
		int nBufferLength = 12;
		int nKey;
		long lGetValue;
		long lCount;
		boolean blnKeyIsThere;
		Object objGetValue;
		Hashtable<Object, Integer> htHashTable = p_CFHT_htHashTable;

		System.out.println("I am comparing the file with the hashtable");
		// Get a channel for the file and provide a place
		// in memory to put the bytes with a buffer
		File f = new File(p_CFHT_strFilename);
		FileInputStream fis = new FileInputStream(f);
		FileChannel fc = fis.getChannel();
		ByteBuffer bb = java.nio.ByteBuffer.allocate(nBufferLength);

		// while we are not at the end of the file
		while (nCount != 0 && nCount != -1) {

			// Starting at byte number (nRecordNumber*nBufferLength)
			// read the next nBufferLength bytes from the file into
			// buffer bb and rewind to the beginning of the buffer
			nCount = fc.read(bb, nRecordNumber * nBufferLength);
			bb.rewind();

			// If we are not at the end of the file
			if (nCount != -1 && nCount != 0) {
				// Read the first 4 bytes and then the next 8 bytes and
				// print the results to the screen.
				nKey = bb.getInt();
				lCount = bb.getLong();

				// Checking the Hashtable to see if the random number is there
				blnKeyIsThere = htHashTable.containsKey(" " + nKey);

				// If the random number is there then get the value
				// associated with this
				// key. Compare this value with the occurences value in the
				// file. If they are
				// the same then increase the nMatches count, if they are
				// different print their
				// values to the screen and increase the differences count.
				// In each case
				// remove the key from the hashtable. If the random number
				// is not there
				// then print this to the screen also.
				if (blnKeyIsThere) {
					objGetValue = htHashTable.get(" " + nKey);
					lGetValue = Long.parseLong(objGetValue.toString());
					if (lCount == lGetValue) {
						nMatches++;
						htHashTable.remove(" " + nKey);
					} else {
						nOccurenceDiffs++;
						htHashTable.remove(" " + nKey);
					}
				} else {
					nNotInHashTable++;
				}
			}

			// clear the buffer and increment the nRecordNumber (this will
			// ensure the next 12 bytes are read into the buffer.
			bb.clear();
			nRecordNumber++;

		}

		// close the FileInputStream (this consequently closes the
		// FileChannel
		fis.close();

		// Check to see if there are any keys left in the hashtable. If
		// there aren't
		// then print all the results to the screen, if there are then
		// calculate how
		// many keys are left in the hashtable and print all the results to
		// the screen.
		if (htHashTable.isEmpty()) {
			nTotalDiffs = nOccurenceDiffs + nNotInHashTable;
		} else {
			nNotInFile = htHashTable.size();
			nTotalDiffs = nOccurenceDiffs + nNotInHashTable + nNotInFile;
		}
	} catch (IOException e) {
		System.out.println("Error occured in ComparingFileHashTable class: " + e);
	}
}
 
源代码15 项目: jdk1.8-source-analysis   文件: FeatureDescriptor.java
/**
 * Copies all values from the specified attribute table.
 * If some attribute is exist its value should be overridden.
 *
 * @param table  the attribute table with new values
 */
private void addTable(Hashtable<String, Object> table) {
    if ((table != null) && !table.isEmpty()) {
        getTable().putAll(table);
    }
}
 
源代码16 项目: hottub   文件: FeatureDescriptor.java
/**
 * Copies all values from the specified attribute table.
 * If some attribute is exist its value should be overridden.
 *
 * @param table  the attribute table with new values
 */
private void addTable(Hashtable<String, Object> table) {
    if ((table != null) && !table.isEmpty()) {
        getTable().putAll(table);
    }
}
 
源代码17 项目: TencentKona-8   文件: FeatureDescriptor.java
/**
 * Copies all values from the specified attribute table.
 * If some attribute is exist its value should be overridden.
 *
 * @param table  the attribute table with new values
 */
private void addTable(Hashtable<String, Object> table) {
    if ((table != null) && !table.isEmpty()) {
        getTable().putAll(table);
    }
}
 
源代码18 项目: Java8CN   文件: FeatureDescriptor.java
/**
 * Copies all values from the specified attribute table.
 * If some attribute is exist its value should be overridden.
 *
 * @param table  the attribute table with new values
 */
private void addTable(Hashtable<String, Object> table) {
    if ((table != null) && !table.isEmpty()) {
        getTable().putAll(table);
    }
}
 
源代码19 项目: openjdk-jdk8u   文件: FeatureDescriptor.java
/**
 * Copies all values from the specified attribute table.
 * If some attribute is exist its value should be overridden.
 *
 * @param table  the attribute table with new values
 */
private void addTable(Hashtable<String, Object> table) {
    if ((table != null) && !table.isEmpty()) {
        getTable().putAll(table);
    }
}
 
源代码20 项目: openjdk-jdk8u-backup   文件: FeatureDescriptor.java
/**
 * Copies all values from the specified attribute table.
 * If some attribute is exist its value should be overridden.
 *
 * @param table  the attribute table with new values
 */
private void addTable(Hashtable<String, Object> table) {
    if ((table != null) && !table.isEmpty()) {
        getTable().putAll(table);
    }
}