Class ResolutionEntryFlyweight

All Implemented Interfaces:
Comparable<DirectBuffer>, AtomicBuffer, DirectBuffer, MutableDirectBuffer

public class ResolutionEntryFlyweight extends HeaderFlyweight
Flyweight for Resolution Entry header.

Protocol Specification wiki page.

  • Field Details

    • RES_TYPE_NAME_TO_IP4_MD

      public static final byte RES_TYPE_NAME_TO_IP4_MD
      Resolution type field flag for IPv4.
      See Also:
    • RES_TYPE_NAME_TO_IP6_MD

      public static final byte RES_TYPE_NAME_TO_IP6_MD
      Resolution type field flag for IPv6.
      See Also:
    • ADDRESS_LENGTH_IP4

      public static final int ADDRESS_LENGTH_IP4
      Length of an IPv4 address in bytes.
      See Also:
    • ADDRESS_LENGTH_IP6

      public static final int ADDRESS_LENGTH_IP6
      Length of an IPv6 address in bytes.
      See Also:
    • SELF_FLAG

      public static final short SELF_FLAG
      (S) - Self flag.
      See Also:
    • RES_TYPE_FIELD_OFFSET

      public static final int RES_TYPE_FIELD_OFFSET
      Offset in the frame at which the res-type (resolution type) field begins.
      See Also:
    • RES_FLAGS_FIELD_OFFSET

      public static final int RES_FLAGS_FIELD_OFFSET
      Offset in the frame at which the res-flags field begins.
      See Also:
    • UDP_PORT_FIELD_OFFSET

      public static final int UDP_PORT_FIELD_OFFSET
      Offset in the frame at which the UDP port field begins.
      See Also:
    • AGE_IN_MS_FIELD_OFFSET

      public static final int AGE_IN_MS_FIELD_OFFSET
      Offset in the frame at which the age field begins.
      See Also:
    • ADDRESS_FIELD_OFFSET

      public static final int ADDRESS_FIELD_OFFSET
      Offset in the frame at which the IP address field begins.
      See Also:
    • MAX_NAME_LENGTH

      public static final int MAX_NAME_LENGTH
      Maximum length allowed for a name.
      See Also:
  • Constructor Details

    • ResolutionEntryFlyweight

      public ResolutionEntryFlyweight()
      Default constructor which can later be used to wrap a frame.
    • ResolutionEntryFlyweight

      public ResolutionEntryFlyweight(UnsafeBuffer buffer)
      Construct the flyweight over a frame.
      Parameters:
      buffer - containing the frame.
    • ResolutionEntryFlyweight

      public ResolutionEntryFlyweight(ByteBuffer buffer)
      Construct the flyweight over a frame.
      Parameters:
      buffer - containing the frame.
  • Method Details

    • resType

      public ResolutionEntryFlyweight resType(byte type)
      Set the protocol type of the resolution.
      Parameters:
      type - of the resolution entry protocol.
      Returns:
      this for a fluent API.
      See Also:
    • resType

      public byte resType()
      Get the protocol type of the resolution entry.
      Returns:
      the protocol type of the resolution entry.
      See Also:
    • flags

      public ResolutionEntryFlyweight flags(short flags)
      Set the flags for the resolution entry.
      Overrides:
      flags in class HeaderFlyweight
      Parameters:
      flags - field value.
      Returns:
      this for a fluent API.
      See Also:
    • flags

      public short flags()
      Get the flags for the resolution entry.
      Overrides:
      flags in class HeaderFlyweight
      Returns:
      the flags for the resolution entry.
    • udpPort

      public ResolutionEntryFlyweight udpPort(int udpPort)
      Set the UDP port of the resolver with a given name.
      Parameters:
      udpPort - of the resolver with a given name.
      Returns:
      this for a fluent API.
    • udpPort

      public int udpPort()
      Get the UDP port of the resolver with a given name.
      Returns:
      the UDP port of the resolver with a given name.
    • ageInMs

      public ResolutionEntryFlyweight ageInMs(int ageInMs)
      Set the age of the entry based on last observed activity.
      Parameters:
      ageInMs - of the entry based on last observed activity.
      Returns:
      this for a fluent API.
    • ageInMs

      public int ageInMs()
      Get the age of the entry based on last observed activity.
      Returns:
      the age of the entry based on last observed activity.
    • putAddress

      public ResolutionEntryFlyweight putAddress(byte[] address)
      Put the address into the resolution entry. It must come after calling resType(byte).
      Parameters:
      address - to be written for the resolution entry.
      Returns:
      this for a fluent API.
    • getAddress

      public int getAddress(byte[] dstBuffer)
      Get the address for the entry by copying it into the destination buffer.
      Parameters:
      dstBuffer - into which the address will be copied.
      Returns:
      length of the address copied.
    • appendAddress

      public void appendAddress(Appendable appendable)
      Append the address to the provided Appendable in ASCII format.
      Parameters:
      appendable - to which the address will be appended.
    • putName

      public ResolutionEntryFlyweight putName(byte[] name)
      Put the name for the resolution entry into the frame.
      Parameters:
      name - for the resolution entry.
      Returns:
      this for a fluent API.
    • getName

      public int getName(byte[] dstBuffer)
      Get the name for the entry by copying it into the destination buffer.
      Parameters:
      dstBuffer - into which the name will be copied.
      Returns:
      the number of bytes copied.
    • appendName

      public void appendName(StringBuilder appendable)
      Append the name to the provided Appendable in ASCII format.
      Parameters:
      appendable - to which the name will be appended.
    • entryLength

      public int entryLength()
      Total length of the entry in bytes.
      Returns:
      total length of the entry in bytes.
    • nameOffset

      public static int nameOffset(byte resType)
      Offset in the entry at which the name begins depending on resolution type.
      Parameters:
      resType - for the protocol family.
      Returns:
      offset in the entry at which the name field begins.
    • entryLengthRequired

      public static int entryLengthRequired(byte resType, int nameLength)
      Calculate the length required for the entry when encoded.
      Parameters:
      resType - of the entry.
      nameLength - of the name in the entry.
      Returns:
      the required length of the entry in bytes.
    • addressLength

      public static int addressLength(byte resType)
      Get the length of the address given a resolution type.
      Parameters:
      resType - to lookup address length for.
      Returns:
      the length of the address given a resolution type.
    • isAnyLocalAddress

      public static boolean isAnyLocalAddress(byte[] address, int addressLength)
      Is the local address a match for binding a socket to ANY IP.
      Parameters:
      address - to check which can be IPv4 or IPv6.
      addressLength - of the address in bytes.
      Returns:
      true if address is an ANY match otherwise false.