Constructors Summary |
---|
public Reference(String className)Constructs a new reference for an object with class name 'className'.
Class factory and class factory location are set to null.
The newly created reference contains zero addresses.
this.className = className;
addrs = new Vector();
|
public Reference(String className, RefAddr addr)Constructs a new reference for an object with class name 'className' and
an address.
Class factory and class factory location are set to null.
this.className = className;
addrs = new Vector();
addrs.addElement(addr);
|
public Reference(String className, String factory, String factoryLocation)Constructs a new reference for an object with class name 'className',
and the class name and location of the object's factory.
this(className);
classFactory = factory;
classFactoryLocation = factoryLocation;
|
public Reference(String className, RefAddr addr, String factory, String factoryLocation)Constructs a new reference for an object with class name 'className',
the class name and location of the object's factory, and the address for
the object.
this(className, addr);
classFactory = factory;
classFactoryLocation = factoryLocation;
|
Methods Summary |
---|
public void | add(javax.naming.RefAddr addr)Adds an address to the end of the list of addresses.
addrs.addElement(addr);
|
public void | add(int posn, javax.naming.RefAddr addr)Adds an address to the list of addresses at index posn.
All addresses at index posn or greater are shifted up
the list by one (away from index 0).
addrs.insertElementAt(addr, posn);
|
public void | clear()Deletes all addresses from this reference.
addrs.setSize(0);
|
public java.lang.Object | clone()Makes a copy of this reference using its class name
list of addresses, class factory name and class factory location.
Changes to the newly created copy does not affect this Reference
and vice versa.
Reference r = new Reference(className, classFactory, classFactoryLocation);
Enumeration<RefAddr> a = getAll();
r.addrs = new Vector();
while (a.hasMoreElements())
r.addrs.addElement(a.nextElement());
return r;
|
public boolean | equals(java.lang.Object obj)Determines whether obj is a reference with the same addresses
(in same order) as this reference.
The addresses are checked using RefAddr.equals().
In addition to having the same addresses, the Reference also needs to
have the same class name as this reference.
The class factory and class factory location are not checked.
If obj is null or not an instance of Reference, null is returned.
if ((obj != null) && (obj instanceof Reference)) {
Reference target = (Reference)obj;
// ignore factory information
if (target.className.equals(this.className) &&
target.size() == this.size()) {
Enumeration mycomps = getAll();
Enumeration comps = target.getAll();
while (mycomps.hasMoreElements())
if (!(mycomps.nextElement().equals(comps.nextElement())))
return false;
return true;
}
}
return false;
|
public javax.naming.RefAddr | get(java.lang.String addrType)Retrieves the first address that has the address type 'addrType'.
String.compareTo() is used to test the equality of the address types.
int len = addrs.size();
RefAddr addr;
for (int i = 0; i < len; i++) {
addr = (RefAddr) addrs.elementAt(i);
if (addr.getType().compareTo(addrType) == 0)
return addr;
}
return null;
|
public javax.naming.RefAddr | get(int posn)Retrieves the address at index posn.
return ((RefAddr) addrs.elementAt(posn));
|
public java.util.Enumeration | getAll()Retrieves an enumeration of the addresses in this reference.
When addresses are added, changed or removed from this reference,
its effects on this enumeration are undefined.
return addrs.elements();
|
public java.lang.String | getClassName()Retrieves the class name of the object to which this reference refers.
return className;
|
public java.lang.String | getFactoryClassLocation()Retrieves the location of the factory of the object
to which this reference refers.
If it is a codebase, then it is an ordered list of URLs,
separated by spaces, listing locations from where the factory
class definition should be loaded.
return classFactoryLocation;
|
public java.lang.String | getFactoryClassName()Retrieves the class name of the factory of the object
to which this reference refers.
return classFactory;
|
public int | hashCode()Computes the hash code of this reference.
The hash code is the sum of the hash code of its addresses.
int hash = className.hashCode();
for (Enumeration e = getAll(); e.hasMoreElements();)
hash += e.nextElement().hashCode();
return hash;
|
public java.lang.Object | remove(int posn)Deletes the address at index posn from the list of addresses.
All addresses at index greater than posn are shifted down
the list by one (towards index 0).
Object r = addrs.elementAt(posn);
addrs.removeElementAt(posn);
return r;
|
public int | size()Retrieves the number of addresses in this reference.
return addrs.size();
|
public java.lang.String | toString()Generates the string representation of this reference.
The string consists of the class name to which this reference refers,
and the string representation of each of its addresses.
This representation is intended for display only and not to be parsed.
StringBuffer buf = new StringBuffer("Reference Class Name: " +
className + "\n");
int len = addrs.size();
for (int i = 0; i < len; i++)
buf.append(get(i).toString());
return buf.toString();
|