size ( )源码实例Demo

java.util.Dictionary#size ( )源码实例Demo

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

源代码1 项目: sling-whiteboard   文件: FrameworkUtil.java
/**
 * Create a case insensitive map from the specified dictionary.
 * 
 * @param dictionary
 * @throws IllegalArgumentException If {@code dictionary} contains case
 *         variants of the same key name.
 */
CaseInsensitiveMap(Dictionary<String, ?> dictionary) {
	if (dictionary == null) {
		this.dictionary = null;
		this.keys = new String[0];
		return;
	}
	this.dictionary = dictionary;
	List<String> keyList = new ArrayList<String>(dictionary.size());
	for (Enumeration<?> e = dictionary.keys(); e.hasMoreElements();) {
		Object k = e.nextElement();
		if (k instanceof String) {
			String key = (String) k;
			for (String i : keyList) {
				if (key.equalsIgnoreCase(i)) {
					throw new IllegalArgumentException();
				}
			}
			keyList.add(key);
		}
	}
	this.keys = keyList.toArray(new String[0]);
}
 
源代码2 项目: concierge   文件: EventProperties.java
/**
 * Create an EventProperties from the specified dictionary.
 * 
 * <p>
 * The specified properties will be copied into this EventProperties.
 * Properties whose key is not of type {@code String} will be ignored. A
 * property with the key &quot;event.topics&quot; will be ignored.
 * 
 * @param properties The properties to use for this EventProperties object
 *        (may be {@code null}).
 */
EventProperties(Dictionary<String, ?> properties) {
	int size = (properties == null) ? 0 : properties.size();
	Map<String, Object> p = new HashMap<String, Object>(size);
	if (size > 0) {
		for (Enumeration<?> e = properties.keys(); e.hasMoreElements();) {
			Object key = e.nextElement();
			if ((key instanceof String) && !EVENT_TOPIC.equals(key)) {
				Object value = properties.get(key);
				p.put((String) key, value);
			}
		}
	}
	// safely publish the map
	this.properties = Collections.unmodifiableMap(p);
}
 
源代码3 项目: concierge   文件: FrameworkUtil.java
/**
 * Create a case insensitive map from the specified dictionary.
 * 
 * @param dictionary
 * @throws IllegalArgumentException If {@code dictionary} contains case
 *         variants of the same key name.
 */
CaseInsensitiveMap(Dictionary<String, ?> dictionary) {
	if (dictionary == null) {
		this.dictionary = null;
		this.keys = new String[0];
		return;
	}
	this.dictionary = dictionary;
	List<String> keyList = new ArrayList<String>(dictionary.size());
	for (Enumeration<?> e = dictionary.keys(); e.hasMoreElements();) {
		Object k = e.nextElement();
		if (k instanceof String) {
			String key = (String) k;
			for (String i : keyList) {
				if (key.equalsIgnoreCase(i)) {
					throw new IllegalArgumentException();
				}
			}
			keyList.add(key);
		}
	}
	this.keys = keyList.toArray(new String[keyList.size()]);
}
 
源代码4 项目: knopflerfish.org   文件: EventProperties.java
/**
 * Create an EventProperties from the specified dictionary.
 * 
 * <p>
 * The specified properties will be copied into this EventProperties.
 * Properties whose key is not of type {@code String} will be ignored. A
 * property with the key &quot;event.topics&quot; will be ignored.
 * 
 * @param properties The properties to use for this EventProperties object
 *        (may be {@code null}).
 */
EventProperties(Dictionary<String, ?> properties) {
	int size = (properties == null) ? 0 : properties.size();
	Map<String, Object> p = new HashMap<String, Object>(size);
	if (size > 0) {
		for (Enumeration<?> e = properties.keys(); e.hasMoreElements();) {
			Object key = e.nextElement();
			if ((key instanceof String) && !EVENT_TOPIC.equals(key)) {
				Object value = properties.get(key);
				p.put((String) key, value);
			}
		}
	}
	// safely publish the map
	this.properties = Collections.unmodifiableMap(p);
}
 
源代码5 项目: knopflerfish.org   文件: CMCommands.java
private void printDictionary(PrintWriter out,
                             Dictionary<String, Object> d,
                             boolean printTypes)
{
  final String[] keyNames = new String[d.size()];
  int i = 0;
  for (final Enumeration<String> keys = d.keys(); keys.hasMoreElements();) {
    keyNames[i++] = keys.nextElement();
  }
  Sort.sortStringArray(keyNames);
  for (i = 0; i < keyNames.length; i++) {
    out.print("  ");
    out.print(keyNames[i]);

    final Object value = d.get(keyNames[i]);
    if (printTypes) {
      out.print(":");
      printValueType(out, value);
    }

    out.print("= ");
    printValue(out, value);
    out.println();
  }
}
 
源代码6 项目: knopflerfish.org   文件: FrameworkUtil.java
/**
 * Create a case insensitive map from the specified dictionary.
 * 
 * @param dictionary
 * @throws IllegalArgumentException If {@code dictionary} contains case
 *         variants of the same key name.
 */
CaseInsensitiveMap(Dictionary<String, ?> dictionary) {
	if (dictionary == null) {
		this.dictionary = null;
		this.keys = new String[0];
		return;
	}
	this.dictionary = dictionary;
	List<String> keyList = new ArrayList<String>(dictionary.size());
	for (Enumeration<?> e = dictionary.keys(); e.hasMoreElements();) {
		Object k = e.nextElement();
		if (k instanceof String) {
			String key = (String) k;
			for (String i : keyList) {
				if (key.equalsIgnoreCase(i)) {
					throw new IllegalArgumentException();
				}
			}
			keyList.add(key);
		}
	}
	this.keys = keyList.toArray(new String[keyList.size()]);
}
 
源代码7 项目: gemfirexd-oss   文件: PropertyConglomerate.java
void savePropertyDefault(TransactionController tc, String key, Serializable value)
	 throws StandardException
{
	if (saveServiceProperty(key,value)) return;

	Dictionary defaults = (Dictionary)readProperty(tc,AccessFactoryGlobals.DEFAULT_PROPERTY_NAME);
	if (defaults == null) defaults = new FormatableHashtable();
	if (value==null)
		defaults.remove(key);
	else
		defaults.put(key,value);
	if (defaults.size() == 0) defaults = null;
	saveProperty(tc,AccessFactoryGlobals.DEFAULT_PROPERTY_NAME,(Serializable)defaults);
}
 
源代码8 项目: concierge   文件: AbstractOSGiResource.java
protected Map<String, String> mapFromDict(
		final Dictionary<String, String> headers) {
	final HashMap<String, String> map = new HashMap<String, String>(
			headers.size());
	final Enumeration<String> keyE = headers.keys();
	while (keyE.hasMoreElements()) {
		final String key = keyE.nextElement();
		map.put(key, headers.get(key));
	}
	return map;
}
 
源代码9 项目: openhab-core   文件: ConfigurationService.java
private @Nullable Configuration toConfiguration(Dictionary<String, Object> dictionary) {
    if (dictionary == null) {
        return null;
    }
    Map<String, Object> properties = new HashMap<>(dictionary.size());
    Enumeration<String> keys = dictionary.keys();
    while (keys.hasMoreElements()) {
        String key = keys.nextElement();
        if (!Constants.SERVICE_PID.equals(key)) {
            properties.put(key, dictionary.get(key));
        }
    }
    return new Configuration(properties);
}
 
源代码10 项目: knopflerfish.org   文件: RequestImpl.java
@Override
public Cookie[] getCookies()
{
  Dictionary<String, Cloneable> d;
  if (cookies == null && !(d = base.getCookies()).isEmpty()) {
    cookies = new Cookie[d.size()];
    final Enumeration<Cloneable> e = d.elements();
    for (int i = 0; i < cookies.length; i++) {
      cookies[i] = (Cookie) e.nextElement();
    }
  }

  return cookies;
}
 
源代码11 项目: knopflerfish.org   文件: PropertiesDictionary.java
PropertiesDictionary(@SuppressWarnings("rawtypes") Dictionary in,
                     String[] classes, Long sid, Long bid, String scope)
{
  final int max_size = (in != null ? in.size() : 0) + size;
  keys = new String[max_size];
  values = new Object[max_size];
  keys[ocIndex] = Constants.OBJECTCLASS;
  values[ocIndex] = classes;
  keys[sidIndex] = Constants.SERVICE_ID;
  values[sidIndex] = sid != null ? sid : new Long(nextServiceID++);
  keys[sbidIndex] = Constants.SERVICE_BUNDLEID;
  values[sbidIndex] = bid;
  keys[ssIndex] = Constants.SERVICE_SCOPE;
  values[ssIndex] = scope;
  if (in != null) {
    try {
      for (@SuppressWarnings("rawtypes")
      final Enumeration e = in.keys(); e.hasMoreElements();) {
        final String key = (String) e.nextElement();
        if (!key.equalsIgnoreCase(Constants.OBJECTCLASS) &&
            !key.equalsIgnoreCase(Constants.SERVICE_ID) &&
            !key.equalsIgnoreCase(Constants.SERVICE_BUNDLEID) &&
            !key.equalsIgnoreCase(Constants.SERVICE_SCOPE)) {
          for (int i = size - 1; i >= 0; i--) {
            if (key.equalsIgnoreCase(keys[i])) {
              throw new IllegalArgumentException(
                                                 "Several entries for property: "
                                                     + key);
            }
          }
          keys[size] = key;
          values[size++] = in.get(key);
        }
      }
    } catch (final ClassCastException ignore) {
      throw new IllegalArgumentException(
                                         "Properties contains key that is not of type java.lang.String");
    }
  }
}
 
源代码12 项目: gemfirexd-oss   文件: PropertyConglomerate.java
void savePropertyDefault(TransactionController tc, String key, Serializable value)
	 throws StandardException
{
	if (saveServiceProperty(key,value)) return;

	Dictionary defaults = (Dictionary)readProperty(tc,AccessFactoryGlobals.DEFAULT_PROPERTY_NAME);
	if (defaults == null) defaults = new FormatableHashtable();
	if (value==null)
		defaults.remove(key);
	else
		defaults.put(key,value);
	if (defaults.size() == 0) defaults = null;
	saveProperty(tc,AccessFactoryGlobals.DEFAULT_PROPERTY_NAME,(Serializable)defaults);
}
 
源代码13 项目: packagedrone   文件: Dictionaries.java
public static Hashtable<String, Object> copy ( final Dictionary<String, ?> properties )
{
    final Hashtable<String, Object> newProps = new Hashtable<> ( properties.size () );
    final Enumeration<String> en = properties.keys ();
    while ( en.hasMoreElements () )
    {
        final String key = en.nextElement ();
        newProps.put ( key, properties.get ( key ) );
    }
    return newProps;
}
 
源代码14 项目: AtlasForAndroid   文件: ServiceReferenceImpl.java
ServiceReferenceImpl(Bundle bundle, Object obj, Dictionary<String, ?> dictionary, String[] strArr) {
    this.useCounters = new HashMap(0);
    this.cachedServices = null;
    if (obj instanceof ServiceFactory) {
        this.isServiceFactory = true;
    } else {
        this.isServiceFactory = false;
        checkService(obj, strArr);
    }
    this.bundle = bundle;
    this.service = obj;
    this.properties = dictionary == null ? new Hashtable() : new Hashtable(dictionary.size());
    if (dictionary != null) {
        Enumeration keys = dictionary.keys();
        while (keys.hasMoreElements()) {
            String str = (String) keys.nextElement();
            this.properties.put(str, dictionary.get(str));
        }
    }
    this.properties.put(Constants.OBJECTCLASS, strArr);
    Dictionary dictionary2 = this.properties;
    String str2 = Constants.SERVICE_ID;
    long j = nextServiceID + 1;
    nextServiceID = j;
    dictionary2.put(str2, Long.valueOf(j));
    Integer num = dictionary == null ? null : (Integer) dictionary.get(Constants.SERVICE_RANKING);
    this.properties.put(Constants.SERVICE_RANKING, Integer.valueOf(num == null ? 0 : num.intValue()));
    this.registration = new ServiceRegistrationImpl();
}
 
源代码15 项目: smarthome   文件: ConfigurationService.java
private Configuration toConfiguration(Dictionary<String, Object> dictionary) {
    if (dictionary == null) {
        return null;
    }
    Map<String, Object> properties = new HashMap<>(dictionary.size());
    Enumeration<String> keys = dictionary.keys();
    while (keys.hasMoreElements()) {
        String key = keys.nextElement();
        if (!key.equals(Constants.SERVICE_PID)) {
            properties.put(key, dictionary.get(key));
        }
    }
    return new Configuration(properties);
}
 
/**
 * It happends that the factory get called with properties that only contain
 * service.pid and service.factoryPid. If that happens we don't want to create
 * an engine.
 * 
 * @param properties
 * @return
 */
@SuppressWarnings("unchecked")
private boolean hasPropertiesConfiguration(Dictionary properties) {
  HashMap<Object, Object> mapProperties = new HashMap<Object, Object>(properties.size());
  for (Object key : Collections.list(properties.keys())) {
    mapProperties.put(key, properties.get(key));
  }
  mapProperties.remove(Constants.SERVICE_PID);
  mapProperties.remove("service.factoryPid");
  return !mapProperties.isEmpty();
}
 
源代码17 项目: openhab1-addons   文件: MqttitudeBinding.java
/**
 * {@inheritDoc}
 */
@Override
public void updated(Dictionary<String, ?> properties) throws ConfigurationException {
    // no mandatory binding properties - so fine to get nothing here
    if (properties == null || properties.size() == 0) {
        return;
    }

    float homeLat = Float.parseFloat(getOptionalProperty(properties, "home.lat", "0"));
    float homeLon = Float.parseFloat(getOptionalProperty(properties, "home.lon", "0"));

    if (homeLat == 0 || homeLon == 0) {
        homeLocation = null;
        geoFence = 0;
        logger.debug(
                "Mqttitude binding configuration updated, no 'home' location specified. All item bindings must be configured with a <region>.");
    } else {
        homeLocation = new Location(homeLat, homeLon);
        geoFence = Float.parseFloat(getOptionalProperty(properties, "geofence", "100"));
        logger.debug(
                "Mqttitude binding configuration updated, 'home' location specified ({}) with a geofence of {}m.",
                homeLocation.toString(), geoFence);
    }

    // need to re-register all the consumers/topics if the home location has changed
    unregisterAll();
    registerAll();
}
 
源代码18 项目: concierge   文件: ServiceReferenceImpl.java
/**
 * create a new service reference implementation instance.
 * 
 * @param bundle
 *            the bundle.
 * @param service
 *            the service object.
 * @param props
 *            the service properties.
 * @param clazzes
 *            the interface classes that the service is registered under.
 * @throws ClassNotFoundException
 */
ServiceReferenceImpl(final Concierge framework, final Bundle bundle,
		final S service, final Dictionary<String, ?> props,
		final String[] clazzes) {
	String scope = "singleton";
	if (service instanceof PrototypeServiceFactory) {
		isServiceFactory = true;
		isPrototype = true;
		scope = "prototype";
	} else if(service instanceof ServiceFactory) {
		isServiceFactory = true;
		isPrototype = false;
		scope = "bundle";
	} else {
		isServiceFactory = false;
		isPrototype = false;
		checkService(service, clazzes);
	}

	this.framework = framework;
	this.bundle = bundle;
	this.service = service;
	this.properties = new HashMap<String, Object>(props == null ? 5
			: props.size() + 5);
	if (props != null) {
		for (final Enumeration<String> keys = props.keys(); keys
				.hasMoreElements();) {
			final String key = keys.nextElement();
			properties.put(key, props.get(key));
		}
	}
	properties.put(Constants.OBJECTCLASS, clazzes);
	properties.put(Constants.SERVICE_BUNDLEID, bundle.getBundleId());
	properties.put(Constants.SERVICE_ID, new Long(++nextServiceID));
	final Integer ranking = props == null ? null : (Integer) props
			.get(Constants.SERVICE_RANKING);
	properties.put(Constants.SERVICE_RANKING,
			ranking == null ? new Integer(0) : ranking);
	properties.put(Constants.SERVICE_SCOPE, scope);
	this.registration = new ServiceRegistrationImpl();
}
 
源代码19 项目: knopflerfish.org   文件: DictionaryUtils.java
static private boolean sizeIsNotEqual(Dictionary<?, ?> first,
                                      Dictionary<?, ?> second)
{
  return first.size() != second.size();
}
 
源代码20 项目: flex-blazeds   文件: DictionaryProxy.java
public List getPropertyNames(Object instance)
{
    if (instance == null)
        return null;

    List propertyNames = null;
    List excludes = null;

    if (descriptor != null)
    {
        excludes = descriptor.getExcludesForInstance(instance);
        if (excludes == null)
            excludes = descriptor.getExcludes();
    }

    // Add all Dictionary keys as properties
    if (instance instanceof Dictionary)
    {
        Dictionary dictionary = (Dictionary)instance;

        propertyNames = new ArrayList(dictionary.size());

        Enumeration keys = dictionary.keys();
        while (keys.hasMoreElements())
        {
            Object key = keys.nextElement();
            if (key != null)
            {
                if (excludes != null && excludes.contains(key))
                    continue;

                propertyNames.add(key.toString());
            }
        }
    }

    // Then, check for bean properties
    List beanProperties = super.getPropertyNames(instance);
    if (propertyNames == null)
    {
        propertyNames = beanProperties;
    }
    else
    {
        propertyNames.addAll(beanProperties);
    }

    return propertyNames;
}
 
源代码评论
动弹
沙发等你来抢
 方法所在类