Savarese.Org

org.savarese.vserv.tcpip
Class OctetConverter

java.lang.Object
  extended byorg.savarese.vserv.tcpip.OctetConverter

public final class OctetConverter
extends java.lang.Object

OctetConverter is a utility singleton class for converting IP octets to and from other representations.

Author:
Daniel F. Savarese

Method Summary
static void intToOctets(int address, byte[] octets)
          Same as intToOctets(address, octets, 0);
static void intToOctets(int address, byte[] octets, int offset)
          Converts a 32-bit word representation of an IPv4 address to a byte array of octets.
static void intToString(java.lang.StringBuffer buffer, int address)
          Converts a 32-bit word representation of an IPv4 address to a string representation.
static void longToOctets(long address, byte[] octets)
          Same as longToOctets(address, octets, 0);
static void longToOctets(long address, byte[] octets, int offset)
          Converts a 64-bit word to a byte array of octets.
static int octetsToInt(byte[] octets)
          Same as octetsToInt(octets, 0);
static int octetsToInt(byte[] octets, int offset)
          Converts a set of IPv4 octets to a 32-bit word.
static long octetsToLong(byte[] octets)
          Same as octetsToLong(octets, 0);
static long octetsToLong(byte[] octets, int offset)
          Converts a set of octets to a 64-bit word.
static void octetsToString(java.lang.StringBuffer buffer, byte[] octets)
          Same as octetsToString(buffer, octets, 0);
static void octetsToString(java.lang.StringBuffer buffer, byte[] octets, int offset)
          Converts a set of IPv4 octets to a string representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

octetsToInt

public static final int octetsToInt(byte[] octets,
                                    int offset)
Converts a set of IPv4 octets to a 32-bit word.

Parameters:
octets - A byte array containing the IPv4 octets.
offset - The offset into the array where the octets start.
Returns:
The 32-bit word representation of the IPv4 address.

octetsToInt

public static final int octetsToInt(byte[] octets)
Same as octetsToInt(octets, 0);


octetsToLong

public static final long octetsToLong(byte[] octets,
                                      int offset)
Converts a set of octets to a 64-bit word.

Parameters:
octets - A byte array containing the octets.
offset - The offset into the array where the octets start.
Returns:
The 64-bit word representation of the octets.

octetsToLong

public static final long octetsToLong(byte[] octets)
Same as octetsToLong(octets, 0);


octetsToString

public static final void octetsToString(java.lang.StringBuffer buffer,
                                        byte[] octets,
                                        int offset)
Converts a set of IPv4 octets to a string representation.

Parameters:
buffer - The StringBuffer to which to append the string.
octets - A byte array containing the IPv4 octets.
offset - The offset into the array where the octets start.

octetsToString

public static final void octetsToString(java.lang.StringBuffer buffer,
                                        byte[] octets)
Same as octetsToString(buffer, octets, 0);


intToString

public static final void intToString(java.lang.StringBuffer buffer,
                                     int address)
Converts a 32-bit word representation of an IPv4 address to a string representation.

Parameters:
buffer - The StringBuffer to which to append the string.
address - The 32-bit word representation of the address.

intToOctets

public static final void intToOctets(int address,
                                     byte[] octets,
                                     int offset)
Converts a 32-bit word representation of an IPv4 address to a byte array of octets.

Parameters:
address - The 32-bit word representation of the IPv4 address.
octets - The byte array in which to store the IPv4 octets.
offset - The offset into the array where the octets start.

intToOctets

public static final void intToOctets(int address,
                                     byte[] octets)
Same as intToOctets(address, octets, 0);


longToOctets

public static final void longToOctets(long address,
                                      byte[] octets,
                                      int offset)
Converts a 64-bit word to a byte array of octets.

Parameters:
address - The 64-bit word.
octets - The byte array in which to store octets.
offset - The offset into the array where the octets start.

longToOctets

public static final void longToOctets(long address,
                                      byte[] octets)
Same as longToOctets(address, octets, 0);


Savarese.Org

Copyright © 2004-2005 Daniel F. Savarese. All Rights Reserved.