/** * Convenience method to protect against a {@code null} argument. */ public static void check(String argumentName, Object argumentValue) { if (argumentValue == null) { throw new NullArgumentException(argumentName); } }
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 ClassTemplateLoader(Class<?> resourceLoaderClass, boolean allowNullResourceLoaderClass, ClassLoader classLoader, String basePackagePath) { if (!allowNullResourceLoaderClass) { NullArgumentException.check("resourceLoaderClass", resourceLoaderClass); } NullArgumentException.check("basePackagePath", basePackagePath); // Either set a non-null resourceLoaderClass or a non-null classLoader, not both: this.resourceLoaderClass = classLoader == null ? (resourceLoaderClass == null ? this.getClass() : resourceLoaderClass) : null; if (this.resourceLoaderClass == null && classLoader == null) { throw new NullArgumentException("classLoader"); } this.classLoader = classLoader; String canonBasePackagePath = canonicalizePrefix(basePackagePath); if (this.classLoader != null && canonBasePackagePath.startsWith("/")) { canonBasePackagePath = canonBasePackagePath.substring(1); } this.basePackagePath = canonBasePackagePath; }
private ClassTemplateLoader(Class<?> resourceLoaderClass, boolean allowNullResourceLoaderClass, ClassLoader classLoader, String basePackagePath) { if (!allowNullResourceLoaderClass) { NullArgumentException.check("resourceLoaderClass", resourceLoaderClass); } NullArgumentException.check("basePackagePath", basePackagePath); // Either set a non-null resourceLoaderClass or a non-null classLoader, not both: this.resourceLoaderClass = classLoader == null ? (resourceLoaderClass == null ? this.getClass() : resourceLoaderClass) : null; if (this.resourceLoaderClass == null && classLoader == null) { throw new NullArgumentException("classLoader"); } this.classLoader = classLoader; String canonBasePackagePath = canonicalizePrefix(basePackagePath); if (this.classLoader != null && canonBasePackagePath.startsWith("/")) { canonBasePackagePath = canonBasePackagePath.substring(1); } this.basePackagePath = canonBasePackagePath; }
/** * Sets the output format of the template; see {@link Configuration#setOutputFormat(OutputFormat)} for more. */ public void setOutputFormat(OutputFormat outputFormat) { NullArgumentException.check("outputFormat", outputFormat); this.outputFormat = outputFormat; }
/** * @since 2.3.22 */ public static void check(Object argumentValue) { if (argumentValue == null) { throw new NullArgumentException(); } }
private ClassTemplateLoader(Class<?> resourceLoaderClass, boolean allowNullResourceLoaderClass, ClassLoader classLoader, String basePackagePath) { if (!allowNullResourceLoaderClass) { NullArgumentException.check("resourceLoaderClass", resourceLoaderClass); } NullArgumentException.check("basePackagePath", basePackagePath); // Either set a non-null resourceLoaderClass or a non-null classLoader, not both: this.resourceLoaderClass = classLoader == null ? (resourceLoaderClass == null ? this.getClass() : resourceLoaderClass) : null; if (this.resourceLoaderClass == null && classLoader == null) { throw new NullArgumentException("classLoader"); } this.classLoader = classLoader; String canonBasePackagePath = canonicalizePrefix(basePackagePath); if (this.classLoader != null && canonBasePackagePath.startsWith("/")) { canonBasePackagePath = canonBasePackagePath.substring(1); } this.basePackagePath = canonBasePackagePath; }
void bindToOutputFormat(OutputFormat outputFormat, int autoEscapingPolicy) { NullArgumentException.check(outputFormat); this.outputFormat = outputFormat; this.autoEscapingPolicy = autoEscapingPolicy; }
throw new NullArgumentException( "outputFormat", "You may meant: " + UndefinedOutputFormat.class.getSimpleName() + ".INSTANCE");
void bindToMarkupOutputFormat(MarkupOutputFormat outputFormat) { NullArgumentException.check(outputFormat); this.outputFormat = outputFormat; }
/** * @since 2.3.22 */ public static void check(Object argumentValue) { if (argumentValue == null) { throw new NullArgumentException(); } }
/** * When the standard template loading/caching mechanism is used, this forces the charset used for reading the * template "file", overriding everything but the encoding coming from the {@code #ftl} header. This setting * overrides the locale-specific encodings set via {@link Configuration#setEncoding(java.util.Locale, String)}. It * also overrides the {@code encoding} parameter of {@link Configuration#getTemplate(String, String)} (and of its * overloads) and the {@code encoding} parameter of the {@code #include} directive. This works like that because * specifying the encoding where you are requesting the template is error prone and deprecated. * * <p> * If you are developing your own template loading/caching mechanism instead of the standard one, note that the * above behavior is not guaranteed by this class alone; you have to ensure it. Also, read the note on * {@code encoding} in the documentation of {@link #apply(Template)}. */ public void setEncoding(String encoding) { NullArgumentException.check("encoding", encoding); this.encoding = encoding; }
/** * @since 2.3.22 */ public static void check(Object argumentValue) { if (argumentValue == null) { throw new NullArgumentException(); } }
/** * Specifies how exceptions handled (and hence suppressed) by an {@code #attempt} blocks will be logged or otherwise * reported. The default value is {@link AttemptExceptionReporter#LOG_ERROR_REPORTER}. * * <p>Note that {@code #attempt} is not supposed to be a general purpose error handler mechanism, like {@code try} * is in Java. It's for decreasing the impact of unexpected errors, by making it possible that only part of the * page is going down, instead of the whole page. But it's still an error, something that someone should fix. So the * error should be reported, not just ignored in a custom {@link AttemptExceptionReporter}-s. * * <p>The {@link AttemptExceptionReporter} is invoked regardless of the value of the * {@link #setLogTemplateExceptions(boolean) log_template_exceptions} setting. * The {@link AttemptExceptionReporter} is not invoked if the {@link TemplateExceptionHandler} has suppressed the * exception. * * @since 2.3.27 */ public void setAttemptExceptionReporter(AttemptExceptionReporter attemptExceptionReporter) { NullArgumentException.check("attemptExceptionReporter", attemptExceptionReporter); this.attemptExceptionReporter = attemptExceptionReporter; }
/** * Convenience method to protect against a {@code null} argument. */ public static void check(String argumentName, Object argumentValue) { if (argumentValue == null) { throw new NullArgumentException(argumentName); } }
/** * Sets the format used to convert {@link java.util.Date}-s that are time (no date part) values to string-s, also * the format that {@code someString?time} will use to parse strings. * * <p>For the possible values see {@link #setDateTimeFormat(String)}. * * <p>Defaults to {@code ""}, which is equivalent to {@code "medium"}. */ public void setTimeFormat(String timeFormat) { NullArgumentException.check("timeFormat", timeFormat); this.timeFormat = timeFormat; properties.setProperty(TIME_FORMAT_KEY, timeFormat); }
/** * Convenience method to protect against a {@code null} argument. */ public static void check(String argumentName, Object argumentValue) { if (argumentValue == null) { throw new NullArgumentException(argumentName); } }
/** * Sets the format used to convert {@link java.util.Date}-s that are date-only (no time part) values to string-s, * also the format that {@code someString?date} will use to parse strings. * * <p>For the possible values see {@link #setDateTimeFormat(String)}. * * <p>Defaults to {@code ""} which is equivalent to {@code "medium"}. */ public void setDateFormat(String dateFormat) { NullArgumentException.check("dateFormat", dateFormat); this.dateFormat = dateFormat; properties.setProperty(DATE_FORMAT_KEY, dateFormat); }
public List<TreeNode> collectNodes(NodeCollector collector) { if (collector == null) { throw new NullArgumentException("collector"); } List<TreeNode> nodes = new LinkedList<TreeNode>(); collectNodes(collector, this, nodes); return nodes; }
/** * @param templateSourceName * The name of the matching template found. This is not necessarily the same as the template name * with which the template was originally requested. For example, one may gets a template for the * {@code "foo.ftl"} name, but due to localized lookup the template is actually loaded from * {@code "foo_de.ftl"}. Then this parameter must be {@code "foo_de.ftl"}, not {@code "foo.ftl"}. Not * {@code null}. * * @param templateSource * See {@link TemplateLoader#findTemplateSource(String)} to understand what that means. Not * {@code null}. */ private PositiveTemplateLookupResult(String templateSourceName, Object templateSource) { NullArgumentException.check("templateName", templateSourceName); NullArgumentException.check("templateSource", templateSource); if (templateSource instanceof TemplateLookupResult) { throw new IllegalArgumentException(); } this.templateSourceName = templateSourceName; this.templateSource = templateSource; }