377 * @exception ArrayIndexOutOfBoundsException if posn is outside the
378 * specified range.
379 */
380 public String get(int posn) {
381 return (impl.get(posn));
382 }
383
384 /**
385 * Creates a composite name whose components consist of a prefix of the
386 * components in this composite name. Subsequent changes to
387 * this composite name does not affect the name that is returned.
388 *
389 * @param posn The 0-based index of the component at which to stop.
390 * Must be in the range [0,size()].
391 * @return A composite name consisting of the components at indexes in
392 * the range [0,posn).
393 * @exception ArrayIndexOutOfBoundsException
394 * If posn is outside the specified range.
395 */
396 public Name getPrefix(int posn) {
397 Enumeration comps = impl.getPrefix(posn);
398 return (new CompositeName(comps));
399 }
400
401 /**
402 * Creates a composite name whose components consist of a suffix of the
403 * components in this composite name. Subsequent changes to
404 * this composite name does not affect the name that is returned.
405 *
406 * @param posn The 0-based index of the component at which to start.
407 * Must be in the range [0,size()].
408 * @return A composite name consisting of the components at indexes in
409 * the range [posn,size()). If posn is equal to
410 * size(), an empty composite name is returned.
411 * @exception ArrayIndexOutOfBoundsException
412 * If posn is outside the specified range.
413 */
414 public Name getSuffix(int posn) {
415 Enumeration comps = impl.getSuffix(posn);
416 return (new CompositeName(comps));
417 }
418
419 /**
420 * Determines whether a composite name is a prefix of this composite name.
421 * A composite name 'n' is a prefix if it is equal to
422 * getPrefix(n.size())--in other words, this composite name
423 * starts with 'n'. If 'n' is null or not a composite name, false is returned.
424 *
425 * @param n The possibly null name to check.
426 * @return true if n is a CompositeName and
427 * is a prefix of this composite name, false otherwise.
428 */
429 public boolean startsWith(Name n) {
430 if (n instanceof CompositeName) {
431 return (impl.startsWith(n.size(), n.getAll()));
432 } else {
433 return false;
434 }
435 }
546 * Must be in the range [0,size()).
547 * @return The component removed (a String).
548 * @exception ArrayIndexOutOfBoundsException
549 * If posn is outside the specified range (includes case where
550 * composite name is empty).
551 * @exception InvalidNameException If deleting the component
552 * would violate the name's syntax.
553 */
554 public Object remove(int posn) throws InvalidNameException{
555 return impl.remove(posn);
556 }
557
558 /**
559 * Overridden to avoid implementation dependency.
560 * @serialData The number of components (an <tt>int</tt>) followed by
561 * the individual components (each a <tt>String</tt>).
562 */
563 private void writeObject(java.io.ObjectOutputStream s)
564 throws java.io.IOException {
565 s.writeInt(size());
566 Enumeration comps = getAll();
567 while (comps.hasMoreElements()) {
568 s.writeObject(comps.nextElement());
569 }
570 }
571
572 /**
573 * Overridden to avoid implementation dependency.
574 */
575 private void readObject(java.io.ObjectInputStream s)
576 throws java.io.IOException, ClassNotFoundException {
577 impl = new NameImpl(null); // null means use default syntax
578 int n = s.readInt(); // number of components
579 try {
580 while (--n >= 0) {
581 add((String)s.readObject());
582 }
583 } catch (InvalidNameException e) {
584 throw (new java.io.StreamCorruptedException("Invalid name"));
585 }
586 }
|
377 * @exception ArrayIndexOutOfBoundsException if posn is outside the
378 * specified range.
379 */
380 public String get(int posn) {
381 return (impl.get(posn));
382 }
383
384 /**
385 * Creates a composite name whose components consist of a prefix of the
386 * components in this composite name. Subsequent changes to
387 * this composite name does not affect the name that is returned.
388 *
389 * @param posn The 0-based index of the component at which to stop.
390 * Must be in the range [0,size()].
391 * @return A composite name consisting of the components at indexes in
392 * the range [0,posn).
393 * @exception ArrayIndexOutOfBoundsException
394 * If posn is outside the specified range.
395 */
396 public Name getPrefix(int posn) {
397 Enumeration<String> comps = impl.getPrefix(posn);
398 return (new CompositeName(comps));
399 }
400
401 /**
402 * Creates a composite name whose components consist of a suffix of the
403 * components in this composite name. Subsequent changes to
404 * this composite name does not affect the name that is returned.
405 *
406 * @param posn The 0-based index of the component at which to start.
407 * Must be in the range [0,size()].
408 * @return A composite name consisting of the components at indexes in
409 * the range [posn,size()). If posn is equal to
410 * size(), an empty composite name is returned.
411 * @exception ArrayIndexOutOfBoundsException
412 * If posn is outside the specified range.
413 */
414 public Name getSuffix(int posn) {
415 Enumeration<String> comps = impl.getSuffix(posn);
416 return (new CompositeName(comps));
417 }
418
419 /**
420 * Determines whether a composite name is a prefix of this composite name.
421 * A composite name 'n' is a prefix if it is equal to
422 * getPrefix(n.size())--in other words, this composite name
423 * starts with 'n'. If 'n' is null or not a composite name, false is returned.
424 *
425 * @param n The possibly null name to check.
426 * @return true if n is a CompositeName and
427 * is a prefix of this composite name, false otherwise.
428 */
429 public boolean startsWith(Name n) {
430 if (n instanceof CompositeName) {
431 return (impl.startsWith(n.size(), n.getAll()));
432 } else {
433 return false;
434 }
435 }
546 * Must be in the range [0,size()).
547 * @return The component removed (a String).
548 * @exception ArrayIndexOutOfBoundsException
549 * If posn is outside the specified range (includes case where
550 * composite name is empty).
551 * @exception InvalidNameException If deleting the component
552 * would violate the name's syntax.
553 */
554 public Object remove(int posn) throws InvalidNameException{
555 return impl.remove(posn);
556 }
557
558 /**
559 * Overridden to avoid implementation dependency.
560 * @serialData The number of components (an <tt>int</tt>) followed by
561 * the individual components (each a <tt>String</tt>).
562 */
563 private void writeObject(java.io.ObjectOutputStream s)
564 throws java.io.IOException {
565 s.writeInt(size());
566 Enumeration<String> comps = getAll();
567 while (comps.hasMoreElements()) {
568 s.writeObject(comps.nextElement());
569 }
570 }
571
572 /**
573 * Overridden to avoid implementation dependency.
574 */
575 private void readObject(java.io.ObjectInputStream s)
576 throws java.io.IOException, ClassNotFoundException {
577 impl = new NameImpl(null); // null means use default syntax
578 int n = s.readInt(); // number of components
579 try {
580 while (--n >= 0) {
581 add((String)s.readObject());
582 }
583 } catch (InvalidNameException e) {
584 throw (new java.io.StreamCorruptedException("Invalid name"));
585 }
586 }
|