本文整理汇总了Java中org.thymeleaf.standard.expression.IStandardExpression类的典型用法代码示例。如果您正苦于以下问题:Java IStandardExpression类的具体用法?Java IStandardExpression怎么用?Java IStandardExpression使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IStandardExpression类属于org.thymeleaf.standard.expression包,在下文中一共展示了IStandardExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getContents
import org.thymeleaf.standard.expression.IStandardExpression; //导入依赖的package包/类
static Contents getContents(final ITemplateContext context,
final IProcessableElementTag tag) {
final Contents contents;
final String from = tag.getAttributeValue(ATTR_FROM);
if (from != null) {
final IEngineConfiguration configuration = context.getConfiguration();
final IStandardExpressionParser parser = getExpressionParser(configuration);
final IStandardExpression expression = parser.parseExpression(context, from);
contents = (Contents) expression.execute(context);
} else {
Object contentsVar = context.getVariable(DEFAULT_VAR_CONTENTS);
if (contentsVar != null) {
contents = (Contents) contentsVar;
} else {
contents = null;
}
}
if (contents != null) {
return contents;
} else {
throw new IllegalStateException(
"Unable to get RxComposer Contents. " +
"You should either provide a template variable named 'contents' or " +
"provide it using attribute 'from': '<rxc:fragment from='${myContents}' position='A' />");
}
}
示例2: doProcess
import org.thymeleaf.standard.expression.IStandardExpression; //导入依赖的package包/类
protected void doProcess(final ITemplateContext context, final IProcessableElementTag tag,
final AttributeName attributeName, final String attributeValue,
final IElementTagStructureHandler structureHandler) {
IStandardExpressionParser expressionParser = StandardExpressions
.getExpressionParser(context.getConfiguration());
IStandardExpression expression = expressionParser.parseExpression(context, attributeValue);
Boolean enabled = (Boolean) expression.execute(context);
if (enabled) {
expression = expressionParser.parseExpression(context, "@{/resources/konker/images/enabled.svg}");
} else {
expression = expressionParser.parseExpression(context, "@{/resources/konker/images/disabled.svg}");
}
structureHandler.setAttribute("src", (String) expression.execute(context));
structureHandler.setAttribute("class", (String) "enabled-img");
}
示例3: parse
import org.thymeleaf.standard.expression.IStandardExpression; //导入依赖的package包/类
public static Object parse(final Arguments arguments, final String attributeValue, boolean escape) {
final Configuration configuration = arguments.getConfiguration();
final IStandardExpressionParser expressionParser = StandardExpressions.getExpressionParser(configuration);
final IStandardExpression expression = expressionParser.parseExpression(configuration, arguments, attributeValue);
final Object result;
if (escape) {
result = expression.execute(configuration, arguments);
}
else {
result = expression.execute(configuration, arguments, StandardExpressionExecutionContext.UNESCAPED_EXPRESSION);
}
return result;
}
示例4: isVisible
import org.thymeleaf.standard.expression.IStandardExpression; //导入依赖的package包/类
@Override
protected boolean isVisible(final Arguments arguments, final Element element, final String attributeName) {
String attributeValue = element.getAttributeValue(attributeName);
if (StringUtils.indexOf(attributeValue, "isAdminPage") != -1) {
Object context = arguments.getContext();
if (context instanceof SpringWebContext) {
SpringWebContext webContext = (SpringWebContext) context;
HttpServletRequest httpServletRequest = webContext.getHttpServletRequest();
boolean val = StringUtils.indexOf(httpServletRequest.getRequestURI(), "/_admin/") != -1;
attributeValue = StringUtils.replace(attributeValue, "isAdminPage", Boolean.toString(val));
}
}
final Configuration configuration = arguments.getConfiguration();
final IStandardExpressionParser expressionParser = StandardExpressions.getExpressionParser(configuration);
final IStandardExpression expression = expressionParser.parseExpression(configuration, arguments, attributeValue);
final Object value = expression.execute(configuration, arguments);
final boolean visible = EvaluationUtil.evaluateAsBoolean(value);
return visible;
}
示例5: getModifiedAttributeValues
import org.thymeleaf.standard.expression.IStandardExpression; //导入依赖的package包/类
@Override
protected Map<String, String> getModifiedAttributeValues(
Arguments arguments, Element element, String attributeName) {
final String attributeValue = element.getAttributeValue(attributeName);
final Configuration configuration = arguments.getConfiguration();
final IStandardExpressionParser expressionParser =
StandardExpressions.getExpressionParser(configuration);
final IStandardExpression expression =
expressionParser.parseExpression(configuration, arguments, attributeValue);
final Set<String> newAttributeNames =
new HashSet<String>(Arrays.asList("id", "name"));
final Object valueForAttributes = expression.execute(configuration, arguments);
final Map<String,String> result =
new HashMap<String,String>(newAttributeNames.size() + 1, 1.0f);
for (final String newAttributeName : newAttributeNames) {
result.put(newAttributeName,
(valueForAttributes == null? "" : valueForAttributes.toString()));
}
return result;
}
示例6: parseExpression
import org.thymeleaf.standard.expression.IStandardExpression; //导入依赖的package包/类
private Object parseExpression(IStandardExpressionParser expressionParser, ITemplateContext context, String attributeValue) {
if (attributeValue == null) {
return null;
}
Object result = null;
try {
IStandardExpression expression = expressionParser.parseExpression(context, attributeValue);
result = expression.execute(context);
} catch (TemplateProcessingException e) {
result = attributeValue;
}
return result;
}
示例7: processStandardExpression
import org.thymeleaf.standard.expression.IStandardExpression; //导入依赖的package包/类
/**
* <p>
* Processes the provided value using the Thymeleaf Standard Expression
* processor.
* </p>
*
* @param arguments
* Thymeleaf {@link Arguments}
* @param value
* String expression to parse
* @param clazz
* {@link Class} of the attribute's value
* @return an object processed by the Thymeleaf Standard Expression
* processor.
*/
@SuppressWarnings("unchecked")
private static <T> T processStandardExpression(Arguments arguments, String value, Class<T> clazz) {
Object result = null;
Configuration configuration = arguments.getConfiguration();
StandardExpressionParserWrapper expressionParser = new StandardExpressionParserWrapper();
IStandardExpression standardExpression = expressionParser.parseExpression(configuration, arguments, value);
if (standardExpression == null) {
result = value;
}
else {
result = standardExpression.execute(configuration, arguments);
}
// Handling null value
if (result == null) {
return null;
}
return clazz.isAssignableFrom(result.getClass()) ? (T) result : null;
}
示例8: getProcessedAttribute
import org.thymeleaf.standard.expression.IStandardExpression; //导入依赖的package包/类
private static Object getProcessedAttribute(Arguments arguments, String value) {
Object result = null;
Configuration configuration = arguments.getConfiguration();
StandardExpressionParserWrapper expressionParser = new StandardExpressionParserWrapper();
IStandardExpression standardExpression = expressionParser.parseExpression(configuration, arguments, value);
if (standardExpression == null) {
result = value;
}
else {
result = standardExpression.execute(configuration, arguments);
}
return result;
}
示例9: doProcess
import org.thymeleaf.standard.expression.IStandardExpression; //导入依赖的package包/类
@Override
protected void doProcess(
final ITemplateContext context, final IProcessableElementTag tag,
final AttributeName attributeName, final String attributeValue,
final IElementTagStructureHandler structureHandler) {
final IEngineConfiguration configuration = context.getConfiguration();
/*
* Obtain the Thymeleaf Standard Expression parser
*/
final IStandardExpressionParser parser = StandardExpressions.getExpressionParser(configuration);
/*
* Parse the attribute value as a Thymeleaf Standard Expression
*/
final IStandardExpression expression = parser.parseExpression(context, attributeValue);
/*
* Execute the expression just parsed
*/
final String origurl = (String) expression.execute(context);
StringBuilder urlBuilder = new StringBuilder(origurl);
CsrfToken token = (CsrfToken) context.getVariable("_csrf");
// token è null quando il csrf è stato disabilitato
if (token!=null) {
final String tokenName = token.getParameterName();
final String tokenValue = token.getToken();
if (urlBuilder.lastIndexOf("?")>-1) {
urlBuilder.append("&");
} else {
urlBuilder.append("?");
}
urlBuilder.append(tokenName).append("=").append(tokenValue);
}
structureHandler.setAttribute("action", urlBuilder.toString());
}
示例10: doProcess
import org.thymeleaf.standard.expression.IStandardExpression; //导入依赖的package包/类
@Override
protected void doProcess(
final ITemplateContext context, final IProcessableElementTag tag,
final AttributeName attributeName, final String attributeValue,
final IElementTagStructureHandler structureHandler) {
final IEngineConfiguration configuration = context.getConfiguration();
/*
* Obtain the Thymeleaf Standard Expression parser
*/
final IStandardExpressionParser parser = StandardExpressions.getExpressionParser(configuration);
/*
* Parse the attribute value as a Thymeleaf Standard Expression
*/
final IStandardExpression expression = parser.parseExpression(context, attributeValue);
/*
* Execute the expression just parsed
*/
final String semiurl = (String) expression.execute(context);
String resultUrl = yadaDialectUtil.getVersionedAttributeValue(context, semiurl);
/*
* Set the new value into the 'href' attribute
*/
if (resultUrl != null) {
structureHandler.setAttribute(ATTR_NAME, resultUrl);
}
}
示例11: doProcess
import org.thymeleaf.standard.expression.IStandardExpression; //导入依赖的package包/类
@Override
protected void doProcess(
final ITemplateContext context, final IProcessableElementTag tag,
final AttributeName attributeName, final String attributeValue,
final IElementTagStructureHandler structureHandler) {
final IEngineConfiguration configuration = context.getConfiguration();
/*
* Obtain the Thymeleaf Standard Expression parser
*/
final IStandardExpressionParser parser = StandardExpressions.getExpressionParser(configuration);
/*
* Parse the attribute value as a Thymeleaf Standard Expression
*/
final IStandardExpression expression = parser.parseExpression(context, attributeValue);
/*
* Execute the expression just parsed
*/
final String semiurl = (String) expression.execute(context);
String resultUrl = yadaDialectUtil.getVersionedAttributeValue(context, semiurl);
/*
* Set the new value into the 'href' attribute
*/
if (resultUrl != null) {
structureHandler.setAttribute(ATTR_NAME, resultUrl);
}
}
示例12: getPosition
import org.thymeleaf.standard.expression.IStandardExpression; //导入依赖的package包/类
static Position getPosition(final ITemplateContext context,
final IProcessableElementTag tag) {
String position = tag.getAttributeValue("position");
try {
final IEngineConfiguration configuration = context.getConfiguration();
final IStandardExpressionParser parser = getExpressionParser(configuration);
final IStandardExpression expression = parser.parseExpression(context, position);
return () -> expression.execute(context).toString();
} catch (final Exception e) {
return () -> position;
}
}
示例13: evaluate
import org.thymeleaf.standard.expression.IStandardExpression; //导入依赖的package包/类
public static Object evaluate(IExpressionContext context, String expressionValue) {
final String value = String.valueOf(expressionValue).trim();
final IStandardExpressionParser expressionParser = StandardExpressions
.getExpressionParser(context.getConfiguration());
final IStandardExpression expression = expressionParser.parseExpression(context, value);
return expression.execute(context);
}
示例14: determineFeatureState
import org.thymeleaf.standard.expression.IStandardExpression; //导入依赖的package包/类
/**
* Determines the feature state
*
* @param context the template context
* @param tag the tag
* @param attributeName the attribute name
* @param attributeValue the attribute value
* @param defaultState the default state if the expression evaluates to null
* @return the feature state
*/
protected boolean determineFeatureState(final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue, boolean defaultState) {
final IStandardExpressionParser expressionParser = StandardExpressions.getExpressionParser(context.getConfiguration());
final IStandardExpression expression = expressionParser.parseExpression(context, attributeValue);
final Object value = expression.execute(context);
if (value != null) {
return isFeatureActive(value.toString());
}
else {
return defaultState;
}
}
示例15: findPage
import org.thymeleaf.standard.expression.IStandardExpression; //导入依赖的package包/类
public static Page<?> findPage(final ITemplateContext context) {
// 1. Get Page object from local variables (defined with sd:page-object)
// 2. Search Page using ${page} expression
// 3. Search Page object as request attribute
final Object pageFromLocalVariable = context.getVariable(Keys.PAGE_VARIABLE_KEY);
if (isPageInstance(pageFromLocalVariable)) {
return (Page<?>) pageFromLocalVariable;
}
// Check if not null and Page instance available with ${page} expression
final IEngineConfiguration configuration = context.getConfiguration();
final IStandardExpressionParser parser = StandardExpressions.getExpressionParser(configuration);
final IStandardExpression expression = parser.parseExpression(context, Keys.PAGE_EXPRESSION);
final Object page = expression.execute(context);
if (isPageInstance(page)) {
return (Page<?>) page;
}
// Search for Page object, and only one instance, as request attribute
if (context instanceof IWebContext) {
HttpServletRequest request = ((IWebContext) context).getRequest();
Enumeration<String> attrNames = request.getAttributeNames();
Page<?> pageOnRequest = null;
while (attrNames.hasMoreElements()) {
String attrName = (String) attrNames.nextElement();
Object attr = request.getAttribute(attrName);
if (isPageInstance(attr)) {
if (pageOnRequest != null) {
throw new InvalidObjectParameterException("More than one Page object found on request!");
}
pageOnRequest = (Page<?>) attr;
}
}
if (pageOnRequest != null) {
return pageOnRequest;
}
}
throw new InvalidObjectParameterException("Invalid or not present Page object found on request!");
}