Package io.opencensus.tags
Class TagValue
- java.lang.Object
-
- io.opencensus.tags.TagValue
-
- Direct Known Subclasses:
AutoValue_TagValue
@Immutable public abstract class TagValue extends java.lang.Object
A validated tag value.Validation ensures that the
String
has a maximum length ofMAX_LENGTH
and contains only printable ASCII characters.- Since:
- 0.8
-
-
Field Summary
Fields Modifier and Type Field Description static int
MAX_LENGTH
The maximum length for a tag value.
-
Constructor Summary
Constructors Constructor Description TagValue()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract java.lang.String
asString()
Returns the tag value as aString
.static TagValue
create(java.lang.String value)
Constructs aTagValue
from the given string.private static boolean
isValid(java.lang.String value)
Determines whether the givenString
is a valid tag value.
-
-
-
Field Detail
-
MAX_LENGTH
public static final int MAX_LENGTH
The maximum length for a tag value. The value is 255.- Since:
- 0.8
- See Also:
- Constant Field Values
-
-
Method Detail
-
create
public static TagValue create(java.lang.String value)
Constructs aTagValue
from the given string. The string must meet the following requirements:- It cannot be longer than
MAX_LENGTH
. - It can only contain printable ASCII characters.
- Parameters:
value
- the tag value.- Throws:
java.lang.IllegalArgumentException
- if theString
is not valid.- Since:
- 0.8
- It cannot be longer than
-
asString
public abstract java.lang.String asString()
Returns the tag value as aString
.- Returns:
- the tag value as a
String
. - Since:
- 0.8
-
isValid
private static boolean isValid(java.lang.String value)
Determines whether the givenString
is a valid tag value.- Parameters:
value
- the tag value to be validated.- Returns:
- whether the value is valid.
-
-