/** * Utility method for implementations to set the map that backs * this bag. Not intended for interactive use outside of * subclasses. */ protected virtual void setMap(java.util.Map <Object, Object> map) { if (map == null || map.isEmpty() == false) { throw new java.lang.IllegalArgumentException("The map must be non-null and empty"); } _map = map; }
/** * Transforms a map. * <p> * The transformer itself may throw an exception if necessary. * * @param map the map to transform * @throws the transformed object */ protected virtual java.util.Map <Object, Object> transformMap(java.util.Map <Object, Object> map) { if (map.isEmpty()) { return(map); } java.util.Map <Object, Object> result = new LinkedMap(map.size()); for (java.util.Iterator <java.util.MapNS.Entry <Object, Object> > it = map.entrySet().iterator(); it.hasNext();) { java.util.MapNS.Entry <Object, Object> entry = it.next(); result.put(transformKey(entry.getKey()), transformValue(entry.getValue())); } return(result); }
/** * Creates an {@code AttributedString} from the given text and the * attributes. The whole text has the given attributes applied. * * @param value * the text to take as base for this attributed string. * @param attributes * the attributes that the text is associated with. * @throws IllegalArgumentException * if the length of {@code value} is 0 but the size of {@code * attributes} is greater than 0. * @throws NullPointerException * if {@code value} is {@code null}. */ public AttributedString(System.String value, java.util.Map <AttributedCharacterIteratorNS.Attribute, System.Object> attributes) { if (value == null) { throw new java.lang.NullPointerException(); } if (value.Length == 0 && !attributes.isEmpty()) { // text.0B=Cannot add attributes to empty string throw new java.lang.IllegalArgumentException("Cannot add attributes to empty string"); //$NON-NLS-1$ } text = value; attributeMap = new java.util.HashMap <AttributedCharacterIteratorNS.Attribute, java.util.List <IAC_Range> >();//(attributes.size() * 4 / 3) + 1); java.util.Iterator <java.util.MapNS.Entry <AttributedCharacterIteratorNS.Attribute, System.Object> > it = attributes.entrySet().iterator(); while (it.hasNext()) { java.util.MapNS.Entry <AttributedCharacterIteratorNS.Attribute, System.Object> entry = it.next(); java.util.ArrayList <IAC_Range> ranges = new java.util.ArrayList <IAC_Range>(1); ranges.add(new IAC_Range(0, text.Length, entry.getValue())); attributeMap.put((AttributedCharacterIteratorNS.Attribute)entry .getKey(), ranges); } }
public virtual bool isEmpty() { return(map.isEmpty()); }
public bool isEmpty() { return(map.isEmpty()); }
public bool hasTokenFrequencyInfo() { return(tokenFrequency != null && !tokenFrequency.isEmpty()); }
/** * Returns the array of providers which meet the user supplied set of * filters. The filter must be supplied in one of two formats: * <nl> * <li> CRYPTO_SERVICE_NAME.ALGORITHM_OR_TYPE</li> * <p/> * for example: "MessageDigest.SHA" The value associated with the key must * be an empty string. <li> CRYPTO_SERVICE_NAME.ALGORITHM_OR_TYPE</li> * ATTR_NAME:ATTR_VALUE * <p/> * for example: "Signature.MD2withRSA KeySize:512" where "KeySize:512" is * the value of the filter map entry. * </nl> * * @param filter * case-insensitive filter. * @return the providers which meet the user supplied string filter {@code * filter}. A {@code null} value signifies that none of the * installed providers meets the filter specification. * @throws InvalidParameterException * if an unusable filter is supplied. * @throws NullPointerException * if {@code filter} is {@code null}. */ public static Provider[] getProviders(java.util.Map <String, String> filter) { lock (lockJ) { if (filter == null) { throw new java.lang.NullPointerException("The filter is null"); //$NON-NLS-1$ } if (filter.isEmpty()) { return(null); } java.util.List <Provider> result = Services.getProvidersList(); java.util.Set <java.util.MapNS.Entry <String, String> > keys = filter.entrySet(); java.util.MapNS.Entry <String, String> entry; for (java.util.Iterator <java.util.MapNS.Entry <String, String> > it = keys.iterator(); it.hasNext();) { entry = it.next(); String key = entry.getKey(); String val = entry.getValue(); String attribute = null; int i = key.indexOf(' '); int j = key.indexOf('.'); if (j == -1) { throw new InvalidParameterException("The filter is not in the required format"); //$NON-NLS-1$ } if (i == -1) { // <crypto_service>.<algorithm_or_type> if (val.length() != 0) { throw new InvalidParameterException("The filter is not in the required format"); //$NON-NLS-1$ } } else { // <crypto_service>.<algorithm_or_type> <attribute_name> if (val.length() == 0) { throw new InvalidParameterException("The filter is not in the required format"); //$NON-NLS-1$ } attribute = key.substring(i + 1); if (attribute.trim().length() == 0) { throw new InvalidParameterException("The filter is not in the required format"); //$NON-NLS-1$ } key = key.substring(0, i); } String serv = key.substring(0, j); String alg = key.substring(j + 1); if (serv.length() == 0 || alg.length() == 0) { throw new InvalidParameterException("The filter is not in the required format"); //$NON-NLS-1$ } Provider p; for (int k = 0; k < result.size(); k++) { try { p = result.get(k); } catch (java.lang.IndexOutOfBoundsException) { break; } if (!p.implementsAlg(serv, alg, attribute, val)) { result.remove(p); k--; } } } if (result.size() > 0) { return(result.toArray(new Provider[result.size()])); } return(null); } }