public abstract class

IPUtil

extends Object
java.lang.Object
   ↳ com.ericsson.research.trap.utils.IPUtil

Class Overview

A collection of checks for IP addresses. These utilities provide convenience methods not covered by the Java API.

Summary

Public Methods
static String getAddressForURI(InetAddress address)
Gets a URI-safe address of an InetAddress.
static InetAddress[] getPublicAddresses()
Gets an array of the publicly accesisble IP addresses of the JVM.
static boolean isLocal(InetAddress address)
Checks whether an InetAddress is a local (=virtual address space).
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static String getAddressForURI (InetAddress address)

Gets a URI-safe address of an InetAddress. For example, returns 127.0.0.1 for localhost in IPv4, and [::1] for localhost in IPv6.

Parameters
address The address to convert
Returns
  • A string representation of the address that is safe to insert into a URI.

public static InetAddress[] getPublicAddresses ()

Gets an array of the publicly accesisble IP addresses of the JVM.

Returns
  • an array of the publicly accesisble IP addresses of the JVM.

public static boolean isLocal (InetAddress address)

Checks whether an InetAddress is a local (=virtual address space). For example, 127.0.0.1 returns true, while 8.8.8.8 returns false.

Parameters
address The address to verify.
Returns
  • true if the address is defined in an address space that is routable from the Internet, false otherwise.