Serializable
Binding
public class NameClassPair extends Object implements Serializable
A context consists of name-to-object bindings. The NameClassPair class represents the name and the class of the bound object. It consists of a name and a string representing the package-qualified class name.
Use subclassing for naming systems that generate contents of a name/class pair dynamically.
A NameClassPair instance is not synchronized against concurrent access by multiple threads. Threads that need to access a NameClassPair concurrently should synchronize amongst themselves and provide the necessary locking.
Constructor | Description |
---|---|
NameClassPair |
Constructs an instance of a NameClassPair given its name and class name. |
NameClassPair |
Constructs an instance of a NameClassPair given its name, class name, and whether it is relative to the listing context. |
Modifier and Type | Method | Description |
---|---|---|
String |
getClassName() |
Retrieves the class name of the object bound to the name of this binding. |
String |
getName() |
Retrieves the name of this binding. |
String |
getNameInNamespace() |
Retrieves the full name of this binding. |
boolean |
isRelative() |
Determines whether the name of this binding is relative to the target context (which is named by the first parameter of the list() method). |
void |
setClassName |
Sets the class name of this binding. |
void |
setName |
Sets the name of this binding. |
void |
setNameInNamespace |
Sets the full name of this binding. |
void |
setRelative |
Sets whether the name of this binding is relative to the target context (which is named by the first parameter of the list() method). |
String |
toString() |
Generates the string representation of this name/class pair. |
public NameClassPair(String name, String className)
name
- The non-null name of the object. It is relative to the target context (which is named by the first parameter of the list()
method)className
- The possibly null class name of the object bound to name. It is null if the object bound is null.public NameClassPair(String name, String className, boolean isRelative)
name
- The non-null name of the object.className
- The possibly null class name of the object bound to name. It is null if the object bound is null.isRelative
- true if name
is a name relative to the target context (which is named by the first parameter of the list()
method); false if name
is a URL string.public String getClassName()
Binding.getObject()
.public String getName()
isRelative()
is true, this name is relative to the target context (which is named by the first parameter of the list()
). If isRelative()
is false, this name is a URL string.public void setName(String name)
name
- the non-null string to use as the name.public void setClassName(String name)
name
- the possibly null string to use as the class name. If null, Binding.getClassName()
will return the actual class name of the object in the binding. The class name will be null if the object bound is null.public boolean isRelative()
list()
method).public void setRelative(boolean r)
list()
method).r
- If true, the name of binding is relative to the target context; if false, the name of binding is a URL string.public String getNameInNamespace()
Context.getNameInNamespace()
. In naming systems for which the notion of full name does not apply to this binding an UnsupportedOperationException
is thrown. This exception is also thrown when a service provider written before the introduction of the method is in use.
The string returned by this method is not a JNDI composite name and should not be passed directly to context methods.
UnsupportedOperationException
- if the notion of full name does not apply to this binding in the naming system.public void setNameInNamespace(String fullName)
NameClassPair
is created and a full name is applicable to this binding. Setting the full name to null, or not setting it at all, will cause getNameInNamespace()
to throw an exception.
fullName
- The full name to use.public String toString()
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.naming/javax/naming/NameClassPair.html