public byte[] encode(){
  char type=getAttributeType();
  if (!isTypeValid(type))   throw new IllegalStateException(((int)type) + "is not a valid address attribute!");
  byte binValue[]=new byte[HEADER_LENGTH + getDataLength()];
  binValue[0]=(byte)(type >> 8);
  binValue[1]=(byte)(type & 0x00FF);
  binValue[2]=(byte)(getDataLength() >> 8);
  binValue[3]=(byte)(getDataLength() & 0x00FF);
  binValue[4]=0x00;
  binValue[5]=getFamily();
  binValue[6]=(byte)(getPort() >> 8);
  binValue[7]=(byte)(getPort() & 0x00FF);
  if (getFamily() == ADDRESS_FAMILY_IPV6) {
    System.arraycopy(getAddressBytes(),0,binValue,8,16);
  }
 else {
    System.arraycopy(getAddressBytes(),0,binValue,8,4);
  }
  return binValue;
}

public byte [ ] encode ( ) { char type = getAttributeType ( ) ; if ( ! isTypeValid ( type ) ) throw new IllegalStateException ( ( ( int ) type ) + "is not a valid address attribute!" ) ; byte binValue [ ] = new byte [ HEADER_LENGTH + getDataLength ( ) ] ; binValue [ 0 ] = ( byte ) ( type > > 8 ) ; binValue [ 1 ] = ( byte ) ( type & 0x00FF ) ; binValue [ 2 ] = ( byte ) ( getDataLength ( ) > > 8 ) ; binValue [ 3 ] = ( byte ) ( getDataLength ( ) & 0x00FF ) ; binValue [ 4 ] = 0x00 ; binValue [ 5 ] = getFamily ( ) ; binValue [ 6 ] = ( byte ) ( getPort ( ) > > 8 ) ; binValue [ 7 ] = ( byte ) ( getPort ( ) & 0x00FF ) ; if ( getFamily ( ) == ADDRESS_FAMILY_IPV6 ) { System . arraycopy ( getAddressBytes ( ) , 0 , binValue , 8 , 16 ) ; } else { System . arraycopy ( getAddressBytes ( ) , 0 , binValue , 8 , 4 ) ; } return binValue ; }
returns a binary representation of this attribute .
