* @return The updated CompoundName, not a new one. Cannot be null. * @exception InvalidNameException If adding comp at end of the name * would violate the compound name's syntax. */ public Name add(String comp) throws InvalidNameException{ impl.add(comp); return this; } /** * Adds a single component at a specified position within this * compound name. * Components of this compound name at or after the index of the new * component are shifted up by one (away from index 0) * to accommodate the new component. * * @param comp The non-null component to add. * @param posn The index at which to add the new component. * Must be in the range [0,size()]. * @exception ArrayIndexOutOfBoundsException * If posn is outside the specified range. * @return The updated CompoundName, not a new one. Cannot be null. * @exception InvalidNameException If adding comp at the specified position * would violate the compound name's syntax. */ public Name add(int posn, String comp) throws InvalidNameException{ impl.add(posn, comp); return this; } /** * Deletes a component from this compound name. * The component of this compound name at position 'posn' is removed, * and components at indices greater than 'posn' * are shifted down (towards index 0) by one. * * @param posn The index of the component to delete. * Must be in the range [0,size()). * @return The component removed (a String). * @exception ArrayIndexOutOfBoundsException * If posn is outside the specified range (includes case where * compound name is empty). * @exception InvalidNameException If deleting the component * would violate the compound name's syntax. */ public Object remove(int posn) throws InvalidNameException { return impl.remove(posn); } /** * Overridden to avoid implementation dependency. * @serialData The syntax <tt>Properties</tt>, followed by * the number of components (an <tt>int</tt>), and the individual * components (each a <tt>String</tt>). */ private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException { s.writeObject(mySyntax); s.writeInt(size()); Enumeration comps = getAll(); while (comps.hasMoreElements()) { s.writeObject(comps.nextElement()); } } /** * Overridden to avoid implementation dependency. */ private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { mySyntax = (Properties)s.readObject(); impl = new NameImpl(mySyntax); int n = s.readInt(); // number of components try { while (--n >= 0) { add((String)s.readObject()); } } catch (InvalidNameException e) { throw (new java.io.StreamCorruptedException("Invalid name")); } } /** * Use serialVersionUID from JNDI 1.1.1 for interoperability */ private static final long serialVersionUID = 3513100557083972036L; /*// For testing public static void main(String[] args) { Properties dotSyntax = new Properties(); dotSyntax.put("jndi.syntax.direction", "right_to_left"); dotSyntax.put("jndi.syntax.separator", "."); dotSyntax.put("jndi.syntax.ignorecase", "true"); dotSyntax.put("jndi.syntax.escape", "\\");// dotSyntax.put("jndi.syntax.beginquote", "\"");// dotSyntax.put("jndi.syntax.beginquote2", "'"); Name first = null; try { for (int i = 0; i < args.length; i++) { Name name; Enumeration e; System.out.println("Given name: " + args[i]); name = new CompoundName(args[i], dotSyntax); if (first == null) { first = name; } e = name.getComponents(); while (e.hasMoreElements()) { System.out.println("Element: " + e.nextElement()); } System.out.println("Constructed name: " + name.toString()); System.out.println("Compare " + first.toString() + " with " + name.toString() + " = " + first.compareTo(name)); } } catch (Exception ne) { ne.printStackTrace(); } }*/}Lines 501–624 of 624. Previous lines
* @return The updated CompoundName, not a new one. Cannot be null. * @exception InvalidNameException If adding comp at end of the name * would violate the compound name's syntax. */ public Name add(String comp) throws InvalidNameException{ impl.add(comp); return this; } /** * Adds a single component at a specified position within this * compound name. * Components of this compound name at or after the index of the new * component are shifted up by one (away from index 0) * to accommodate the new component. * * @param comp The non-null component to add. * @param posn The index at which to add the new component. * Must be in the range [0,size()]. * @exception ArrayIndexOutOfBoundsException * If posn is outside the specified range. * @return The updated CompoundName, not a new one. Cannot be null. * @exception InvalidNameException If adding comp at the specified position * would violate the compound name's syntax. */ public Name add(int posn, String comp) throws InvalidNameException{ impl.add(posn, comp); return this; } /** * Deletes a component from this compound name. * The component of this compound name at position 'posn' is removed, * and components at indices greater than 'posn' * are shifted down (towards index 0) by one. * * @param posn The index of the component to delete. * Must be in the range [0,size()). * @return The component removed (a String). * @exception ArrayIndexOutOfBoundsException * If posn is outside the specified range (includes case where * compound name is empty). * @exception InvalidNameException If deleting the component * would violate the compound name's syntax. */ public Object remove(int posn) throws InvalidNameException { return impl.remove(posn); } /** * Overridden to avoid implementation dependency. * @serialData The syntax <tt>Properties</tt>, followed by * the number of components (an <tt>int</tt>), and the individual * components (each a <tt>String</tt>). */ private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException { s.writeObject(mySyntax); s.writeInt(size()); Enumeration comps = getAll(); while (comps.hasMoreElements()) { s.writeObject(comps.nextElement()); } } /** * Overridden to avoid implementation dependency. */ private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { mySyntax = (Properties)s.readObject(); impl = new NameImpl(mySyntax); int n = s.readInt(); // number of components try { while (--n >= 0) { add((String)s.readObject()); } } catch (InvalidNameException e) { throw (new java.io.StreamCorruptedException("Invalid name")); } } /** * Use serialVersionUID from JNDI 1.1.1 for interoperability */ private static final long serialVersionUID = 3513100557083972036L; /* // For testing public static void main(String[] args) { Properties dotSyntax = new Properties(); dotSyntax.put("jndi.syntax.direction", "right_to_left"); dotSyntax.put("jndi.syntax.separator", "."); dotSyntax.put("jndi.syntax.ignorecase", "true"); dotSyntax.put("jndi.syntax.escape", "\\"); // dotSyntax.put("jndi.syntax.beginquote", "\""); // dotSyntax.put("jndi.syntax.beginquote2", "'"); Name first = null; try { for (int i = 0; i < args.length; i++) { Name name; Enumeration e; System.out.println("Given name: " + args[i]); name = new CompoundName(args[i], dotSyntax); if (first == null) { first = name; } e = name.getComponents(); while (e.hasMoreElements()) { System.out.println("Element: " + e.nextElement()); } System.out.println("Constructed name: " + name.toString()); System.out.println("Compare " + first.toString() + " with " + name.toString() + " = " + first.compareTo(name)); } } catch (Exception ne) { ne.printStackTrace(); } } */ }