java.lang.Object
org.minidns.util.SafeCharSequence
All Implemented Interfaces:
CharSequence
Direct Known Subclasses:
DnsLabel, DnsName

public class SafeCharSequenceextends Object implements CharSequence
A CharSequence whose toString() output is guaranteed safe to expose. Subclasses may override toSafeString() if toString() is not safe.
  • Constructor Details

    • SafeCharSequence

      public SafeCharSequence()
      A sequence with no fields of its own: subclasses supply the text through toSafeString(), so construction needs no arguments.
  • Method Details

    • length

      public final int length()
      Counts the characters of the safe string form.
      Specified by:
      length in interface CharSequence
    • charAt

      public final char charAt(int index)
      Returns one character of the safe string form.
      Specified by:
      charAt in interface CharSequence
    • subSequence

      public final CharSequence subSequence(int start, int end)
      Returns a safe substring of the safe string form.
      Specified by:
      subSequence in interface CharSequence
    • toSafeString

      public String toSafeString()
      Return a safe string representation. The default implementation assumes that toString() returns a safe representation. Subclasses may override toSafeString() if this assumption is not correct.
      Returns:
      safe string representation