Package ru.bitel.common.inet

# Class IpAddress

java.lang.Object
ru.bitel.common.inet.IpAddress

All Implemented Interfaces:
  `java.io.Serializable`, `java.lang.Comparable<IpAddress>`

    public class IpAddress
    extends java.lang.Object
    implements java.lang.Comparable<IpAddress>, java.io.Serializable

See Also:
  Serialized Form

- ## Field Summary

  Fields
  Modifier and Type | Field | Description
  --- | --- | ---
  `byte[]` | `address` |
  `static java.util.Comparator<byte[]>` | `comparator` |
  `static IpAddress` | `IPV6_ZERO_ADDRESS` |
  `static IpAddress` | `ZERO_ADDRESS` |

- ## Constructor Summary

  Constructors
  Constructor | Description
  --- | ---
  `IpAddress()` |
  `IpAddress​(byte[] address)` |

- ## Method Summary

  Modifier and Type | Method | Description
  --- | --- | ---
  `static boolean` | `add​(byte[] ip, long delta)` | Прибавляем к адресу нужное нам количество. delta >=0
  `void` | `clear()` |
  `IpAddress` | `clone()` |
  `static int` | `compare​(byte[] v1, byte[] v2)` |
  `static int` | `compare​(byte[] v1, int i, int len1, byte[] v2, int j, int len2)` |
  `int` | `compareTo​(IpAddress o)` |
  `static byte[]` | `convertBigIntToIp4Address​(java.math.BigInteger bigInteger)` |
  `static byte[]` | `convertBigIntToIp6Address​(java.math.BigInteger bigInteger)` |
  `static java.math.BigInteger` | `convertIp4AddresToBigInt​(byte[] address)` |
  `static java.math.BigInteger` | `convertIp6AddresToBigInt​(byte[] address)` |
  `static boolean` | `decrement​(byte[] ip)` | Отнимаем один ip от адреса
  `static boolean` | `equals​(byte[] a, byte[] a2)` |
  `boolean` | `equals​(java.lang.Object obj)` |
  `static java.lang.String` | `formatRange​(byte[] from, byte[] to)` | Deprecated. - use `IpRange.toString(byte[], byte[])` Форматирует диапазон адресов к виду от-до.
  `static java.lang.String` | `formatRange​(IpAddress from, IpAddress to)` | Deprecated. - use `IpRange.toString(IpAddress, IpAddress)` Форматирует диапазон адресов к виду от-до.
  `int` | `hashCode()` |
  `static int` | `hashCode​(byte[] a)` |
  `static boolean` | `increment​(byte[] ip)` |
  `static boolean` | `increment​(byte[] ip, int fromBit)` | Инкрементирует адрес.
  `static boolean` | `instersect​(byte[] addressFrom, byte[] addressTo, byte[] addressFrom2, byte[] addressTo2)` | Deprecated. - use `IpRange.intersects(byte[], byte[], byte[], byte[])` функция пересечения отрезков.
  `static boolean` | `ipInRange​(byte[] ip, byte[] addressFrom, byte[] addressTo)` | Deprecated. - use `IpRange.inRange(byte[], byte[], byte[], byte[])`
  `static byte[]` | `newAndDecrement​(byte[] ip)` |
  `static byte[]` | `newAndIncrement​(byte[] ip)` |
  `static boolean` | `nextPrefix​(byte[] ip, int prefixLength)` | Возвращает префикс для указанной длины префикса.
  `static boolean` | `rangeInRange​(byte[] addressFrom, byte[] addressTo, byte[] addressFrom2, byte[] addressTo2)` | Deprecated. - use `IpRange.inRange(byte[], byte[], byte[], byte[])` функция вхождения одного отрезка в другой.
  `static boolean` | `substract​(byte[] ip, int delta)` | Отнимем от адреса нужное нам количество. delta >=0
  `static java.lang.String` | `toRFCString​(byte[] address)` |
  `static void` | `toRFCString​(byte[] address, java.lang.StringBuilder sb)` |
  `java.lang.String` | `toString()` |
  `static java.lang.String` | `toString​(byte[] address)` |
  `static void` | `toString​(byte[] address, java.lang.StringBuilder sb)` |

  ### Methods inherited from class java.lang.Object

  `finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### ZERO_ADDRESS

    public static final IpAddress ZERO_ADDRESS

  - ### IPV6_ZERO_ADDRESS

    public static final IpAddress IPV6_ZERO_ADDRESS

  - ### address

    public byte[] address

  - ### comparator

    public static final java.util.Comparator<byte[]> comparator

- ## Constructor Details

  - ### IpAddress

    public IpAddress()

  - ### IpAddress

    public IpAddress​(byte[] address)

- ## Method Details

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `java.lang.Object`

  - ### hashCode

    public static int hashCode​(byte[] a)

  - ### equals

    public boolean equals​(java.lang.Object obj)
    Overrides:
      `equals` in class `java.lang.Object`

  - ### equals

    public static boolean equals​(byte[] a, byte[] a2)

  - ### clear

    public void clear()

  - ### toString

    public java.lang.String toString()
    Overrides:
      `toString` in class `java.lang.Object`

  - ### toString

    public static java.lang.String toString​(byte[] address)

  - ### toString

    public static void toString​(byte[] address, java.lang.StringBuilder sb)

  - ### compare

    public static final int compare​(byte[] v1, byte[] v2)

  - ### compare

    public static final int compare​(byte[] v1, int i, int len1, byte[] v2, int j, int len2)

  - ### newAndIncrement

    public static byte[] newAndIncrement​(byte[] ip)

  - ### increment

    public static boolean increment​(byte[] ip)

  - ### increment

    public static boolean increment​(byte[] ip, int fromBit)
    Инкрементирует адрес.
    Parameters:
      `ip` -
      `fromBit` - позиция бита с конца
    Returns:

  - ### add

    public static boolean add​(byte[] ip, long delta)
    Прибавляем к адресу нужное нам количество. delta >=0
    Parameters:
      `ip` -
      `delta` -
    Returns:

  - ### substract

    public static boolean substract​(byte[] ip, int delta)
    Отнимем от адреса нужное нам количество. delta >=0

  - ### decrement

    public static boolean decrement​(byte[] ip)
    Отнимаем один ip от адреса
    Parameters:
      `ip` -
    Returns:

  - ### newAndDecrement

    public static byte[] newAndDecrement​(byte[] ip)

  - ### compareTo

    public int compareTo​(IpAddress o)
    Specified by:
      `compareTo` in interface `java.lang.Comparable<IpAddress>`

  - ### clone

    public IpAddress clone()
    Overrides:
      `clone` in class `java.lang.Object`

  - ### instersect

    @Deprecated public static boolean instersect​(byte[] addressFrom, byte[] addressTo, byte[] addressFrom2, byte[] addressTo2)
    Deprecated.
    - use `IpRange.intersects(byte[], byte[], byte[], byte[])` функция пересечения отрезков. Все параметры не пустые , иначе NullPointerException
    Parameters:
      `addressFrom` -
      `addressTo` -
      `addressFrom2` -
      `addressTo2` -
    Returns:

  - ### rangeInRange

    @Deprecated public static boolean rangeInRange​(byte[] addressFrom, byte[] addressTo, byte[] addressFrom2, byte[] addressTo2)
    Deprecated.
    - use `IpRange.inRange(byte[], byte[], byte[], byte[])` функция вхождения одного отрезка в другой. Все параметры не пустые , иначе NullPointerException.
    Parameters:
      `addressFrom` -
      `addressTo` -
      `addressFrom2` -
      `addressTo2` -
    Returns:

  - ### ipInRange

    @Deprecated public static boolean ipInRange​(byte[] ip, byte[] addressFrom, byte[] addressTo)
    Deprecated.
    - use `IpRange.inRange(byte[], byte[], byte[], byte[])`
    Parameters:
      `ip` -
      `addressFrom` -
      `addressTo` -
    Returns:

  - ### convertIp6AddresToBigInt

    public static java.math.BigInteger convertIp6AddresToBigInt​(byte[] address)
    Parameters:
      `address` -
    Returns:

  - ### convertIp4AddresToBigInt

    public static java.math.BigInteger convertIp4AddresToBigInt​(byte[] address)
    Parameters:
      `address` -
    Returns:

  - ### convertBigIntToIp4Address

    public static byte[] convertBigIntToIp4Address​(java.math.BigInteger bigInteger)
    Parameters:
      `bigInteger` -
    Returns:

  - ### convertBigIntToIp6Address

    public static byte[] convertBigIntToIp6Address​(java.math.BigInteger bigInteger)
    Parameters:
      `bigInteger` -
    Returns:

  - ### formatRange

    @Deprecated public static java.lang.String formatRange​(IpAddress from, IpAddress to)
    Deprecated.
    - use `IpRange.toString(IpAddress, IpAddress)` Форматирует диапазон адресов к виду от-до.
    Parameters:
      `from` -
      `to` -
    Returns:

  - ### formatRange

    @Deprecated public static java.lang.String formatRange​(byte[] from, byte[] to)
    Deprecated.
    - use `IpRange.toString(byte[], byte[])` Форматирует диапазон адресов к виду от-до.
    Parameters:
      `from` -
      `to` -
    Returns:

  - ### nextPrefix

    public static boolean nextPrefix​(byte[] ip, int prefixLength)
    Возвращает префикс для указанной длины префикса. Если в адресе не префиксные биты !=0, то возвращает следующий префикс.
    Parameters:
      `ip` -
      `prefixLength` -
    Returns:

  - ### toRFCString

    public static java.lang.String toRFCString​(byte[] address)

  - ### toRFCString

    public static void toRFCString​(byte[] address, java.lang.StringBuilder sb)