public class TXTextends Data
DNS TXT record payload for arbitrary text data.
Contains one or more text strings, commonly used for verification, policies, or other metadata. Each string is prefixed with a length byte.
  • Field Details

    • blob

      private final byte[] blob
      The record's bytes.
    • textCache

      private transient String textCache
      Cache of the text of the first string.
    • characterStringsCache

      private transient List<String> characterStringsCache
      Cache of the strings in the record.
  • Constructor Details

    • TXT

      public TXT(byte[] blob)
      Create a TXT record from its raw wire data.
      Parameters:
      blob - the raw TXT record data
  • Method Details

    • parse

      public static TXT parse(DataInputStream dis, int length) throws IOException
      Parse a TXT record's wire data, a sequence of length-prefixed strings.
      Parameters:
      dis - the stream positioned at the start of the record data
      length - how many bytes of record data to read
      Returns:
      a TXT record holding those bytes
      Throws:
      IOException - if the stream ends before length bytes have been read
    • getBlob

      public byte[] getBlob()
      Get the raw wire data of this record.
      Returns:
      copy of the raw blob data
    • getText

      public String getText()
      Return the strings joined by " / ", built once and then cached.
      Returns:
      the character strings joined by " / ", built once and then cached
    • getCharacterStrings

      public List<String> getCharacterStrings()
      Get the character strings of this record, decoding each as UTF-8.
      Returns:
      individual character strings as UTF-8 strings
    • getExtents

      public List<byte[]> getExtents()
      Get the character strings of this record as undecoded byte arrays.
      Returns:
      individual character strings as raw byte arrays
    • serialize

      public void serialize(DataOutputStream dos) throws IOException
      Write the raw wire data to a DNS output stream.
      Specified by:
      serialize in class Data
      Parameters:
      dos - the output stream to serialize to.
      Throws:
      IOException - if an I/O error occurs.
    • getType

      public Record.TYPE getType()
      Return the record type of this payload.
      Specified by:
      getType in class Data
      Returns:
      The DNS record type of this payload.
    • toString

      public String toString()
      Return the record's text in quotes, as it appears in a zone file.
      Overrides:
      toString in class Object