Esempio n. 1
0
 private static string[] finishSplit(java.util.List <string> list, string input, int
                                     begin, int maxSize, int limit)
 {
     // Add trailing text.
     if (begin < input.Length)
     {
         list.add(Sharpen.StringHelper.Substring(input, begin));
     }
     else
     {
         if (limit != 0)
         {
             // No point adding the empty string if limit == 0, just to remove it below.
             list.add(string.Empty);
         }
     }
     // Remove all trailing empty matches in the limit == 0 case.
     if (limit == 0)
     {
         int i = list.size() - 1;
         while (i >= 0 && string.IsNullOrEmpty(list.get(i)))
         {
             list.remove(i);
             i--;
         }
     }
     // Convert to an array.
     return(list.toArray(new string[list.size()]));
 }
Esempio n. 2
0
 /// <summary> Removes a Primitive from the container
 /// </summary>
 /// <param name="p">primitive to delete
 ///
 /// </param>
 public virtual void  removePrimitive(Primitive p)
 {
     if (p is ConnectorLine)
     {
         lines.remove(p);
     }
     if (p is Shape)
     {
         shapes.remove(p);
     }
     repaint();
 }
Esempio n. 3
0
 /**
  * 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);
     }
 }