Class Port

All Implemented Interfaces:
DtoFactory<Port>, Serializable, Comparable<IPortRange>

public final class Port extends IPortRange implements Serializable, DtoFactory<Port>
Several network resources on a Server require a unique port. All of the possible network ports are represented by Port.
Author:
AO Industries, Inc.
See Also:
  • Method Details

    • validate

      public static ValidationResult validate(int port, Protocol protocol)
    • valueOf

      public static Port valueOf(int port, Protocol protocol) throws ValidationException
      Throws:
      ValidationException
    • equals

      public boolean equals(Object obj)
      Port instances are cached and may be safely compared by identity.
      Specified by:
      equals in class IPortRange
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in class IPortRange
    • toString

      public String toString()
      Specified by:
      toString in class IPortRange
      Returns:
      The port and protocol, such as 110/TCP.
      See Also:
    • getFrom

      public int getFrom()
      Description copied from class: IPortRange
      Gets the first port number in the range.
      Specified by:
      getFrom in class IPortRange
    • getFromPort

      public Port getFromPort()
      Description copied from class: IPortRange
      Gets the first port number in the range as a Port.
      Specified by:
      getFromPort in class IPortRange
    • getTo

      public int getTo()
      Description copied from class: IPortRange
      Gets the last port number in the range.
      Specified by:
      getTo in class IPortRange
    • getToPort

      public Port getToPort()
      Description copied from class: IPortRange
      Gets the last port number in the range as a Port.
      Specified by:
      getToPort in class IPortRange
    • getPort

      public int getPort()
    • isUser

      public boolean isUser()
      Determines if this is a port that may be bound by non-root processes.
      Returns:
      true when the port is >= 1024.
    • getDto

      public Port getDto()
      Specified by:
      getDto in interface DtoFactory<Port>
    • splitBelow

      public IPortRange splitBelow(int below)
      Specified by:
      splitBelow in class IPortRange
      Returns:
      The part of this port range below, and not including, the given port or null if none.
    • splitAbove

      public IPortRange splitAbove(int above)
      Specified by:
      splitAbove in class IPortRange
      Returns:
      The part of this port range above, and not including, the given port or null if none.