FileDocCategorySizeDatePackage
NameClassPair.javaAPI DocJava SE 5 API8747Fri Aug 26 14:57:38 BST 2005javax.naming

NameClassPair

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.

author
Rosanna Lee
author
Scott Seligman
version
1.10 03/12/19
see
Context#list
since
1.3

Fields Summary
private String
name
Contains the name of this NameClassPair. It is initialized by the constructor and can be updated using setName().
private String
className
Contains the class name contained in this NameClassPair. It is initialized by the constructor and can be updated using setClassName().
private String
fullName
Contains the full name of this NameClassPair within its own namespace. It is initialized using setNameInNamespace()
private boolean
isRel
Records whether the name of this NameClassPair is relative to the target context. It is initialized by the constructor and can be updated using setRelative().
private static final long
serialVersionUID
Use serialVersionUID from JNDI 1.1.1 for interoperability
Constructors Summary
public NameClassPair(String name, String className)
Constructs an instance of a NameClassPair given its name and class name.

param
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)
param
className The possibly null class name of the object bound to name. It is null if the object bound is null.
see
#getClassName
see
#setClassName
see
#getName
see
#setName


                 		        			               		       		                        
         
	this.name = name;
	this.className = className;
    
public 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.

param
name The non-null name of the object.
param
className The possibly null class name of the object bound to name. It is null if the object bound is null.
param
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
#getClassName
see
#setClassName
see
#getName
see
#setName
see
#isRelative
see
#setRelative

	this.name = name;
	this.className = className;
	this.isRel = isRelative;
    
Methods Summary
public java.lang.StringgetClassName()
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().

return
The possibly null class name of object bound. It is null if the object bound is null.
see
Binding#getObject
see
Binding#getClassName
see
#setClassName

	return className;
    
public java.lang.StringgetName()
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.

return
The non-null name of this binding.
see
#isRelative
see
#setName

	return name;
    
public java.lang.StringgetNameInNamespace()
Retrieves the full name of this binding. The full name is the absolute name of this binding within its own namespace. See {@link 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.

return
The full name of this binding.
throws
UnsupportedOperationException if the notion of full name does not apply to this binding in the naming system.
since
1.5
see
#setNameInNamespace
see
#getName

	if (fullName == null) {
	    throw new UnsupportedOperationException();
	}
        return fullName;
    
public booleanisRelative()
Determines whether the name of this binding is relative to the target context (which is named by the first parameter of the list() method).

return
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
#setRelative
see
#getName

	return isRel;
    
public voidsetClassName(java.lang.String name)
Sets the class name of this binding.

param
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
#getClassName
see
Binding#getClassName

	this.className = name;
    
public voidsetName(java.lang.String name)
Sets the name of this binding.

param
name the non-null string to use as the name.
see
#getName
see
#setRelative

	this.name = name;
    
public voidsetNameInNamespace(java.lang.String 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.

param
fullName The full name to use.
since
1.5
see
#getNameInNamespace
see
#setName

        this.fullName = fullName;
    
public voidsetRelative(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).

param
r If true, the name of binding is relative to the target context; if false, the name of binding is a URL string.
see
#isRelative
see
#setName

	isRel = r;
    
public java.lang.StringtoString()
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.

return
The string representation of this name/class pair.

	return (isRelative() ? "" : "(not relative)") + getName() + ": " +
		getClassName();