Class StringUtils

java.lang.Object
com.onenetwork.platform.tools.util.StringUtils

public abstract class StringUtils
extends java.lang.Object
Basic utilities for manipulating Strings.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static java.util.regex.Pattern ALPHA_NUMERIC_PATTERN
    Alpha Numeric Pattern constant
    static java.lang.String EMPTY_STRING
    Empty string constant
  • Constructor Summary

    Constructors 
    Modifier Constructor Description
    protected StringUtils()  
  • Method Summary

    Modifier and Type Method Description
    static boolean isAlphaNumeric​(char ch)
    Check Character is alphanumeric
    static boolean isAlphaNumeric​(java.lang.String str)  
    static boolean isBlank​(java.lang.Object o)
    Utility method to check for blanks Strings.
    static boolean isNull​(java.lang.Object o)
    Utility method to check for null objects.
    static boolean isNullOrBlank​(java.lang.Object o)
    Checks an object's for null or if a String, empty string
    static java.lang.String requireNonNullOrBlank​(java.lang.String val, java.util.function.Supplier<java.lang.String> supp)  
    static java.lang.String sanitizeWebSafeCallbackString​(java.lang.String str)
    This method is the same as validateWebSafeCallbackString except it returns a string This method is the preferred one for code checked by Checkmarx since it only considers a method to be a sanitizer of a variable if it affects its content
    static void validateWebSafeCallbackString​(java.lang.String str)
    This method is used to validate strings which will may be emitted into a web page as a callback parameter- it allows a very restrictive set of characters, including alphanumeric, whitespace, and a few others which are not interpreted by HTML, such as _ and .
    static void validateWebSafeJsonp​(java.lang.String str)
    This method is used to validate strings which will may be emitted into a web page as a jsonp (callback) parameter It allows a very restrictive set of characters, including alphanumeric, whitespace, and a few others which are not interpreted by HTML, such as _ and .

    Methods inherited from class java.lang.Object

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

  • Constructor Details

  • Method Details

    • isBlank

      public static boolean isBlank​(java.lang.Object o)
      Utility method to check for blanks Strings. Probably exists somewhere else in some fashion.
      Parameters:
      o - an object to check to see if is a blank string
      Returns:
      true, if object is blank
    • isNull

      public static boolean isNull​(java.lang.Object o)
      Utility method to check for null objects. Probably exists somewhere else in some fashion.
      Parameters:
      o - the object to check
      Returns:
      true, if object is null
    • isNullOrBlank

      public static boolean isNullOrBlank​(java.lang.Object o)
      Checks an object's for null or if a String, empty string
      Parameters:
      o - object being investigated
      Returns:
      true, if the object is null or is an empty String.
    • isAlphaNumeric

      public static boolean isAlphaNumeric​(char ch)
      Check Character is alphanumeric
      Parameters:
      ch -
      Returns:
      true iff char is Number of Character else false
    • isAlphaNumeric

      public static boolean isAlphaNumeric​(java.lang.String str)
    • requireNonNullOrBlank

      public static java.lang.String requireNonNullOrBlank​(java.lang.String val, java.util.function.Supplier<java.lang.String> supp)
    • sanitizeWebSafeCallbackString

      public static java.lang.String sanitizeWebSafeCallbackString​(java.lang.String str)
      This method is the same as validateWebSafeCallbackString except it returns a string This method is the preferred one for code checked by Checkmarx since it only considers a method to be a sanitizer of a variable if it affects its content
      Returns:
      String
    • validateWebSafeCallbackString

      public static void validateWebSafeCallbackString​(java.lang.String str)
      This method is used to validate strings which will may be emitted into a web page as a callback parameter- it allows a very restrictive set of characters, including alphanumeric, whitespace, and a few others which are not interpreted by HTML, such as _ and . This helps ensure the string has not html elements like < or > which could allow a user to inject scripts/etc into a page if their input is reflected back as markup in the response.
    • validateWebSafeJsonp

      public static void validateWebSafeJsonp​(java.lang.String str)
      This method is used to validate strings which will may be emitted into a web page as a jsonp (callback) parameter It allows a very restrictive set of characters, including alphanumeric, whitespace, and a few others which are not interpreted by HTML, such as _ and . This helps ensure the string has not html elements like < or > which could allow a user to inject scripts/etc into a page if their input is reflected back as markup in the response.