PROXY  WHOIS  RQUOTE  TEXTS  SOFT  FOREX  BBOARD
 Music  Philosophy  Code  Literature  Russian

= ROOT|Technical|Code_Examples|Java|javax|naming|BinaryRefAddr.java =

page 2 of 2



      * it contains the same address type and their contents are byte-wise
      * equivalent.
      * @param obj	The possibly null object to check.
      * @return true if the object is equal; false otherwise.
      */
    public boolean equals(Object obj) {
	if ((obj != null) && (obj instanceof BinaryRefAddr)) {
	    BinaryRefAddr target = (BinaryRefAddr)obj;
	    if (addrType.compareTo(target.addrType) == 0) {
		if (buf == null && target.buf == null)
		    return true;
		if (buf == null || target.buf == null ||
		    buf.length != target.buf.length)
		    return false;
		for (int i = 0; i < buf.length; i++)
		    if (buf[i] != target.buf[i])
			return false;
		return true;
	    }
	}
	return false;
    }
    
    /**
      * Computes the hash code of this address using its address type and contents.
      * Two BinaryRefAddrs have the same hash code if they have
      * the same address type and the same contents.
      * It is also possible for different BinaryRefAddrs to have
      * the same hash code.
      *
      * @return The hash code of this address as an int.
      */
    public int hashCode() {
	int hash = addrType.hashCode();
	for (int i = 0; i < buf.length; i++) {
	    hash += buf[i];	// %%% improve later
	}
	return hash;
    }

    /**
      * Generates the string representation of this address.
      * The string consists of the address's type and contents with labels.
      * The first 32 bytes of contents are displayed (in hexadecimal).
      * If there are more than 32 bytes, "..." is used to indicate more.
      * This string is meant to used for debugging purposes and not
      * meant to be interpreted programmatically.
      * @return The non-null string representation of this address.
      */
    public String toString(){
	StringBuffer str = new StringBuffer("Address Type: " + addrType + "\n");

	str.append("AddressContents: ");
	for (int i = 0; i<buf.length && i < 32; i++) {
	    str.append(Integer.toHexString(buf[i]) +" ");
	}
	if (buf.length >= 32)
	    str.append(" ...\n");
	return (str.toString());
    }

    /**
     * Use serialVersionUID from JNDI 1.1.1 for interoperability
     */
    private static final long serialVersionUID = -3415254970957330361L;
}
=2=
THE END

1| < PREV = PAGE 2 =

UP TO ROOT | UP TO DIR | TO FIRST PAGE

Google
 

E-mail Facebook Google Digg del.icio.us BlinkList Fark Furl Ma.gnolia Netscape NewsVine Reddit Slashdot Spurl StumbleUpon Technorati YahooMyWeb LiveJournal Blogmarks TwitThis Live News2.ru BobrDobr.ru Memori.ru MoeMesto.ru

0.031112 wallclock secs ( 0.01 usr + 0.00 sys = 0.01 CPU)