/** * @since 2.3.22 */ public static void check(Object argumentValue) { if (argumentValue == null) { throw new NullArgumentException(); } }
/** * XHTML Encoding. * Replaces all '>' '<' '&', "'" and '"' with entity reference * suitable for XHTML decoding in common user agents (including legacy * user agents, which do not decode "&apos;" to "'", so "&#39;" is used * instead [see http://www.w3.org/TR/xhtml1/#C_16]) */ public static String XHTMLEnc(String s) { return XMLOrHTMLEnc(s, true, true, HTML_APOS); }
public JarEntryTldLocation(URL entryUrl, InputStreamFactory fallbackRawJarContentInputStreamFactory, String entryPath) { if (entryUrl == null) { NullArgumentException.check(fallbackRawJarContentInputStreamFactory); NullArgumentException.check(entryPath); } this.entryUrl = entryUrl; this.fallbackRawJarContentInputStreamFactory = fallbackRawJarContentInputStreamFactory; this.entryPath = entryPath != null ? normalizeJarEntryPath(entryPath, false) : null; }
private void loadBuiltInSharedVariables() { sharedVariables.put("capture_output", new CaptureOutput()); sharedVariables.put("compress", StandardCompress.INSTANCE); sharedVariables.put("html_escape", new HtmlEscape()); sharedVariables.put("normalize_newlines", new NormalizeNewlines()); sharedVariables.put("xml_escape", new XmlEscape()); }
/** * Same as {@link #unwrap(TemplateModel)}, but it doesn't throw exception * if it doesn't know how to unwrap the model, but rather returns it as-is. * @since 2.3.14 */ public static Object permissiveUnwrap(TemplateModel model) throws TemplateModelException { return unwrap(model, true); }
@Override public void close() throws IOException { flushInternal(); } }
/** * URL encoding (like%20this) for query parameter values, path <em>segments</em>, fragments; this encodes all * characters that are reserved anywhere. */ public static String URLEnc(String s, String charset) throws UnsupportedEncodingException { return URLEnc(s, charset, false); }
public MalformedTemplateNameException(String templateName, String malformednessDescription) { super("Malformed template name, " + StringUtil.jQuote(templateName) + ": " + malformednessDescription); this.templateName = templateName; this.malformednessDescription = malformednessDescription; }
/** * Escapes a {@link String} to be safely insertable into a JSON string literal; for more see * {@link #jsStringEnc(String, boolean) jsStringEnc(s, true)}. */ public static String jsonStringEnc(String s) { return jsStringEnc(s, true); }
/** * Like {@link #isTrimmableToEmpty(char[])}, but acts on a sub-array that starts at {@code start} (inclusive index). * * @since 2.3.23 */ public static boolean isTrimmableToEmpty(char[] text, int start) { return isTrimmableToEmpty(text, start, text.length); }
/** * Same as {@link #globToRegularExpression(String, boolean)} with {@code caseInsensitive} argument {@code false}. * * @since 2.3.24 */ public static Pattern globToRegularExpression(String glob) { return globToRegularExpression(glob, false); }
@Override protected Date parseDate(String s, TimeZone tz, CalendarFieldsToDateConverter calToDateConverter) throws DateParseException { return DateUtil.parseISO8601Date(s, tz, calToDateConverter); }
@Override protected Date parseDateTime(String s, TimeZone tz, CalendarFieldsToDateConverter calToDateConverter) throws DateParseException { return DateUtil.parseXSDateTime(s, tz, calToDateConverter); }
@Override TemplateModel calculateResult(Number num, TemplateModel model) throws TemplateModelException { return NumberUtil.isNaN(num) ? TemplateBooleanModel.TRUE : TemplateBooleanModel.FALSE; } }
/** * Same as {@link #toUpperABC(int)}, but produces lower case result, like {@code "ab"}. * * @since 2.3.22 */ public static String toLowerABC(int n) { return toABC(n, 'a'); }
@Override protected Date parseDate(String s, TimeZone tz, CalendarFieldsToDateConverter calToDateConverter) throws DateParseException { return DateUtil.parseXSDate(s, tz, calToDateConverter); }
/** * Convenience method to protect against a {@code null} argument. */ public static void check(String argumentName, Object argumentValue) { if (argumentValue == null) { throw new NullArgumentException(argumentName); } }
/** * XML encoding for attribute values quoted with <tt>"</tt> (not with <tt>'</tt>!). * Also can be used for HTML attributes that are quoted with <tt>"</tt>. * @see #XMLEnc(String) */ public static String XMLEncQAttr(String s) { return XMLOrHTMLEnc(s, false, true, null); }
/** * XML encoding without replacing apostrophes and quotation marks and * greater-thans (except in {@code ]]>}). * @see #XMLEnc(String) */ public static String XMLEncNQG(String s) { return XMLOrHTMLEnc(s, false, false, null); }
/** * Like {@link #XMLEnc(String)}, but writes the result into a {@link Writer}. * * @since 2.3.24 */ public static void XMLEnc(String s, Writer out) throws IOException { XMLOrHTMLEnc(s, XML_APOS, out); }