Exemplo n.º 1
0
  /**
   * Removes the {@code Provider} with the specified name form the collection of providers. If the
   * the {@code Provider} with the specified name is removed, all provider at a greater position are
   * shifted down one position.
   *
   * <p>Returns silently if {@code name} is {@code null} or no provider with the specified name is
   * installed.
   *
   * @param name the name of the provider to remove.
   */
  public static synchronized void removeProvider(String name) {
    // It is not clear from spec.:
    // 1. if name is null, should we checkSecurityAccess or not?
    //    throw SecurityException or not?
    // 2. as 1 but provider is not installed
    // 3. behavior if name is empty string?

    Provider p;
    if ((name == null) || (name.length() == 0)) {
      return;
    }
    p = getProvider(name);
    if (p == null) {
      return;
    }
    Services.removeProvider(p.getProviderNumber());
    renumProviders();
    p.setProviderNumber(-1);
  }