javax.naming
Class Reference

java.lang.Object
  extended by javax.naming.Reference
All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
LinkRef

public class Reference
extends Object
implements Cloneable, Serializable

This class represents a reference to an object that is located outside of the naming/directory system.

See Also:
Referenceable, Serialized Form

Field Summary
protected  Vector<RefAddr> addrs
          The list of addresses, stored in this reference.
protected  String classFactory
          The name of the class factory to create an instance of the object, referenced by this reference.
protected  String classFactoryLocation
          The location, from where the class factory should be loaded.
protected  String className
          The name of the class of the object, to that this reference refers.
 
Constructor Summary
Reference(String className)
          Create a new reference that is referencting to the object of the specified class.
Reference(String className, RefAddr addr)
          Create a new reference that is referencing to the object of the specified class with the given address.
Reference(String className, RefAddr addr, String factoryClassName, String factoryLocation)
          Create a new reference that is referencing to the object of the specified class, specifying the class and location of the factory that produces these objects and also the address of this object.
Reference(String className, String factoryClassName, String factoryLocation)
          Create a new reference that is referencing to the object of the specified class, specifying the class and location of the factory that produces these objects.
 
Method Summary
 void add(int posn, RefAddr addr)
          Add the new address for this object at the given position of the address list.
 void add(RefAddr addr)
          Appends the new object address to the end of the address list.
 void clear()
          Removes all defined addresses of the object.
 Object clone()
          This method may be called to create a new copy of the Object.
 boolean equals(Object obj)
          Compares two addresses for equality, by value.
 RefAddr get(int posn)
          Get the address of this object at the given position.
 RefAddr get(String addrType)
          Get the given type of address for this object.
 Enumeration<RefAddr> getAll()
          Get the enumeration over all defined addresses of the object.
 String getClassName()
          Get the name of the class of the referenced object.
 String getFactoryClassLocation()
          Get the location of the factory class of the referenced object.
 String getFactoryClassName()
          Get the name of the factory class of the referenced object
 int hashCode()
          Get the hashcode of this reference.
 Object remove(int posn)
          Remove the address at the given position.
 int size()
          Return the number of the defined addresses.
 String toString()
          Return the string representation.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

addrs

protected Vector<RefAddr> addrs
The list of addresses, stored in this reference. The object may be have by several different addresses.


classFactory

protected String classFactory
The name of the class factory to create an instance of the object, referenced by this reference.


classFactoryLocation

protected String classFactoryLocation
The location, from where the class factory should be loaded.


className

protected String className
The name of the class of the object, to that this reference refers.

Constructor Detail

Reference

public Reference(String className)
Create a new reference that is referencting to the object of the specified class.


Reference

public Reference(String className,
                 RefAddr addr)
Create a new reference that is referencing to the object of the specified class with the given address.


Reference

public Reference(String className,
                 String factoryClassName,
                 String factoryLocation)
Create a new reference that is referencing to the object of the specified class, specifying the class and location of the factory that produces these objects.

Parameters:
className - the object class name
factoryClassName - the object factory class name
factoryLocation - the object factory location

Reference

public Reference(String className,
                 RefAddr addr,
                 String factoryClassName,
                 String factoryLocation)
Create a new reference that is referencing to the object of the specified class, specifying the class and location of the factory that produces these objects and also the address of this object.

Parameters:
className - the object class name
addr - the address of the object
factoryClassName - the object factory class name
factoryLocation - the object factory location
Method Detail

add

public void add(int posn,
                RefAddr addr)
Add the new address for this object at the given position of the address list.


add

public void add(RefAddr addr)
Appends the new object address to the end of the address list.


clear

public void clear()
Removes all defined addresses of the object.


clone

public Object clone()
Description copied from class: Object
This method may be called to create a new copy of the Object. The typical behavior is as follows:

However, these are not strict requirements, and may be violated if necessary. Of the three requirements, the last is the most commonly violated, particularly if the subclass does not override Object.equals(Object).

If the Object you call clone() on does not implement Cloneable (which is a placeholder interface), then a CloneNotSupportedException is thrown. Notice that Object does not implement Cloneable; this method exists as a convenience for subclasses that do.

Object's implementation of clone allocates space for the new Object using the correct class, without calling any constructors, and then fills in all of the new field values with the old field values. Thus, it is a shallow copy. However, subclasses are permitted to make a deep copy.

All array types implement Cloneable, and override this method as follows (it should never fail):

 public Object clone()
 {
   try
     {
       super.clone();
     }
   catch (CloneNotSupportedException e)
     {
       throw new InternalError(e.getMessage());
     }
 }
 

Overrides:
clone in class Object
Returns:
a copy of the Object
See Also:
Cloneable

equals

public boolean equals(Object obj)
Compares two addresses for equality, by value.

Overrides:
equals in class Object
Parameters:
obj - the Object to compare to
Returns:
whether this Object is semantically equal to another
See Also:
Object.hashCode()

get

public RefAddr get(int posn)
Get the address of this object at the given position.


get

public RefAddr get(String addrType)
Get the given type of address for this object.

Parameters:
addrType - the needed type of address
Returns:
the address of this object, having the specified type. If there is no address of such type, null is returned.

getAll

public Enumeration<RefAddr> getAll()
Get the enumeration over all defined addresses of the object.


getClassName

public String getClassName()
Get the name of the class of the referenced object.

See Also:
className

getFactoryClassLocation

public String getFactoryClassLocation()
Get the location of the factory class of the referenced object.

See Also:
classFactoryLocation

getFactoryClassName

public String getFactoryClassName()
Get the name of the factory class of the referenced object

See Also:
classFactory

hashCode

public int hashCode()
Get the hashcode of this reference.

Overrides:
hashCode in class Object
Returns:
the sum of the hash codes of the addresses.
See Also:
Object.equals(Object), System.identityHashCode(Object)

remove

public Object remove(int posn)
Remove the address at the given position.

Parameters:
posn - the position of the address to remove
Returns:
the removed address

size

public int size()
Return the number of the defined addresses.


toString

public String toString()
Return the string representation.

Overrides:
toString in class Object
Returns:
the String representing this Object, which may be null
See Also:
Object.getClass(), Object.hashCode(), Class.getName(), Integer.toHexString(int)