Package stanford.netdb.IP
Class IP
- java.lang.Object
-
- stanford.netdb.IP.IP
-
- All Implemented Interfaces:
java.io.Serializable,java.util.Comparator
public abstract class IP extends java.lang.Object implements java.util.Comparator, java.io.SerializableThis class contains a number of constants used in the IPaddress and the Prefix classes.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static intCOMPRESSEDCompressed IPv6 addresses have the longest set of 'empty' segments replaced with the double colon.static intDEFAULT_RADIXThis is the radix that will be used, if one isn't explicitly specified.static intEXPANDEDThe expanded format has all segments present without leading zeroes.static intIPv4static intIPv4_bitsstatic java.lang.StringIPv4_normal_prefixInternally normalized form of IPv4_prefix.static java.lang.StringIPv4_prefixThe normalized IPv6 prefix that IPv4 addresses should reside in.static java.math.BigIntegerIPv4_prefix_numberNumeric value of IPv4_prefix.static java.lang.StringIPv4_prefix_shortCompressed form of IPv4_prefix.static java.lang.StringIPv4_regexNon-capturing regular expression matching any valid IPv4 address.static intIPv6static intIPv6_bitsstatic java.lang.StringIPv6_regexNon-capturing regular expression matching any valid IPv6 address.static java.lang.StringIPv6_regex_6hex_4decNon-capturing regular expression matching an IPv6 address when all segments have one or more characters with the last segments represented as an IPv4 address.static java.lang.StringIPv6_regex_6hex_4dec_compressedNon-capturing regular expression matching a compressed IPv6 address, and the last segments are represented as an IPv4 address.static java.lang.StringIPv6_regex_compressedNon-capturing regular expression matching a compressed IPv6 address.static java.lang.StringIPv6_regex_not_compressedNon-capturing regular expression matching an IPv6 address when all segments have one or more characters.static intIPv64The IP64 address is an IPv6 address with the last two segments represented as an IPv4 address.static intLOWERDisplay the IPv6 address in lower case.static intNORMALIZEDA normalized address has all segments present, and has all leading zeroes in the address.static intPASSEDUse the same format that the IPaddress or Prefix was created with.static intPREFERREDName of the expanded format taken from RFC 4291 Section 2.2 Item 1.static intRADIXIP addresses can be converted to a number in an arbitrary radix.static java.lang.BooleanSUPPRESS_SORT_ERRORSSuppress the errors that would be thrown while sorting.static intUPPERDisplay the IPv6 address in upper case.static java.lang.Stringv4_setNon-capturing regular expression matching a number in the range 0-255.static java.lang.Stringv6_setRegular expression that matches one segment of an IPv6 address.
-
Constructor Summary
Constructors Constructor Description IP()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static intcmp(IP ip1, IP ip2)Compare ip1 to ip2.abstract intcompare(java.lang.Object ip1, java.lang.Object ip2)Compare ip1 to ip2.abstract intcompareTo(java.lang.Object ip)Compare the current IP to ip.booleanequals(IP ip)Check if an IP is equal to the current IP.booleangt(IP ip)Check if an IP is greater than the current IP.booleangte(IP ip)Check if an IP is greater than or equal to the current IP.booleanlt(IP ip)Check if an IP is less than the current IP.booleanlte(IP ip)Check if an IP is less than or equal to the current IP.java.lang.StringtoCompressedString()Convenience method for toString (IP.COMPRESSED).java.lang.StringtoCompressedString(int flags)Convenience method for toString (IP.COMPRESSED).java.lang.StringtoExpandedString()Convenience method for toString (IP.EXPANDED).java.lang.StringtoExpandedString(int flags)Convenience method for toString (IP.EXPANDED).java.lang.StringtoIPv4String()Convenience method for toString (IP.IPv4).java.lang.StringtoIPv4String(int flags)Convenience method for toString (IP.IPv4).java.lang.StringtoIPv6String()Convenience method for toString (IP.IPv6).java.lang.StringtoIPv6String(int flags)Convenience method for toString (IP.IPv6).java.lang.StringtoNormalizedString()Convenience method for toString (IP.NORMALIZED).java.lang.StringtoNormalizedString(int flags)Convenience method for toString (IP.NORMALIZED).java.lang.StringtoPassedString()Convenience method for toString (IP.PASSED).java.lang.StringtoPassedString(int flags)Convenience method for toString (IP.PASSED).java.lang.StringtoPreferredString()Convenience method for toString (IP.PREFERRED).java.lang.StringtoPreferredString(int flags)Convenience method for toString (IP.PREFERRED).abstract java.lang.StringtoString(int flags)
-
-
-
Field Detail
-
SUPPRESS_SORT_ERRORS
public static java.lang.Boolean SUPPRESS_SORT_ERRORS
Suppress the errors that would be thrown while sorting. This will effectively cause malformed addresses to be sorted to the end of whatever is being sorted.
-
IPv4
public static final int IPv4
- See Also:
- Constant Field Values
-
IPv6
public static final int IPv6
- See Also:
- Constant Field Values
-
IPv64
public static final int IPv64
The IP64 address is an IPv6 address with the last two segments represented as an IPv4 address.Example: 1:2::6:1.2.3.4
- See Also:
- Constant Field Values
-
PASSED
public static final int PASSED
Use the same format that the IPaddress or Prefix was created with.- See Also:
- Constant Field Values
-
COMPRESSED
public static final int COMPRESSED
Compressed IPv6 addresses have the longest set of 'empty' segments replaced with the double colon. This flag has no effect with an IPv4 address.Example: 1:2:3::8
- See Also:
- Constant Field Values
-
NORMALIZED
public static final int NORMALIZED
A normalized address has all segments present, and has all leading zeroes in the address.Example: 001.002.003.004 or 0001:0002:0003:0000:0000:0006:0007:0008
- See Also:
- Constant Field Values
-
PREFERRED
public static final int PREFERRED
Name of the expanded format taken from RFC 4291 Section 2.2 Item 1.- See Also:
- Constant Field Values
-
EXPANDED
public static final int EXPANDED
The expanded format has all segments present without leading zeroes. This flag has no effect with an IPv4 address.Example: 1:2:0:0:0:0:7:8
- See Also:
- Constant Field Values
-
LOWER
public static final int LOWER
Display the IPv6 address in lower case.- See Also:
- Constant Field Values
-
UPPER
public static final int UPPER
Display the IPv6 address in upper case.- See Also:
- Constant Field Values
-
RADIX
public static final int RADIX
IP addresses can be converted to a number in an arbitrary radix.- See Also:
- Constant Field Values
-
DEFAULT_RADIX
public static int DEFAULT_RADIX
This is the radix that will be used, if one isn't explicitly specified.
-
IPv4_prefix
public static final java.lang.String IPv4_prefix
The normalized IPv6 prefix that IPv4 addresses should reside in.- See Also:
- Constant Field Values
-
IPv4_prefix_short
public static final java.lang.String IPv4_prefix_short
Compressed form of IPv4_prefix.- See Also:
- Constant Field Values
-
IPv4_normal_prefix
public static final java.lang.String IPv4_normal_prefix
Internally normalized form of IPv4_prefix.
-
IPv4_prefix_number
public static final java.math.BigInteger IPv4_prefix_number
Numeric value of IPv4_prefix.
-
v4_set
public static final java.lang.String v4_set
Non-capturing regular expression matching a number in the range 0-255.- See Also:
- Constant Field Values
-
v6_set
public static final java.lang.String v6_set
Regular expression that matches one segment of an IPv6 address.- See Also:
- Constant Field Values
-
IPv4_regex
public static final java.lang.String IPv4_regex
Non-capturing regular expression matching any valid IPv4 address.- See Also:
- Constant Field Values
-
IPv6_regex_not_compressed
public static final java.lang.String IPv6_regex_not_compressed
Non-capturing regular expression matching an IPv6 address when all segments have one or more characters.- See Also:
- Constant Field Values
-
IPv6_regex_6hex_4dec
public static final java.lang.String IPv6_regex_6hex_4dec
Non-capturing regular expression matching an IPv6 address when all segments have one or more characters with the last segments represented as an IPv4 address.- See Also:
- Constant Field Values
-
IPv6_regex_compressed
public static final java.lang.String IPv6_regex_compressed
Non-capturing regular expression matching a compressed IPv6 address.- See Also:
- Constant Field Values
-
IPv6_regex_6hex_4dec_compressed
public static final java.lang.String IPv6_regex_6hex_4dec_compressed
Non-capturing regular expression matching a compressed IPv6 address, and the last segments are represented as an IPv4 address.- See Also:
- Constant Field Values
-
IPv6_regex
public static final java.lang.String IPv6_regex
Non-capturing regular expression matching any valid IPv6 address.- See Also:
- Constant Field Values
-
IPv4_bits
public static final int IPv4_bits
- See Also:
- Constant Field Values
-
IPv6_bits
public static final int IPv6_bits
- See Also:
- Constant Field Values
-
-
Method Detail
-
toString
public abstract java.lang.String toString(int flags)
- Parameters:
flags- bit field of flags defined in the IP class. The following flags are understood:
EXPANDED (or PREFERRED), NORMALIZED, COMPRESSED, PASSED, IPv4, IPv6, IPv64, LOWER, UPPER, RADIXSetting both the IPv4 and IPv6 flag will return an IPv6 address with the lower 32 bits displayed as an IPv4 address.
Setting the IPv4 flag on an IPv6 address will return ONLY the lower 32 bits in an IPv4 format.
The following precedences are used when processing flags:
RADIX, PASSED, IPv4 and IPv6 (IPv4 and IPv6 have equal precedence)
EXPANDED (or PREFERRED), NORMALIZED, COMPRESSED
LOWER, UPPER- See Also:
EXPANDED,PREFERRED,NORMALIZED,COMPRESSED,PASSED,IPv4,IPv6,IPv64,LOWER,UPPER,RADIX
-
toCompressedString
public java.lang.String toCompressedString()
Convenience method for toString (IP.COMPRESSED).
-
toNormalizedString
public java.lang.String toNormalizedString()
Convenience method for toString (IP.NORMALIZED).
-
toExpandedString
public java.lang.String toExpandedString()
Convenience method for toString (IP.EXPANDED).
-
toPreferredString
public java.lang.String toPreferredString()
Convenience method for toString (IP.PREFERRED).
-
toPassedString
public java.lang.String toPassedString()
Convenience method for toString (IP.PASSED).
-
toIPv4String
public java.lang.String toIPv4String()
Convenience method for toString (IP.IPv4).
-
toIPv6String
public java.lang.String toIPv6String()
Convenience method for toString (IP.IPv6).
-
toCompressedString
public java.lang.String toCompressedString(int flags)
Convenience method for toString (IP.COMPRESSED).
-
toNormalizedString
public java.lang.String toNormalizedString(int flags)
Convenience method for toString (IP.NORMALIZED).
-
toPreferredString
public java.lang.String toPreferredString(int flags)
Convenience method for toString (IP.PREFERRED).
-
toExpandedString
public java.lang.String toExpandedString(int flags)
Convenience method for toString (IP.EXPANDED).
-
toPassedString
public java.lang.String toPassedString(int flags)
Convenience method for toString (IP.PASSED).
-
toIPv4String
public java.lang.String toIPv4String(int flags)
Convenience method for toString (IP.IPv4).
-
toIPv6String
public java.lang.String toIPv6String(int flags)
Convenience method for toString (IP.IPv6).
-
lt
public boolean lt(IP ip)
Check if an IP is less than the current IP.- Returns:
- true if this < ip
-
lte
public boolean lte(IP ip)
Check if an IP is less than or equal to the current IP.- Returns:
- true if this <= ip
-
gt
public boolean gt(IP ip)
Check if an IP is greater than the current IP.- Returns:
- true if this > ip
-
gte
public boolean gte(IP ip)
Check if an IP is greater than or equal to the current IP.- Returns:
- true if this >= ip
-
equals
public boolean equals(IP ip)
Check if an IP is equal to the current IP.- Returns:
- true if this == ip
-
cmp
public static int cmp(IP ip1, IP ip2)
Compare ip1 to ip2.- See Also:
compareTo(Object)
-
compare
public abstract int compare(java.lang.Object ip1, java.lang.Object ip2)Compare ip1 to ip2.- Specified by:
comparein interfacejava.util.Comparator- See Also:
compareTo(Object),SUPPRESS_SORT_ERRORS
-
compareTo
public abstract int compareTo(java.lang.Object ip)
Compare the current IP to ip.- Returns:
- -1 if this < ip
1 if this > ip
0 if this = ip - See Also:
SUPPRESS_SORT_ERRORS
-
-