javax.naming
Class BinaryRefAddr

java.lang.Object
  extended by javax.naming.RefAddr
      extended by javax.naming.BinaryRefAddr
All Implemented Interfaces:
Serializable

public class BinaryRefAddr
extends RefAddr

RefAddr that uses a byte array as content. This can be used to reference objects that can only be represented as byte arrays.

Since:
1.3
See Also:
Reference, Serialized Form

Field Summary
 
Fields inherited from class javax.naming.RefAddr
addrType
 
Constructor Summary
BinaryRefAddr(String addrType, byte[] buf)
          Contructs a new BinaryRefAddr with the given type and content.
BinaryRefAddr(String addrType, byte[] buf, int off, int length)
          Contructs a new BinaryRefAddr with the given type and the content taken from the given byte array.
 
Method Summary
 boolean equals(Object o)
          Checks if the object is a BinaryRefAddr with the same type and with the same bytes in the content.
 Object getContent()
          Returns the byte array contents as given to the constructor.
 int hashCode()
          Returns the hashCode which is the hasCode of the String returned by getType() plus the hashCode of the byte array returned by getContent.
 String toString()
          Returns a String representation of the RefAddr.
 
Methods inherited from class javax.naming.RefAddr
getType
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BinaryRefAddr

public BinaryRefAddr(String addrType,
                     byte[] buf)
Contructs a new BinaryRefAddr with the given type and content. The complete content of the byte array is copied to a new array.


BinaryRefAddr

public BinaryRefAddr(String addrType,
                     byte[] buf,
                     int off,
                     int length)
Contructs a new BinaryRefAddr with the given type and the content taken from the given byte array. The content of the byte array is copied to a new array.

Method Detail

getContent

public Object getContent()
Returns the byte array contents as given to the constructor. The returned byte array is shared with this object and other callers. Changing the content of the buffer is discouraged and should only be done when the byte array is locked.

Specified by:
getContent in class RefAddr

equals

public boolean equals(Object o)
Checks if the object is a BinaryRefAddr with the same type and with the same bytes in the content.

Overrides:
equals in class RefAddr
Parameters:
o - the Object to compare to
Returns:
true if the given object is an instance of BinaryRefAddr, the addrType is the same as this addrType and the bytes of the content are the same.
See Also:
Object.hashCode()

hashCode

public int hashCode()
Returns the hashCode which is the hasCode of the String returned by getType() plus the hashCode of the byte array returned by getContent. The hashCode of the byte array is calculated by taking the xor of all the bytes in the array, or zero when there are no bytes in the array.

Overrides:
hashCode in class RefAddr
Returns:
the hash code for this Object
See Also:
Object.equals(Object), System.identityHashCode(Object)

toString

public String toString()
Returns a String representation of the RefAddr. Only the first 32 bytes of the content are added as hex encoded characters. Should only be used for debugging purposes.

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