javax.naming

Class Reference

Implemented Interfaces:
Cloneable, Serializable
Known Direct 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
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, 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.
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.

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
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

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

addrs

protected Vector 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 Details

Reference

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

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)
Create a new reference that is referencing to the object of the specified class with the given address.

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 Details

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()
This method may be called to create a new copy of the Object. The typical behavior is as follows:
  • o == o.clone() is false
  • o.getClass() == o.clone().getClass() is true
  • o.equals(o) is true

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 interface 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 interface Object

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 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.

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 interface Object
Returns:
the sum of the hash codes of the addresses.

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 interface Object

Reference.java -- Copyright (C) 2000, 2001, 2005, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.