< prev index next >

src/java.naming/share/classes/javax/naming/CompoundName.java

Print this page




 120  *<li>
 121  * An escape string that does not precede a meta string (quotes or separator)
 122  * and is not at the end of a component is treated as an ordinary string.
 123  *<li>
 124  * A leading separator (the compound name string begins with
 125  * a separator) denotes a leading empty atomic component (consisting
 126  * of an empty string).
 127  * A trailing separator (the compound name string ends with
 128  * a separator) denotes a trailing empty atomic component.
 129  * Adjacent separators denote an empty atomic component.
 130  *</ol>
 131  * <p>
 132  * The string form of the compound name follows the syntax described above.
 133  * When the components of the compound name are turned into their
 134  * string representation, the reserved syntax rules described above are
 135  * applied (e.g. embedded separators are escaped or quoted)
 136  * so that when the same string is parsed, it will yield the same components
 137  * of the original compound name.
 138  *
 139  *<h1>Multithreaded Access</h1>
 140  * A <tt>CompoundName</tt> instance is not synchronized against concurrent
 141  * multithreaded access. Multiple threads trying to access and modify a
 142  * <tt>CompoundName</tt> should lock the object.
 143  *
 144  * @author Rosanna Lee
 145  * @author Scott Seligman
 146  * @since 1.3
 147  */
 148 
 149 public class CompoundName implements Name {
 150 
 151     /**
 152       * Implementation of this compound name.
 153       * This field is initialized by the constructors and cannot be null.
 154       * It should be treated as a read-only variable by subclasses.
 155       */
 156     protected transient NameImpl impl;
 157     /**
 158       * Syntax properties for this compound name.
 159       * This field is initialized by the constructors and cannot be null.
 160       * It should be treated as a read-only variable by subclasses.
 161       * Any necessary changes to mySyntax should be made within constructors
 162       * and not after the compound name has been instantiated.


 177       *                 this compound name. See class description for
 178       *                 contents of properties.
 179       */
 180     protected CompoundName(Enumeration<String> comps, Properties syntax) {
 181         if (syntax == null) {
 182             throw new NullPointerException();
 183         }
 184         mySyntax = syntax;
 185         impl = new NameImpl(syntax, comps);
 186     }
 187 
 188     /**
 189       * Constructs a new compound name instance by parsing the string n
 190       * using the syntax specified by the syntax properties supplied.
 191       *
 192       * @param  n       The non-null string to parse.
 193       * @param syntax   A non-null list of properties that specify the syntax of
 194       *                 this compound name.  See class description for
 195       *                 contents of properties.
 196       * @exception      InvalidNameException If 'n' violates the syntax specified
 197       *                 by <code>syntax</code>.
 198       */
 199     public CompoundName(String n, Properties syntax) throws InvalidNameException {
 200         if (syntax == null) {
 201             throw new NullPointerException();
 202         }
 203         mySyntax = syntax;
 204         impl = new NameImpl(syntax, n);
 205     }
 206 
 207     /**
 208       * Generates the string representation of this compound name, using
 209       * the syntax rules of the compound name. The syntax rules
 210       * are described in the class description.
 211       * An empty component is represented by an empty string.
 212       *
 213       * The string representation thus generated can be passed to
 214       * the CompoundName constructor with the same syntax properties
 215       * to create a new equivalent compound name.
 216       *
 217       * @return A non-null string representation of this compound name.


 532       * Deletes a component from this compound name.
 533       * The component of this compound name at position 'posn' is removed,
 534       * and components at indices greater than 'posn'
 535       * are shifted down (towards index 0) by one.
 536       *
 537       * @param  posn    The index of the component to delete.
 538       *                 Must be in the range [0,size()).
 539       * @return The component removed (a String).
 540       * @exception ArrayIndexOutOfBoundsException
 541       *         If posn is outside the specified range (includes case where
 542       *         compound name is empty).
 543       * @exception InvalidNameException If deleting the component
 544       *                         would violate the compound name's syntax.
 545       */
 546     public Object remove(int posn) throws InvalidNameException {
 547         return impl.remove(posn);
 548     }
 549 
 550     /**
 551      * Overridden to avoid implementation dependency.
 552      * @serialData The syntax <tt>Properties</tt>, followed by
 553      * the number of components (an <tt>int</tt>), and the individual
 554      * components (each a <tt>String</tt>).
 555      */
 556     private void writeObject(java.io.ObjectOutputStream s)
 557             throws java.io.IOException {
 558         s.writeObject(mySyntax);
 559         s.writeInt(size());
 560         Enumeration<String> comps = getAll();
 561         while (comps.hasMoreElements()) {
 562             s.writeObject(comps.nextElement());
 563         }
 564     }
 565 
 566     /**
 567      * Overridden to avoid implementation dependency.
 568      */
 569     private void readObject(java.io.ObjectInputStream s)
 570             throws java.io.IOException, ClassNotFoundException {
 571         mySyntax = (Properties)s.readObject();
 572         impl = new NameImpl(mySyntax);
 573         int n = s.readInt();    // number of components
 574         try {




 120  *<li>
 121  * An escape string that does not precede a meta string (quotes or separator)
 122  * and is not at the end of a component is treated as an ordinary string.
 123  *<li>
 124  * A leading separator (the compound name string begins with
 125  * a separator) denotes a leading empty atomic component (consisting
 126  * of an empty string).
 127  * A trailing separator (the compound name string ends with
 128  * a separator) denotes a trailing empty atomic component.
 129  * Adjacent separators denote an empty atomic component.
 130  *</ol>
 131  * <p>
 132  * The string form of the compound name follows the syntax described above.
 133  * When the components of the compound name are turned into their
 134  * string representation, the reserved syntax rules described above are
 135  * applied (e.g. embedded separators are escaped or quoted)
 136  * so that when the same string is parsed, it will yield the same components
 137  * of the original compound name.
 138  *
 139  *<h1>Multithreaded Access</h1>
 140  * A {@code CompoundName} instance is not synchronized against concurrent
 141  * multithreaded access. Multiple threads trying to access and modify a
 142  * {@code CompoundName} should lock the object.
 143  *
 144  * @author Rosanna Lee
 145  * @author Scott Seligman
 146  * @since 1.3
 147  */
 148 
 149 public class CompoundName implements Name {
 150 
 151     /**
 152       * Implementation of this compound name.
 153       * This field is initialized by the constructors and cannot be null.
 154       * It should be treated as a read-only variable by subclasses.
 155       */
 156     protected transient NameImpl impl;
 157     /**
 158       * Syntax properties for this compound name.
 159       * This field is initialized by the constructors and cannot be null.
 160       * It should be treated as a read-only variable by subclasses.
 161       * Any necessary changes to mySyntax should be made within constructors
 162       * and not after the compound name has been instantiated.


 177       *                 this compound name. See class description for
 178       *                 contents of properties.
 179       */
 180     protected CompoundName(Enumeration<String> comps, Properties syntax) {
 181         if (syntax == null) {
 182             throw new NullPointerException();
 183         }
 184         mySyntax = syntax;
 185         impl = new NameImpl(syntax, comps);
 186     }
 187 
 188     /**
 189       * Constructs a new compound name instance by parsing the string n
 190       * using the syntax specified by the syntax properties supplied.
 191       *
 192       * @param  n       The non-null string to parse.
 193       * @param syntax   A non-null list of properties that specify the syntax of
 194       *                 this compound name.  See class description for
 195       *                 contents of properties.
 196       * @exception      InvalidNameException If 'n' violates the syntax specified
 197       *                 by {@code syntax}.
 198       */
 199     public CompoundName(String n, Properties syntax) throws InvalidNameException {
 200         if (syntax == null) {
 201             throw new NullPointerException();
 202         }
 203         mySyntax = syntax;
 204         impl = new NameImpl(syntax, n);
 205     }
 206 
 207     /**
 208       * Generates the string representation of this compound name, using
 209       * the syntax rules of the compound name. The syntax rules
 210       * are described in the class description.
 211       * An empty component is represented by an empty string.
 212       *
 213       * The string representation thus generated can be passed to
 214       * the CompoundName constructor with the same syntax properties
 215       * to create a new equivalent compound name.
 216       *
 217       * @return A non-null string representation of this compound name.


 532       * Deletes a component from this compound name.
 533       * The component of this compound name at position 'posn' is removed,
 534       * and components at indices greater than 'posn'
 535       * are shifted down (towards index 0) by one.
 536       *
 537       * @param  posn    The index of the component to delete.
 538       *                 Must be in the range [0,size()).
 539       * @return The component removed (a String).
 540       * @exception ArrayIndexOutOfBoundsException
 541       *         If posn is outside the specified range (includes case where
 542       *         compound name is empty).
 543       * @exception InvalidNameException If deleting the component
 544       *                         would violate the compound name's syntax.
 545       */
 546     public Object remove(int posn) throws InvalidNameException {
 547         return impl.remove(posn);
 548     }
 549 
 550     /**
 551      * Overridden to avoid implementation dependency.
 552      * @serialData The syntax {@code Properties}, followed by
 553      * the number of components (an {@code int}), and the individual
 554      * components (each a {@code String}).
 555      */
 556     private void writeObject(java.io.ObjectOutputStream s)
 557             throws java.io.IOException {
 558         s.writeObject(mySyntax);
 559         s.writeInt(size());
 560         Enumeration<String> comps = getAll();
 561         while (comps.hasMoreElements()) {
 562             s.writeObject(comps.nextElement());
 563         }
 564     }
 565 
 566     /**
 567      * Overridden to avoid implementation dependency.
 568      */
 569     private void readObject(java.io.ObjectInputStream s)
 570             throws java.io.IOException, ClassNotFoundException {
 571         mySyntax = (Properties)s.readObject();
 572         impl = new NameImpl(mySyntax);
 573         int n = s.readInt();    // number of components
 574         try {


< prev index next >