Package org.xhtmlrenderer.util
Class GeneralUtil
java.lang.Object
org.xhtmlrenderer.util.GeneralUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
Dumps an exception to the console, only the last 5 lines of the stack trace.static String
escapeHTML
(String s) Converts any special characters into their corresponding HTML entities , for example invalid input: '<' to <.static @Nullable URL
getURLFromClasspath
(Object obj, String resource) static StringBuilder
htmlEscapeSpace
(String uri) static boolean
isMacOSX()
static @Nullable InputStream
openStreamFromClasspath
(Object obj, String resource) static int
Parses an integer from a string using less restrictive rules about which characters we won't accept.
-
Constructor Details
-
GeneralUtil
public GeneralUtil()
-
-
Method Details
-
openStreamFromClasspath
@CheckReturnValue public static @Nullable InputStream openStreamFromClasspath(Object obj, String resource) -
getURLFromClasspath
-
dumpShortException
Dumps an exception to the console, only the last 5 lines of the stack trace. -
isMacOSX
@CheckReturnValue public static boolean isMacOSX() -
htmlEscapeSpace
-
parseIntRelaxed
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
Converts any special characters into their corresponding HTML entities , for example invalid input: '<' 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.
-