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

Print this page




 188 </tr>
 189 
 190 </table>
 191  *
 192  *<h1>Multithreaded Access</h1>
 193  * A <tt>CompositeName</tt> instance is not synchronized against concurrent
 194  * multithreaded access. Multiple threads trying to access and modify a
 195  * <tt>CompositeName</tt> should lock the object.
 196  *
 197  * @author Rosanna Lee
 198  * @author Scott Seligman
 199  * @since 1.3
 200  */
 201 
 202 
 203 public class CompositeName implements Name {
 204 
 205     private transient NameImpl impl;
 206     /**
 207       * Constructs a new composite name instance using the components
 208       * specified by 'comps'. This protected method is intended to be
 209       * to be used by subclasses of CompositeName when they override
 210       * methods such as clone(), getPrefix(), getSuffix().
 211       *
 212       * @param comps A non-null enumeration containing the components for the new
 213       *              composite name. Each element is of class String.
 214       *               The enumeration will be consumed to extract its
 215       *               elements.
 216       */
 217     protected CompositeName(Enumeration<String> comps) {
 218         impl = new NameImpl(null, comps); // null means use default syntax
 219     }
 220 
 221     /**
 222       * Constructs a new composite name instance by parsing the string n
 223       * using the composite name syntax (left-to-right, slash separated).
 224       * The composite name syntax is described in detail in the class
 225       * description.
 226       *
 227       * @param  n       The non-null string to parse.
 228       * @exception InvalidNameException If n has invalid composite name syntax.


 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     }
 436 
 437     /**
 438       * Determines whether a composite name is a suffix of this composite name.
 439       * A composite name 'n' is a suffix if it it is equal to
 440       * getSuffix(size()-n.size())--in other words, this
 441       * composite name ends with 'n'.
 442       * If n is null or not a composite name, false is returned.
 443       *
 444       * @param  n       The possibly null name to check.
 445       * @return true if n is a CompositeName and
 446       *         is a suffix of this composite name, false otherwise.
 447       */
 448     public boolean endsWith(Name n) {
 449         if (n instanceof CompositeName) {
 450             return (impl.endsWith(n.size(), n.getAll()));
 451         } else {
 452             return false;
 453         }
 454     }
 455 
 456     /**
 457       * Adds the components of a composite name -- in order -- to the end of
 458       * this composite name.
 459       *




 188 </tr>
 189 
 190 </table>
 191  *
 192  *<h1>Multithreaded Access</h1>
 193  * A <tt>CompositeName</tt> instance is not synchronized against concurrent
 194  * multithreaded access. Multiple threads trying to access and modify a
 195  * <tt>CompositeName</tt> should lock the object.
 196  *
 197  * @author Rosanna Lee
 198  * @author Scott Seligman
 199  * @since 1.3
 200  */
 201 
 202 
 203 public class CompositeName implements Name {
 204 
 205     private transient NameImpl impl;
 206     /**
 207       * Constructs a new composite name instance using the components
 208       * specified by 'comps'. This protected method is intended
 209       * to be used by subclasses of CompositeName when they override
 210       * methods such as clone(), getPrefix(), getSuffix().
 211       *
 212       * @param comps A non-null enumeration containing the components for the new
 213       *              composite name. Each element is of class String.
 214       *               The enumeration will be consumed to extract its
 215       *               elements.
 216       */
 217     protected CompositeName(Enumeration<String> comps) {
 218         impl = new NameImpl(null, comps); // null means use default syntax
 219     }
 220 
 221     /**
 222       * Constructs a new composite name instance by parsing the string n
 223       * using the composite name syntax (left-to-right, slash separated).
 224       * The composite name syntax is described in detail in the class
 225       * description.
 226       *
 227       * @param  n       The non-null string to parse.
 228       * @exception InvalidNameException If n has invalid composite name syntax.


 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     }
 436 
 437     /**
 438       * Determines whether a composite name is a suffix of this composite name.
 439       * A composite name 'n' is a suffix if it is equal to
 440       * getSuffix(size()-n.size())--in other words, this
 441       * composite name ends with 'n'.
 442       * If n is null or not a composite name, false is returned.
 443       *
 444       * @param  n       The possibly null name to check.
 445       * @return true if n is a CompositeName and
 446       *         is a suffix of this composite name, false otherwise.
 447       */
 448     public boolean endsWith(Name n) {
 449         if (n instanceof CompositeName) {
 450             return (impl.endsWith(n.size(), n.getAll()));
 451         } else {
 452             return false;
 453         }
 454     }
 455 
 456     /**
 457       * Adds the components of a composite name -- in order -- to the end of
 458       * this composite name.
 459       *