Package io.jenkins.plugins.checks.api
Class TruncatedString
java.lang.Object
io.jenkins.plugins.checks.api.TruncatedString
Utility wrapper that silently truncates output with a message at a certain size.
The GitHub Checks API has a size limit on text fields. Because it also accepts markdown, it is not trivial to truncate to the required length as this could lead to unterminated syntax. The use of this class allows for adding chunks of complete markdown until an overflow is detected, at which point a message will be added and all future additions will be silently discarded.
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild
(int maxSize) Deprecated.buildByBytes
(int maxSize) Builds the string such that it does not exceed maxSize in bytes, including the truncation string.buildByChars
(int maxSize) Builds the string such that it does not exceed maxSize in chars, including the truncation string.toString()
Builds the string without truncation.
-
Method Details
-
toString
Builds the string without truncation. -
build
Deprecated.use the explicitbuildByBytes(int)
orbuildByChars(int)
method according to your requirements.Builds the string such that it does not exceed maxSize in bytes, including the truncation string.- Parameters:
maxSize
- the maximum size of the resultant string.- Returns:
- A string comprising as many of the joined chunks that will fit in the given size, plus the truncation string if truncation was necessary.
-
buildByBytes
Builds the string such that it does not exceed maxSize in bytes, including the truncation string.- Parameters:
maxSize
- the maximum size of the resultant string.- Returns:
- A string comprising as many of the joined chunks that will fit in the given size, plus the truncation string if truncation was necessary.
-
buildByChars
Builds the string such that it does not exceed maxSize in chars, including the truncation string.- Parameters:
maxSize
- the maximum size of the resultant string.- Returns:
- A string comprising as many of the joined chunks that will fit in the given size, plus the truncation string if truncation was necessary.
-
buildByBytes(int)
orbuildByChars(int)
method according to your requirements.