public abstract class

UAStringUtil

extends Object
java.lang.Object
   ↳ com.urbanairship.util.UAStringUtil

Class Overview

A class containing utility methods related to strings.

Summary

Public Constructors
UAStringUtil()
Public Methods
static byte[] base64Decode(String encoded)
Base64 decodes a string.
static String base64DecodedString(String encoded)
Generates a base 64 decoded string.
static String byteToHex(byte[] bytes)
Converts the bytes into a hex string.
static boolean equals(String firstString, String secondString)
Checks if the strings are equal.
static String generateSignedToken(String secret, List<String> values)
Generates a base64 encoded HmacSHA256 signed value.
static boolean isEmpty(String stringToCheck)
Checks if the string is empty.
static String join(Collection<String> c, String delimiter)
Append a collection of strings and delimiter.
static String namedStringResource(Context context, String name, String defaultValue)
static String nullIfEmpty(String value)
static String repeat(String repeater, int times, String separator)
Builds a string.
static String sha256(String value)
Returns the sha256 hex string for a given string.
static byte[] sha256Digest(String value)
Generates the sha256 digest for a given string.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public UAStringUtil ()

Public Methods

public static byte[] base64Decode (String encoded)

Base64 decodes a string.

Parameters
encoded The base64 encoded string.
Returns
  • The decoded bytes or null if it failed to be decoded.

public static String base64DecodedString (String encoded)

Generates a base 64 decoded string.

Parameters
encoded The encoded value.
Returns
  • The decoded string or null if it failed to be decoded.

public static String byteToHex (byte[] bytes)

Converts the bytes into a hex string.

Parameters
bytes The byte array.
Returns
  • A hex string.

public static boolean equals (String firstString, String secondString)

Checks if the strings are equal.

Parameters
firstString The first string.
secondString The second string.
Returns
  • true if the strings are equal, false otherwise.

public static String generateSignedToken (String secret, List<String> values)

Generates a base64 encoded HmacSHA256 signed value.

Parameters
secret The secret
values A list of values that will be concatenated by ":"
Returns
  • A signed token.

public static boolean isEmpty (String stringToCheck)

Checks if the string is empty.

Parameters
stringToCheck The string to check.
Returns
  • true if the string is null, false otherwise.

public static String join (Collection<String> c, String delimiter)

Append a collection of strings and delimiter.

Parameters
c A collection of strings.
delimiter A delimiter string.
Returns
  • The new string.

public static String namedStringResource (Context context, String name, String defaultValue)

public static String nullIfEmpty (String value)

public static String repeat (String repeater, int times, String separator)

Builds a string.

Parameters
repeater The string to build.
times The number of times to append the string.
separator The separator string.
Returns
  • The new string.

public static String sha256 (String value)

Returns the sha256 hex string for a given string.

Parameters
value The value.
Returns
  • The sha256 hex string or null if the value is null or it failed encode the string.

public static byte[] sha256Digest (String value)

Generates the sha256 digest for a given string.

Parameters
value The string.
Returns
  • The sha256 digest for the string, or null if it failed to create the digest.