/*
* @(#)BinaryRefAddr.java 1.8 05/11/17
*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package javax.naming;
/**
* This class represents the binary form of the address of
* a communications end-point.
*<p>
* A BinaryRefAddr consists of a type that describes the communication mechanism
* and an opaque buffer containing the address description
* specific to that communication mechanism. The format and interpretation of
* the address type and the contents of the opaque buffer are based on
* the agreement of three parties: the client that uses the address,
* the object/server that can be reached using the address,
* and the administrator or program that creates the address.
*<p>
* An example of a binary reference address is an BER X.500 presentation address.
* Another example of a binary reference address is a serialized form of
* a service's object handle.
*<p>
* A binary reference address is immutable in the sense that its fields
* once created, cannot be replaced. However, it is possible to access
* the byte array used to hold the opaque buffer. Programs are strongly
* recommended against changing this byte array. Changes to this
* byte array need to be explicitly synchronized.
*
* @author Rosanna Lee
* @author Scott Seligman
* @version 1.8 05/11/17
*
* @see RefAddr
* @see StringRefAddr
* @since 1.3
*/
/*
* The serialized form of a BinaryRefAddr object consists of its type
* name String and a byte array containing its "contents".
*/
public class BinaryRefAddr extends RefAddr {
/**
* Contains the bytes of the address.
* This field is initialized by the constructor and returned
* using getAddressBytes() and getAddressContents().
* @serial
*/
private byte[] buf = null;
/**
* Constructs a new instance of BinaryRefAddr using its address type and a byte
* array for contents.
*
* @param addrType A non-null string describing the type of the address.
* @param src The non-null contents of the address as a byte array.
* The contents of src is copied into the new BinaryRefAddr.
*/
public BinaryRefAddr(String addrType, byte[] src) {
this(addrType, src, 0, src.length);
}
/**
* Constructs a new instance of BinaryRefAddr using its address type and
* a region of a byte array for contents.
*
* @param addrType A non-null string describing the type of the address.
* @param src The non-null contents of the address as a byte array.
* The contents of src is copied into the new BinaryRefAddr.
* @param offset The starting index in src to get the bytes.
* 0 <= offset <= src.length.
* @param count The number of bytes to extract from src.
* 0 <= count <= src.length-offset.
*/
public BinaryRefAddr(String addrType, byte[] src, int offset, int count) {
super(addrType);
buf = new byte[count];
System.arraycopy(src, offset, buf, 0, count);
}
/**
* Retrieves the contents of this address as an Object.
* The result is a byte array.
* Changes to this array will affect this BinaryRefAddr's contents.
* Programs are recommended against changing this array's contents
* and to lock the buffer if they need to change it.
*
* @return The non-null buffer containing this address's contents.
*/
public Object getContent() {
return buf;
}
/**
* Determines whether obj is equal to this address. It is equal if
=1= |