Class TagValue

java.lang.Object
io.opencensus.tags.TagValue
Direct Known Subclasses:
AutoValue_TagValue

@Immutable public abstract class TagValue extends Object
A validated tag value.

Validation ensures that the String has a maximum length of MAX_LENGTH and contains only printable ASCII characters.

Since:
0.8
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The maximum length for a tag value.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract String
    Returns the tag value as a String.
    static TagValue
    create(String value)
    Constructs a TagValue from the given string.
    private static boolean
    isValid(String value)
    Determines whether the given String is a valid tag value.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MAX_LENGTH

      public static final int MAX_LENGTH
      The maximum length for a tag value. The value is 255.
      Since:
      0.8
      See Also:
  • Constructor Details

    • TagValue

      TagValue()
  • Method Details

    • create

      public static TagValue create(String value)
      Constructs a TagValue from the given string. The string must meet the following requirements:
      1. It cannot be longer than MAX_LENGTH.
      2. It can only contain printable ASCII characters.
      Parameters:
      value - the tag value.
      Throws:
      IllegalArgumentException - if the String is not valid.
      Since:
      0.8
    • asString

      public abstract String asString()
      Returns the tag value as a String.
      Returns:
      the tag value as a String.
      Since:
      0.8
    • isValid

      private static boolean isValid(String value)
      Determines whether the given String is a valid tag value.
      Parameters:
      value - the tag value to be validated.
      Returns:
      whether the value is valid.