Class Web
java.lang.Object
ch.autumo.beetroot.utils.web.Web
Web helper methods.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringenrichQuery(String url, String name, Object value) Enrich URL with parameters.static StringescapeHtml(String value) Full HTML escape value.static StringescapeHtmlReserved(String input) HTML escape (reserved characters only) value.protected static StringformatDateForHTML(Date sqlDate) Format SQL date.protected static StringformatDateTimeForHTML(Timestamp sqlTimestamp) Format SQL time-stamp.protected static StringformatTimeForHTML(Time sqlTime) Format SQL time.static StringgetHtmlDivType(ResultSetMetaData rsmd, int idx, String columnName) Determine HTML div field type for SQL data type.static StringgetHtmlInputPattern(int idx, String columnName) Determine HTML input field pattern based on column name.static StringgetHtmlInputType(ResultSetMetaData rsmd, int idx, String columnName) Determine HTML input field type for SQL data type.static StringgetRealPath(jakarta.servlet.ServletContext context) Returns the real filesystem path of the web application's root directory.static StringnormalizeUri(String uri) Normalize URI.static booleanpingWebsite(String urlAddress) Ping a web-site.static StringpreFormatForHTML(Object databaseValueObject, int sqlType) Pre-format values from database for HTML input values.static StringprepareHtmlWithLineBreaks(String html, boolean prettyPrint) Remove unnecessary HTML tags, but preserve line-breaks.static StringprepareHtmlWithLineBreaks(String html, boolean prettyPrint, String... addTags) Remove unnecessary HTML tags, but preserve line-breaks.static StringprepareHtmlWithLineBreaks(String html, boolean prettyPrint, List<AbstractMap.SimpleEntry<String, String>> replacements) Remove unnecessary HTML tags, but preserve line-breaks.static StringprepareHtmlWithLineBreaks(String html, boolean prettyPrint, List<AbstractMap.SimpleEntry<String, String>> replacements, String... addTags) Remove unnecessary HTML tags, but preserve line-breaks.
-
Method Details
-
escapeHtmlReserved
-
escapeHtml
-
enrichQuery
-
normalizeUri
-
getRealPath
Returns the real filesystem path of the web application's root directory. Note: This only works for exploded (unpacked) web applications. If the application is packaged in a WAR and not exploded, this method may return null.- Parameters:
context- the ServletContext- Returns:
- the absolute filesystem path ending with a file separator, or null if unavailable
-
prepareHtmlWithLineBreaks
-
prepareHtmlWithLineBreaks
-
prepareHtmlWithLineBreaks
public static String prepareHtmlWithLineBreaks(String html, boolean prettyPrint, List<AbstractMap.SimpleEntry<String, String>> replacements) Remove unnecessary HTML tags, but preserve line-breaks.- Parameters:
html- the input HTMLprettyPrint- use pretty-print?replacements- tags to replace if any- Returns:
- prepared HTML
-
prepareHtmlWithLineBreaks
public static String prepareHtmlWithLineBreaks(String html, boolean prettyPrint, List<AbstractMap.SimpleEntry<String, String>> replacements, String... addTags) Remove unnecessary HTML tags, but preserve line-breaks.- Parameters:
html- the input HTMLprettyPrint- use pretty-print?replacements- tags to replace if anyaddTags- additional tags that should be kept if any- Returns:
- prepared HTML
-
getHtmlDivType
public static String getHtmlDivType(ResultSetMetaData rsmd, int idx, String columnName) throws SQLException Determine HTML div field type for SQL data type.- Parameters:
rsmd- result set meta dataidx- db column indexcolumnName- db column name- Returns:
- type
- Throws:
SQLException- SQL exception
-
getHtmlInputType
public static String getHtmlInputType(ResultSetMetaData rsmd, int idx, String columnName) throws SQLException Determine HTML input field type for SQL data type.- Parameters:
rsmd- result set meta dataidx- db column indexcolumnName- db column name- Returns:
- type
- Throws:
SQLException- SQL exception
-
getHtmlInputPattern
Determine HTML input field pattern based on column name.- Parameters:
idx- db column indexcolumnName- db column name- Returns:
- pattern
- Throws:
SQLException- SQL exception
-
preFormatForHTML
-
formatDateForHTML
-
formatTimeForHTML
-
formatDateTimeForHTML
-
pingWebsite
Ping a web-site.- Parameters:
urlAddress- URL address- Returns:
- true if ping was successful
-