@PublicApi public final class

PortUtil

extends Object
java.lang.Object
   ↳ com.atlassian.jira.util.PortUtil

@PublicApi

This class is designed for plugins to consume (call its methods).

Clients of @PublicApi can expect that programs compiled against a given version will remain binary compatible with later versions of the @PublicApi as per each product's API policy as long as the client does not implement/extend @PublicApi interfaces or classes (refer to each product's API policy for the exact guarantee---usually binary compatibility is guaranteed at least across minor versions).

Note: since @PublicApi interfaces and classes are not designed to be implemented or extended by clients, we may perform certain types of binary-incompatible changes to these classes and interfaces, but these will not affect well-behaved clients that do not extend/implement these types (in general, only classes and interfaces annotated with @PublicSpi are safe to extend/implement).

Class Overview

Class that validates the value of a TCP/UDP port.

Summary

Constants
int MAX_PORT
int MIN_PORT
Public Methods
static boolean isValidPort(int port)
Tells the caller of the passed int represents a valid TCP/UDP port.
static boolean isValidPort(String port)
Tells the caller of the passed string represents a valid TCP/UDP port.
static int parsePort(String port)
Return the TCP/UDP port contained in the passed port string.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int MAX_PORT

Constant Value: 65535 (0x0000ffff)

public static final int MIN_PORT

Constant Value: 0 (0x00000000)

Public Methods

public static boolean isValidPort (int port)

Tells the caller of the passed int represents a valid TCP/UDP port.

Parameters
port the int to check.
Returns
  • true if the passed string is a valid port or false otherwise.

public static boolean isValidPort (String port)

Tells the caller of the passed string represents a valid TCP/UDP port.

Parameters
port the string to check.
Returns
  • true if the passed string is a valid port or false otherwise.

public static int parsePort (String port)

Return the TCP/UDP port contained in the passed port string. Returns -1 if the passed string is not a valid port.

Parameters
port the string to get the port from.
Returns
  • a valid port if the string contains a valid port, or -1 otherwise.