Package org.jppf.net

Class IPv6AddressPattern

Direct Known Subclasses:
IPv6AddressNetmask

public class IPv6AddressPattern extends AbstractIPAddressPattern
Represents a pattern used for IPv6 addresses inclusion and exclusion lists.
A pattern represents a single value or a range of values for each component of an IPv6 address.

Examples:

  • 1080:0:0:0:8:800:200C:417A represents a single IPv6 address
  • 1080:0:0:0:8:800:200C represents all IPv6 addresses in the range 1080:0:0:0:8:800:200C:0 - 1080:0:0:0:8:800:200C:FFFF
  • 1080:0:0:0:8:800 represents all IPv6 addresses in the range 1080:0:0:0:8:800:0:0 - 1080:0:0:0:8:800:FFFF:FFFF
  • 1080:0:0:0:8:800:200C-20FF represents all IP addresses where the first component is equal to 1080, the second to 0, ..., the 7th component in the range 200C - 200FF, and the 8th in the range 0 - FFFF (equivalent to 1080:0:0:0:8:800:200C-20FF:0-FFFF)

Syntax rules:

1. An empty component is considered as a 0-FFFF range. Examples:

  • :2:3:4:5:6:7:8 is equivalent to 0-FFFF:2:3:4:5:6:7:8
  • 1:2:3:4:5::7:8 is equivalent to 1:2:3:4:5:0-FFFF:7:8
  • 1:2:3:4:5:6:7: is equivalent to 1:2:3:4:5:6:7 and to 1:2:3:4:5:6:7:0-FFFF

2. Ranges with missing bounds but still including the "-" sign are interpreted as a range with the lower bound equal to zero for a missing lower bound, and an upper bound equal to 0xFFFF if the upper bound is missing. Examples:

  • -128 is equivalent to 0-128
  • 12- is equivalent to 12-FFFF
  • - is equivalent to an empty value and to 0-FFFF

3. Valid values for range bounds and single values are positive integers in the range 0 ... 0xFFFF. A pattern containing any invalid value will be ignored.

4. A pattern describing more than 8 components or containing characters other than hexadecimal digits, '-', ':' or spaces will be ignored.

Author:
Laurent Cohen
  • Constructor Details

    • IPv6AddressPattern

      public IPv6AddressPattern(String source) throws IllegalArgumentException
      Initialize this object with the specified string pattern.
      Parameters:
      source - the source pattern as a string.
      Throws:
      IllegalArgumentException - if the pattern is null or invalid.
  • Method Details

    • matches

      public boolean matches(InetAddress ip)
      Description copied from class: AbstractIPAddressPattern
      Determine whether the specified IP address matches this pattern. No check is made to verify that the IP address is valid.
      Overrides:
      matches in class AbstractIPAddressPattern
      Parameters:
      ip - the ip to match as a string.
      Returns:
      true if the address matches this pattern, false otherwise.
    • toString

      public String toString()
      Overrides:
      toString in class RangePattern
    • main

      public static void main(String[] args)
      Main method.
      Parameters:
      args - not used.