javax.naming
Class NameClassPair

java.lang.Object
  extended by javax.naming.NameClassPair
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
Binding

public class NameClassPair
extends Object
implements Serializable

NameClassPair represents the name-classname mapping pair of a binding in a context.

Bindings are mappings of a name to an object and this class is used to specify the mapping of the name to the class type of the bound object. As classname the fully qualified classname is used.

Since:
1.3
See Also:
Serialized Form

Constructor Summary
NameClassPair(String name, String className)
          Constructs an instance with the given name and classname.
NameClassPair(String name, String className, boolean isRelative)
          Constructs an instance with the given name and classname and a flag indicating if the name is relative to the target context.
 
Method Summary
 String getClassName()
          Returns the classname of the binding.
 String getName()
          Returns the name of the binding.
 String getNameInNamespace()
          Returns the full name for this binding.
 boolean isRelative()
          Checks whether the name is relative to the target context or not.
 void setClassName(String name)
          Sets the classname of the bound object.
 void setName(String name)
          Sets the name of the binding.
 void setNameInNamespace(String fullName)
          Sets the full name for this binding.
 void setRelative(boolean r)
          Sets if the name is relative to the target context.
 String toString()
          Returns the string representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NameClassPair

public NameClassPair(String name,
                     String className)
Constructs an instance with the given name and classname.

Parameters:
name - the name of the binding relative to the target context (may not be null)
className - the name of the class. If null the bound object is also null

NameClassPair

public NameClassPair(String name,
                     String className,
                     boolean isRelative)
Constructs an instance with the given name and classname and a flag indicating if the name is relative to the target context.

Parameters:
name - the name of the binding (may not be null)
className - the name of the class. If null the bound object is also null
isRelative - flag indicating if the name is relative or not
Method Detail

getClassName

public String getClassName()
Returns the classname of the binding.

Returns:
The fully qualified classname or null if the bound object is null.

getName

public String getName()
Returns the name of the binding.

Returns:
The name.

isRelative

public boolean isRelative()
Checks whether the name is relative to the target context or not.

Returns:
true if the name is relative, false otherwise.

setClassName

public void setClassName(String name)
Sets the classname of the bound object.

Parameters:
name - the classname to set (maybe null)

setName

public void setName(String name)
Sets the name of the binding.

Parameters:
name - the name to set

setRelative

public void setRelative(boolean r)
Sets if the name is relative to the target context.

Parameters:
r - true to mark as relative

setNameInNamespace

public void setNameInNamespace(String fullName)
Sets the full name for this binding. Setting the full name by this method is the only way to initialize full names of bindings if supported by a specific naming system.

Parameters:
fullName - the full name of this binding. If not set or set to null the getNameInNamespace() method will throw an exception
Since:
1.5
See Also:
getNameInNamespace()

getNameInNamespace

public String getNameInNamespace()
Returns the full name for this binding. The full name of a binding is defined as the absolute name in its own namespace and is not valid outside.

Returns:
The full name in the bindings namespace.
Throws:
UnsupportedOperationException - if no full name is applicable in the specific naming system.
Since:
1.5
See Also:
Context.getNameInNamespace()

toString

public String toString()
Returns the string representation.

Overrides:
toString in class Object
Returns:
The string getName() + ":" + getClassName().
See Also:
Object.getClass(), Object.hashCode(), Class.getName(), Integer.toHexString(int)