NameClassPair (Java SE 11 & JDK 11 ) (original) (raw)
- javax.naming.NameClassPair
All Implemented Interfaces:
[Serializable](../../../java.base/java/io/Serializable.html "interface in java.io")
Direct Known Subclasses:[Binding](Binding.html "class in javax.naming")
public class NameClassPair
extends Object
implements Serializable
This class represents the object name and class name pair of a binding found in a context.
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.
Since:
1.3
See Also:
Context.list(javax.naming.Name), Serialized Form
Constructor Summary
Constructors
Constructor Description NameClassPair(String name,String className) Constructs an instance of a NameClassPair given its name and class name. NameClassPair(String name,String className, boolean isRelative) Constructs an instance of a NameClassPair given its name, class name, and whether it is relative to the listing context. Method Summary
All Methods Instance Methods Concrete Methods
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(String name) Sets the class name of this binding. void setName(String name) Sets the name of this binding. void setNameInNamespace(String fullName) Sets the full name of this binding. void setRelative(boolean r) 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. * ### Methods declared in class java.lang.[Object](../../../java.base/java/lang/Object.html "class in java.lang") `[clone](../../../java.base/java/lang/Object.html#clone%28%29), [equals](../../../java.base/java/lang/Object.html#equals%28java.lang.Object%29), [finalize](../../../java.base/java/lang/Object.html#finalize%28%29), [getClass](../../../java.base/java/lang/Object.html#getClass%28%29), [hashCode](../../../java.base/java/lang/Object.html#hashCode%28%29), [notify](../../../java.base/java/lang/Object.html#notify%28%29), [notifyAll](../../../java.base/java/lang/Object.html#notifyAll%28%29), [wait](../../../java.base/java/lang/Object.html#wait%28%29), [wait](../../../java.base/java/lang/Object.html#wait%28long%29), [wait](../../../java.base/java/lang/Object.html#wait%28long,int%29)`
Constructor Detail
* #### NameClassPair public NameClassPair([String](../../../java.base/java/lang/String.html "class in java.lang") name, [String](../../../java.base/java/lang/String.html "class in java.lang") className) Constructs an instance of a NameClassPair given its name and class name. Parameters: `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. See Also: [getClassName()](#getClassName%28%29), [setClassName(java.lang.String)](#setClassName%28java.lang.String%29), [getName()](#getName%28%29), [setName(java.lang.String)](#setName%28java.lang.String%29) * #### NameClassPair public NameClassPair([String](../../../java.base/java/lang/String.html "class in java.lang") name, [String](../../../java.base/java/lang/String.html "class in java.lang") className, boolean isRelative) Constructs an instance of a NameClassPair given its name, class name, and whether it is relative to the listing context. Parameters: `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. See Also: [getClassName()](#getClassName%28%29), [setClassName(java.lang.String)](#setClassName%28java.lang.String%29), [getName()](#getName%28%29), [setName(java.lang.String)](#setName%28java.lang.String%29), [isRelative()](#isRelative%28%29), [setRelative(boolean)](#setRelative%28boolean%29)
Method Detail
* #### getClassName public [String](../../../java.base/java/lang/String.html "class in java.lang") getClassName() Retrieves the class name of the object bound to the name of this binding. If a reference or some other indirect information is bound, retrieves the class name of the eventual object that will be returned by `Binding.getObject()`. Returns: The possibly null class name of object bound. It is null if the object bound is null. See Also: [Binding.getObject()](Binding.html#getObject%28%29), [Binding.getClassName()](Binding.html#getClassName%28%29), [setClassName(java.lang.String)](#setClassName%28java.lang.String%29) * #### getName public [String](../../../java.base/java/lang/String.html "class in java.lang") getName() Retrieves the name of this binding. If `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. Returns: The non-null name of this binding. See Also: [isRelative()](#isRelative%28%29), [setName(java.lang.String)](#setName%28java.lang.String%29) * #### setName public void setName([String](../../../java.base/java/lang/String.html "class in java.lang") name) Sets the name of this binding. Parameters: `name` \- the non-null string to use as the name. See Also: [getName()](#getName%28%29), [setRelative(boolean)](#setRelative%28boolean%29) * #### setClassName public void setClassName([String](../../../java.base/java/lang/String.html "class in java.lang") name) Sets the class name of this binding. Parameters: `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. See Also: [getClassName()](#getClassName%28%29), [Binding.getClassName()](Binding.html#getClassName%28%29) * #### isRelative public 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). Returns: true if the name of this binding is relative to the target context; false if the name of this binding is a URL string. See Also: [setRelative(boolean)](#setRelative%28boolean%29), [getName()](#getName%28%29) * #### setRelative public void setRelative(boolean r) Sets whether the name of this binding is relative to the target context (which is named by the first parameter of the `list()` method). Parameters: `r` \- If true, the name of binding is relative to the target context; if false, the name of binding is a URL string. See Also: [isRelative()](#isRelative%28%29), [setName(java.lang.String)](#setName%28java.lang.String%29) * #### getNameInNamespace public [String](../../../java.base/java/lang/String.html "class in java.lang") getNameInNamespace() Retrieves the full name of this binding. The full name is the absolute name of this binding within its own namespace. See [Context.getNameInNamespace()](Context.html#getNameInNamespace%28%29). 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. Returns: The full name of this binding. Throws: `[UnsupportedOperationException](../../../java.base/java/lang/UnsupportedOperationException.html "class in java.lang")` \- if the notion of full name does not apply to this binding in the naming system. Since: 1.5 See Also: [setNameInNamespace(java.lang.String)](#setNameInNamespace%28java.lang.String%29), [getName()](#getName%28%29) * #### setNameInNamespace public void setNameInNamespace([String](../../../java.base/java/lang/String.html "class in java.lang") fullName) Sets the full name of this binding. This method must be called to set the full name whenever a`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. Parameters: `fullName` \- The full name to use. Since: 1.5 See Also: [getNameInNamespace()](#getNameInNamespace%28%29), [setName(java.lang.String)](#setName%28java.lang.String%29) * #### toString public [String](../../../java.base/java/lang/String.html "class in java.lang") toString() Generates the string representation of this name/class pair. The string representation consists of the name and class name separated by a colon (':'). The contents of this string is useful for debugging and is not meant to be interpreted programmatically. Overrides: `[toString](../../../java.base/java/lang/Object.html#toString%28%29)` in class `[Object](../../../java.base/java/lang/Object.html "class in java.lang")` Returns: The string representation of this name/class pair.
Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2025, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.