Strings

com.netflix.atlas.core.util.Strings
object Strings

Helper functions for working with strings.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Strings.type

Members list

Value members

Concrete methods

def cast[T](c: Class[_], v: String): T

Cast a string value to an internal type.

Cast a string value to an internal type.

Attributes

def conversionExists(c: Class[_]): Boolean

Returns true if a conversion exists for the specified class.

Returns true if a conversion exists for the specified class.

Attributes

def extractReferencePointDate(str: String): Option[String]

Returns the name of the reference point for relative dates. For example, with the relative date now-5m, it would return now.

Returns the name of the reference point for relative dates. For example, with the relative date now-5m, it would return now.

Attributes

def hexDecode(input: String, escapeChar: Char): String

Hex decode an input string.

Hex decode an input string.

Value parameters

escapeChar

Character used to indicate the start of a hex encoded symbol.

input

Input string to decode.

Attributes

Returns

Decoded string.

def isRelativeDate(str: String): Boolean

Returns true if a date string is relative.

Returns true if a date string is relative.

Attributes

def isRelativeDate(str: String, customRef: Boolean): Boolean

Returns true if a date string is relative. If custom ref is true it will check if it is a relative date against a custom reference point other than now or the epoch.

Returns true if a date string is relative. If custom ref is true it will check if it is a relative date against a custom reference point other than now or the epoch.

Attributes

def parseColor(str: String): Color

Parse a color expressed as a hexadecimal RRGGBB string.

Parse a color expressed as a hexadecimal RRGGBB string.

Attributes

def parseDate(str: String, tz: ZoneId, refs: Map[String, ZonedDateTime]): ZonedDateTime

Return the time associated with a given string. Times can be relative to a reference point using syntax <ref><+/-><duration>. Supported references points are s, e, now, and epoch. See parseDuration for more details about durations.

Return the time associated with a given string. Times can be relative to a reference point using syntax <ref><+/-><duration>. Supported references points are s, e, now, and epoch. See parseDuration for more details about durations.

Attributes

def parseDuration(str: String): Duration

Parse a string that follows the ISO8601 spec or at time range spec into a period object.

Parse a string that follows the ISO8601 spec or at time range spec into a period object.

Attributes

def parseQueryString(query: String): Map[String, List[String]]

Returns a map corresponding to the URL query parameters in the string.

Returns a map corresponding to the URL query parameters in the string.

Attributes

def stripMargin(str: String): String

Strip the margin from multi-line strings.

Strip the margin from multi-line strings.

Attributes

def substitute(str: String, vars: Map[String, String]): String

Substitute variables from the map into a string. If a key used in the input string is not set, then the key will be used as the value.

Substitute variables from the map into a string. If a key used in the input string is not set, then the key will be used as the value.

Attributes

def substitute(str: String, vars: String => String): String

Substitute variables into a string.

Substitute variables into a string.

Attributes

def timeRange(s: String, e: String, tz: ZoneId, refs: Map[String, ZonedDateTime]): (Instant, Instant)

Parse start and end time strings that can be relative to each other and resolve to precise instants.

Parse start and end time strings that can be relative to each other and resolve to precise instants.

Value parameters

e

End time string in a format supported by parseDate.

s

Start time string in a format supported by parseDate.

tz

Time zone to assume for the times if a zone is not explicitly specified. Defaults to UTC.

Attributes

Returns

Tuple start -> end.

def toString(d: Duration): String

Returns a string representation of a period.

Returns a string representation of a period.

Attributes

def urlDecode(s: String): String

Lenient url-decoder. The URLDecoder class provided in the jdk throws if there is an invalid hex encoded value. This function will map invalid encodes to a %25 (a literal percent sign) and then decode it normally.

Lenient url-decoder. The URLDecoder class provided in the jdk throws if there is an invalid hex encoded value. This function will map invalid encodes to a %25 (a literal percent sign) and then decode it normally.

Attributes

def urlEncode(s: String): String

Lenient url-encoder. The URLEncoder class provided in the jdk is eager to percent encode making atlas expressions hard to read. This version assumes the only escaping necessary for '%', '&', '+', '?', '=', and ' '.

Lenient url-encoder. The URLEncoder class provided in the jdk is eager to percent encode making atlas expressions hard to read. This version assumes the only escaping necessary for '%', '&', '+', '?', '=', and ' '.

Attributes

def zeroPad(s: String, width: Int): String

Left pad the input string with zeros to the specified width. This is typically used as an alternative to performing zero padding using String.format.

Left pad the input string with zeros to the specified width. This is typically used as an alternative to performing zero padding using String.format.

Attributes

def zeroPad(v: Int, width: Int): String

Convert integer value to hex string and zero pad. It is intended for positive values and the integer value will be treated as unsigned.

Convert integer value to hex string and zero pad. It is intended for positive values and the integer value will be treated as unsigned.

Attributes

def zeroPad(v: Long, width: Int): String

Convert long value to hex string and zero pad. It is intended for positive values and the integer value will be treated as unsigned.

Convert long value to hex string and zero pad. It is intended for positive values and the integer value will be treated as unsigned.

Attributes

def zeroPad(v: BigInteger, width: Int): String

Convert BigInteger value to hex string and zero pad.

Convert BigInteger value to hex string and zero pad.

Attributes

def zeroPad(v: Array[Byte], width: Int): String

Convert integer represented as a byte array to a hex string and zero pad. This can be used to avoid a conversion to BigInteger if the hex string is the only result needed. The minimum padding width is 2, smaller values will get ignored.

Convert integer represented as a byte array to a hex string and zero pad. This can be used to avoid a conversion to BigInteger if the hex string is the only result needed. The minimum padding width is 2, smaller values will get ignored.

Attributes