426 */
427 public Name addAll(List<Rdn> suffixRdns) {
428 return addAll(size(), suffixRdns);
429 }
430
431 /**
432 * Adds the components of a name -- in order -- at a specified position
433 * within this name. Components of this LDAP name at or after the
434 * index (if any) of the first new component are shifted up
435 * (away from index 0) to accomodate the new components.
436 *
437 * @param suffix The non-null components to add.
438 * @param posn The index at which to add the new component.
439 * Must be in the range [0,size()].
440 *
441 * @return The updated name (not a new instance).
442 *
443 * @throws InvalidNameException if <tt>suffix</tt> is not a valid LDAP
444 * name, or if the addition of the components would violate the
445 * syntax rules of this LDAP name.
446 * @throws IndexOutOfBoundsException.
447 * If posn is outside the specified range.
448 */
449 public Name addAll(int posn, Name suffix)
450 throws InvalidNameException {
451 unparsed = null; // no longer valid
452 if (suffix instanceof LdapName) {
453 LdapName s = (LdapName) suffix;
454 rdns.addAll(posn, s.rdns);
455 } else {
456 Enumeration<String> comps = suffix.getAll();
457 while (comps.hasMoreElements()) {
458 rdns.add(posn++,
459 (new Rfc2253Parser(comps.nextElement()).
460 parseRdn()));
461 }
462 }
463 return this;
464 }
465
466 /**
467 * Adds the RDNs of a name -- in order -- at a specified position
468 * within this name. RDNs of this LDAP name at or after the
469 * index (if any) of the first new RDN are shifted up (away from index 0) to
470 * accomodate the new RDNs.
471 *
472 * @param suffixRdns The non-null suffix <tt>Rdn</tt>s to add.
473 * @param posn The index at which to add the suffix RDNs.
474 * Must be in the range [0,size()].
475 *
476 * @return The updated name (not a new instance).
477 * @throws IndexOutOfBoundsException.
478 * If posn is outside the specified range.
479 */
480 public Name addAll(int posn, List<Rdn> suffixRdns) {
481 unparsed = null;
482 for (int i = 0; i < suffixRdns.size(); i++) {
483 Object obj = suffixRdns.get(i);
484 if (!(obj instanceof Rdn)) {
485 throw new IllegalArgumentException("Entry:" + obj +
486 " not a valid type;suffix list entries must be of type Rdn");
487 }
488 rdns.add(i + posn, (Rdn)obj);
489 }
490 return this;
491 }
492
493 /**
494 * Adds a single component to the end of this LDAP name.
495 *
496 * @param comp The non-null component to add.
497 * @return The updated LdapName, not a new instance.
510 *
511 * @return The updated LdapName, not a new instance.
512 * Cannot be null.
513 */
514 public Name add(Rdn comp) {
515 return add(size(), comp);
516 }
517
518 /**
519 * Adds a single component at a specified position within this
520 * LDAP name.
521 * Components of this LDAP name at or after the index (if any) of the new
522 * component are shifted up by one (away from index 0) to accommodate
523 * the new component.
524 *
525 * @param comp The non-null component to add.
526 * @param posn The index at which to add the new component.
527 * Must be in the range [0,size()].
528 * @return The updated LdapName, not a new instance.
529 * Cannot be null.
530 * @exception IndexOutOfBoundsException.
531 * If posn is outside the specified range.
532 * @exception InvalidNameException If adding comp at the
533 * specified position would violate the name's syntax.
534 */
535 public Name add(int posn, String comp) throws InvalidNameException {
536 Rdn rdn = (new Rfc2253Parser(comp)).parseRdn();
537 rdns.add(posn, rdn);
538 unparsed = null; // no longer valid
539 return this;
540 }
541
542 /**
543 * Adds a single RDN at a specified position within this
544 * LDAP name.
545 * RDNs of this LDAP name at or after the index (if any) of the new
546 * RDN are shifted up by one (away from index 0) to accommodate
547 * the new RDN.
548 *
549 * @param comp The non-null RDN to add.
550 * @param posn The index at which to add the new RDN.
|
426 */
427 public Name addAll(List<Rdn> suffixRdns) {
428 return addAll(size(), suffixRdns);
429 }
430
431 /**
432 * Adds the components of a name -- in order -- at a specified position
433 * within this name. Components of this LDAP name at or after the
434 * index (if any) of the first new component are shifted up
435 * (away from index 0) to accomodate the new components.
436 *
437 * @param suffix The non-null components to add.
438 * @param posn The index at which to add the new component.
439 * Must be in the range [0,size()].
440 *
441 * @return The updated name (not a new instance).
442 *
443 * @throws InvalidNameException if <tt>suffix</tt> is not a valid LDAP
444 * name, or if the addition of the components would violate the
445 * syntax rules of this LDAP name.
446 * @throws IndexOutOfBoundsException
447 * If posn is outside the specified range.
448 */
449 public Name addAll(int posn, Name suffix)
450 throws InvalidNameException {
451 unparsed = null; // no longer valid
452 if (suffix instanceof LdapName) {
453 LdapName s = (LdapName) suffix;
454 rdns.addAll(posn, s.rdns);
455 } else {
456 Enumeration<String> comps = suffix.getAll();
457 while (comps.hasMoreElements()) {
458 rdns.add(posn++,
459 (new Rfc2253Parser(comps.nextElement()).
460 parseRdn()));
461 }
462 }
463 return this;
464 }
465
466 /**
467 * Adds the RDNs of a name -- in order -- at a specified position
468 * within this name. RDNs of this LDAP name at or after the
469 * index (if any) of the first new RDN are shifted up (away from index 0) to
470 * accomodate the new RDNs.
471 *
472 * @param suffixRdns The non-null suffix <tt>Rdn</tt>s to add.
473 * @param posn The index at which to add the suffix RDNs.
474 * Must be in the range [0,size()].
475 *
476 * @return The updated name (not a new instance).
477 * @throws IndexOutOfBoundsException
478 * If posn is outside the specified range.
479 */
480 public Name addAll(int posn, List<Rdn> suffixRdns) {
481 unparsed = null;
482 for (int i = 0; i < suffixRdns.size(); i++) {
483 Object obj = suffixRdns.get(i);
484 if (!(obj instanceof Rdn)) {
485 throw new IllegalArgumentException("Entry:" + obj +
486 " not a valid type;suffix list entries must be of type Rdn");
487 }
488 rdns.add(i + posn, (Rdn)obj);
489 }
490 return this;
491 }
492
493 /**
494 * Adds a single component to the end of this LDAP name.
495 *
496 * @param comp The non-null component to add.
497 * @return The updated LdapName, not a new instance.
510 *
511 * @return The updated LdapName, not a new instance.
512 * Cannot be null.
513 */
514 public Name add(Rdn comp) {
515 return add(size(), comp);
516 }
517
518 /**
519 * Adds a single component at a specified position within this
520 * LDAP name.
521 * Components of this LDAP name at or after the index (if any) of the new
522 * component are shifted up by one (away from index 0) to accommodate
523 * the new component.
524 *
525 * @param comp The non-null component to add.
526 * @param posn The index at which to add the new component.
527 * Must be in the range [0,size()].
528 * @return The updated LdapName, not a new instance.
529 * Cannot be null.
530 * @exception IndexOutOfBoundsException
531 * If posn is outside the specified range.
532 * @exception InvalidNameException If adding comp at the
533 * specified position would violate the name's syntax.
534 */
535 public Name add(int posn, String comp) throws InvalidNameException {
536 Rdn rdn = (new Rfc2253Parser(comp)).parseRdn();
537 rdns.add(posn, rdn);
538 unparsed = null; // no longer valid
539 return this;
540 }
541
542 /**
543 * Adds a single RDN at a specified position within this
544 * LDAP name.
545 * RDNs of this LDAP name at or after the index (if any) of the new
546 * RDN are shifted up by one (away from index 0) to accommodate
547 * the new RDN.
548 *
549 * @param comp The non-null RDN to add.
550 * @param posn The index at which to add the new RDN.
|