Class GeneralUtil

java.lang.Object
org.xhtmlrenderer.util.GeneralUtil

public class GeneralUtil extends Object
  • Constructor Details

    • GeneralUtil

      public GeneralUtil()
  • Method Details

    • openStreamFromClasspath

      @CheckReturnValue public static @Nullable InputStream openStreamFromClasspath(Object obj, String resource)
    • getURLFromClasspath

      @CheckReturnValue public static @Nullable URL getURLFromClasspath(Object obj, String resource)
    • dumpShortException

      public static void dumpShortException(Exception ex)
      Dumps an exception to the console, only the last 5 lines of the stack trace.
    • isMacOSX

      @CheckReturnValue public static boolean isMacOSX()
    • htmlEscapeSpace

      public static StringBuilder htmlEscapeSpace(String uri)
    • parseIntRelaxed

      public static int parseIntRelaxed(String s)
      Parses an integer from a string using less restrictive rules about which characters we won't accept. This scavenges the supplied string for any numeric character, while dropping all others.
      Parameters:
      s - The string to parse
      Returns:
      The number represented by the passed string, or 0 if the string is null, empty, white-space only, contains only non-numeric characters, or simply evaluates to 0 after parsing (e.g. "0")
    • escapeHTML

      public static String escapeHTML(String s)
      Converts any special characters into their corresponding HTML entities , for example < to <. This is done using a character by character test, so you may consider other approaches for large documents. Make sure you declare the entities that might appear in this replacement, e.g. the latin-1 entities This method was taken from a code-samples website, written and hosted by Real Gagnon, at ....
      Parameters:
      s - The String which may contain characters to escape.
      Returns:
      The string with the characters as HTML entities.