public static void containsNoEmpties(final Iterable<String> collection, final String message) { for (final String object : collection) { notEmpty(object, message); } }
protected AbstractAttributeTagProcessor( final TemplateMode templateMode, final String dialectPrefix, final String elementName, final boolean prefixElementName, final String attributeName, final boolean prefixAttributeName, final int precedence, final boolean removeAttribute) { super(templateMode, dialectPrefix, elementName, prefixElementName, attributeName, prefixAttributeName, precedence); Validate.notEmpty(attributeName, "Attribute name cannot be null or empty in Attribute Tag Processor"); this.removeAttribute = removeAttribute; }
public FragmentSignature(final String fragmentName, final List<String> parameterNames) { super(); Validate.notEmpty(fragmentName, "Fragment name cannot be null or empty"); this.fragmentName = fragmentName; this.parameterNames = parameterNames; }
public UrlTemplateResource(final String path, final String characterEncoding) throws MalformedURLException { super(); Validate.notEmpty(path, "Resource Path cannot be null or empty"); // Character encoding CAN be null (system default will be used) this.url = new URL(path); this.characterEncoding = characterEncoding; }
public static String format(final Object target, final String pattern, final Locale locale) { Validate.notEmpty(pattern, "Pattern cannot be null or empty"); if (target == null) { return null; } return formatDate(target, pattern, locale); }
public FileTemplateResource(final String path, final String characterEncoding) { super(); Validate.notEmpty(path, "Resource Path cannot be null or empty"); // Character encoding CAN be null (system default will be used) this.path = TemplateResourceUtils.cleanPath(path); this.file = new File(path); this.characterEncoding = characterEncoding; }
public void addPattern(final String pattern) { Validate.notEmpty(pattern, "Pattern cannot be null or empty"); if (this.patterns == null) { this.patternStrs = new LinkedHashSet<String>(DEFAULT_PATTERN_SET_SIZE); this.patterns = new LinkedHashSet<Pattern>(DEFAULT_PATTERN_SET_SIZE); } this.patternStrs.add(pattern); this.patterns.add(PatternUtils.strPatternToPattern(pattern)); }
public void iterateElement(final String iterVariableName, final String iterStatusVariableName, final Object iteratedObject) { Validate.notEmpty(iterVariableName, "Iteration variable name cannot be null"); // Iteration status variable name CAN be null // IteratedObject CAN be null resetAllButVariablesOrAttributes(); this.iterateElement = true; this.iterVariableName = iterVariableName; this.iterStatusVariableName = iterStatusVariableName; this.iteratedObject = iteratedObject; }
/** * <p> * Create a ClassLoader-based template resource, specifying the specific class loader * to be used for resolving the resource. * </p> * * @param classLoader the class loader to be used for resource resolution. * @param path the path to the template resource. * @param characterEncoding the character encoding to be used to read the resource. * * @since 3.0.3 */ public ClassLoaderTemplateResource(final ClassLoader classLoader, final String path, final String characterEncoding) { super(); // Class Loader CAN be null (will apply the default sequence of class loaders Validate.notEmpty(path, "Resource Path cannot be null or empty"); // Character encoding CAN be null (system default will be used) this.optionalClassLoader = classLoader; final String cleanPath = TemplateResourceUtils.cleanPath(path); this.path = (cleanPath.charAt(0) == '/' ? cleanPath.substring(1) : cleanPath); this.characterEncoding = characterEncoding; }
public ServletContextTemplateResource(final ServletContext servletContext, final String path, final String characterEncoding) { super(); Validate.notNull(servletContext, "ServletContext cannot be null"); Validate.notEmpty(path, "Resource Path cannot be null or empty"); // Character encoding CAN be null (system default will be used) this.servletContext = servletContext; final String cleanPath = TemplateResourceUtils.cleanPath(path); this.path = (cleanPath.charAt(0) != '/' ? ("/" + cleanPath) : cleanPath); this.characterEncoding = characterEncoding; }
private static void addParameter(final Map<String, Object> parameters, final String parameterName, final Object parameterValue) { Validate.notEmpty(parameterName, "Parameter name cannot be null"); final Object normalizedParameterValue = normalizeParameterValue(parameterValue); if (parameters.containsKey(parameterName)) { // Parameter already exists, therefore we will be appending to an existing value Object currentValue = parameters.get(parameterName); if (currentValue == null || !(currentValue instanceof List<?>)) { final List<Object> newValue = new ArrayList<Object>(3); newValue.add(currentValue); currentValue = newValue; parameters.put(parameterName, currentValue); } if (normalizedParameterValue != null && normalizedParameterValue instanceof List<?>) { ((List<Object>) currentValue).addAll((List<?>)normalizedParameterValue); } else { ((List<Object>) currentValue).add(normalizedParameterValue); } return; } // Parameter does not exist, so its new and we might need to add the original name in order to find it later parameters.put(parameterName, normalizedParameterValue); }
public ITemplateResource relative(final String relativeLocation) { Validate.notEmpty(relativeLocation, "Relative Path cannot be null or empty"); // We will create a new URL using the current one as context, and the relative path as spec final URL relativeURL; try { relativeURL = new URL(this.url, (relativeLocation.charAt(0) == '/' ? relativeLocation.substring(1) : relativeLocation)); } catch (final MalformedURLException e) { throw new TemplateInputException( "Could not create relative URL resource for resource \"" + getDescription() + "\" and " + "relative location \"" + relativeLocation + "\"", e); } return new UrlTemplateResource(relativeURL, this.characterEncoding); }
public DecoupledTemplateLogicBuilderMarkupHandler(final String templateName, final TemplateMode templateMode) { super(); Validate.notEmpty(templateName, "Template name cannot be null or empty"); Validate.notNull(templateMode, "Template mode cannot be null"); this.templateName = templateName; this.templateMode = templateMode; this.decoupledTemplateLogic = new DecoupledTemplateLogic(); }
public ITemplateResource relative(final String relativeLocation) { Validate.notEmpty(relativeLocation, "Relative Path cannot be null or empty"); final String fullRelativeLocation = TemplateResourceUtils.computeRelativeLocation(this.path, relativeLocation); return new FileTemplateResource(fullRelativeLocation, this.characterEncoding); }
public ITemplateResource relative(final String relativeLocation) { Validate.notEmpty(relativeLocation, "Relative Path cannot be null or empty"); final String fullRelativeLocation = TemplateResourceUtils.computeRelativeLocation(this.path, relativeLocation); return new ServletContextTemplateResource(this.servletContext, fullRelativeLocation, this.characterEncoding); }
public ITemplateResource relative(final String relativeLocation) { Validate.notEmpty(relativeLocation, "Relative Path cannot be null or empty"); final String fullRelativeLocation = TemplateResourceUtils.computeRelativeLocation(this.path, relativeLocation); return new ClassLoaderTemplateResource(this.optionalClassLoader, fullRelativeLocation, this.characterEncoding); }
public StandardCache(final String name, final boolean useSoftReferences, final int initialCapacity, final int maxSize, final ICacheEntryValidityChecker<? super K, ? super V> entryValidityChecker, final Logger logger, final boolean enableCounters) { super(); Validate.notEmpty(name, "Name cannot be null or empty"); Validate.isTrue(initialCapacity > 0, "Initial capacity must be > 0"); Validate.isTrue(maxSize != 0, "Cache max size must be either -1 (no limit) or > 0"); this.name = name; this.useSoftReferences = useSoftReferences; this.maxSize = maxSize; this.entryValidityChecker = entryValidityChecker; this.logger = logger; this.traceExecution = (logger != null && logger.isTraceEnabled()); this.enableCounters = (this.traceExecution || enableCounters); this.dataContainer = new CacheDataContainer<K,V>(this.name, initialCapacity, maxSize, this.traceExecution, this.logger); this.getCount = new AtomicLong(0); this.putCount = new AtomicLong(0); this.hitCount = new AtomicLong(0); this.missCount = new AtomicLong(0); if (this.logger != null) { if (this.maxSize < 0) { this.logger.trace("[THYMELEAF][CACHE_INITIALIZE] Initializing cache {}. Soft references {}.", this.name, (this.useSoftReferences? "are used" : "not used")); } else { this.logger.trace("[THYMELEAF][CACHE_INITIALIZE] Initializing cache {}. Max size: {}. Soft references {}.", new Object[] {this.name, Integer.valueOf(this.maxSize), (this.useSoftReferences? "are used" : "not used")}); } } }
public SpringResourceTemplateResource( final ApplicationContext applicationContext, final String location, final String characterEncoding) { super(); Validate.notNull(applicationContext, "Application Context cannot be null"); Validate.notEmpty(location, "Resource Location cannot be null or empty"); // Character encoding CAN be null (system default will be used) this.resource = applicationContext.getResource(location); this.characterEncoding = characterEncoding; }
public boolean acl(final Object domainObject, final String permissions) { Validate.notEmpty(permissions, "permissions cannot be null or empty"); final ApplicationContext applicationContext = AuthUtils.getContext(this.servletContext); final List<Permission> permissionsList = AclAuthUtils.parsePermissionsString(applicationContext, permissions); return AclAuthUtils.authorizeUsingAccessControlList( domainObject, permissionsList, this.authentication, this.servletContext); }
public boolean acl(final Object domainObject, final String permissions) { Validate.notEmpty(permissions, "permissions cannot be null or empty"); final ApplicationContext applicationContext = AuthUtils.getContext(this.context); final List<Permission> permissionsList = AclAuthUtils.parsePermissionsString(applicationContext, permissions); return AclAuthUtils.authorizeUsingAccessControlList( this.context, domainObject, permissionsList, this.authentication); }