javax.naming

Class NameClassPair

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

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
StringgetClassName()
Returns the classname of the binding.
StringgetName()
Returns the name of the binding.
StringgetNameInNamespace()
Returns the full name for this binding.
booleanisRelative()
Checks whether the name is relative to the target context or not.
voidsetClassName(String name)
Sets the classname of the bound object.
voidsetName(String name)
Sets the name of the binding.
voidsetNameInNamespace(String fullName)
Sets the full name for this binding.
voidsetRelative(boolean r)
Sets if the name is relative to the target context.
StringtoString()
Returns the string representation.

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.

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:

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

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:

setRelative

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

Parameters: r true to mark as relative

toString

public String toString()
Returns the string representation.

Returns: The string getName() + ":" + getClassName().