java.lang.Object
net.i2p.servlet.util.ServletUtil
Simple utilities for servlets. Consolidated from i2psnark, susimail, and routerconsole
Constructor Summary
ConstructorsMethod Summary
All MethodsModifier and TypeMethodDescriptionstatic booleanThe intent here is to return true for phones but false for big tablets? But not consistent.static booleanisSmallBrowser(String ua) Does the request come from a browser too small for the full desktop pages, i.e.static booleanisTextBrowser(String ua) Does the User-Agent name a text-mode browser? Matched on the product token at the start of the string: Lynx, w3m, ELinks, Links, Dillo or Emacs-w3m.static StringSanitize an encoded String from getQueryString().static StringTruncate a String.
Constructor Details
ServletUtil
private ServletUtil()Utility class, not intended for instantiation.
Method Details
isSmallBrowser
Does the request come from a browser too small for the full desktop pages, i.e. either a text-mode browser or a mobile one?- Parameters:
ua- User-Agent string, non-null- Returns:
- true if a text-mode or mobile browser
isTextBrowser
Does the User-Agent name a text-mode browser? Matched on the product token at the start of the string: Lynx, w3m, ELinks, Links, Dillo or Emacs-w3m.- Parameters:
ua- User-Agent string, non-null- Returns:
- true if a text-mode browser
isMobileBrowser
The intent here is to return true for phones but false for big tablets? But not consistent.- Parameters:
ua- User-Agent string, non-null- Returns:
- true if a mobile browser
truncate
Truncate a String. Same as s.substring(0, len) except that it won't split a surrogate pair or at a ZWJ.- Parameters:
s- non-nulllen- greater than zero- Returns:
- s if shorter; s.substring(0, len) if the char at len-1 is not a high surrogate or the char at len-1 or len is not a zero-width joiner; s.substring(0, len+1 or len+2) if it is
sanitizeQuery