All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.anotheria.anosite.content.variables.ConditionProcessor Maven / Gradle / Ivy

There is a newer version: 4.1.2
Show newest version
package net.anotheria.anosite.content.variables;

import net.anotheria.util.content.template.processors.variables.ConditionProcessorNames;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.http.HttpServletRequest;

public class ConditionProcessor implements VariablesProcessor {
	private final Logger log = LoggerFactory.getLogger(ConditionProcessor.class);

	@Override
	public String replace(String prefix, String variable, String defValue, HttpServletRequest req) {
		//sorry!  next If block -- is just the stupid hack!  due  to 'if' prefix name (
		if (ConditionProcessorNames.iF.getPrefixName().equals(prefix)) {
			return ConditionProcessorNames.iF.executeReplacement(variable, defValue);
		} else {
			try {
				return ConditionProcessorNames.valueOf(ConditionProcessorNames.class, prefix).executeReplacement(variable, defValue);
			} catch (Exception ignored) {
				log.error("An exceptions has been occurred while trying to replace variable. where prefix=" + prefix + " variable=" + variable + " defaultvalue=" + defValue, ignored);
			}
		}
		return "";
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy