当前位置: 首页>>代码示例>>Java>>正文


Java IStandardExpressionParser类代码示例

本文整理汇总了Java中org.thymeleaf.standard.expression.IStandardExpressionParser的典型用法代码示例。如果您正苦于以下问题:Java IStandardExpressionParser类的具体用法?Java IStandardExpressionParser怎么用?Java IStandardExpressionParser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IStandardExpressionParser类属于org.thymeleaf.standard.expression包,在下文中一共展示了IStandardExpressionParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getContents

import org.thymeleaf.standard.expression.IStandardExpressionParser; //导入依赖的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' />");
    }
}
 
开发者ID:otto-de,项目名称:rx-composer,代码行数:27,代码来源:RxcFragmentElementProcessor.java

示例2: doProcess

import org.thymeleaf.standard.expression.IStandardExpressionParser; //导入依赖的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");

}
 
开发者ID:KonkerLabs,项目名称:konker-platform,代码行数:21,代码来源:EnabledImageTagProcessor.java

示例3: parse

import org.thymeleaf.standard.expression.IStandardExpressionParser; //导入依赖的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;
    }
 
开发者ID:af-not-found,项目名称:blog-java2,代码行数:18,代码来源:ProcessorUtil.java

示例4: isVisible

import org.thymeleaf.standard.expression.IStandardExpressionParser; //导入依赖的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;
}
 
开发者ID:af-not-found,项目名称:blog-java2,代码行数:26,代码来源:MyFunctionDialect.java

示例5: getModifiedAttributeValues

import org.thymeleaf.standard.expression.IStandardExpressionParser; //导入依赖的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;
}
 
开发者ID:onBass-naga,项目名称:spring-boot-samples,代码行数:27,代码来源:IdNameProcessor.java

示例6: parseExpression

import org.thymeleaf.standard.expression.IStandardExpressionParser; //导入依赖的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;
}
 
开发者ID:dtrunk90,项目名称:thymeleaf-jawr-extension,代码行数:17,代码来源:AbstractJawrAttributeTagProcessor.java

示例7: doProcess

import org.thymeleaf.standard.expression.IStandardExpressionParser; //导入依赖的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());
     
 }
 
开发者ID:xtianus,项目名称:yadaframework,代码行数:40,代码来源:YadaActionUploadAttrProcessor.java

示例8: doProcess

import org.thymeleaf.standard.expression.IStandardExpressionParser; //导入依赖的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);
    }
}
 
开发者ID:xtianus,项目名称:yadaframework,代码行数:33,代码来源:YadaSrcAttrProcessor.java

示例9: doProcess

import org.thymeleaf.standard.expression.IStandardExpressionParser; //导入依赖的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);
    }

}
 
开发者ID:xtianus,项目名称:yadaframework,代码行数:34,代码来源:YadaHrefAttrProcessor.java

示例10: getPosition

import org.thymeleaf.standard.expression.IStandardExpressionParser; //导入依赖的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;
    }
}
 
开发者ID:otto-de,项目名称:rx-composer,代码行数:13,代码来源:RxcFragmentElementProcessor.java

示例11: evaluate

import org.thymeleaf.standard.expression.IStandardExpressionParser; //导入依赖的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);
}
 
开发者ID:jpenren,项目名称:thymeleaf-spring-data-dialect,代码行数:9,代码来源:Expressions.java

示例12: determineFeatureState

import org.thymeleaf.standard.expression.IStandardExpressionParser; //导入依赖的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;
    }
}
 
开发者ID:heneke,项目名称:thymeleaf-extras-togglz,代码行数:22,代码来源:AbstractFeatureAttrProcessor.java

示例13: findPage

import org.thymeleaf.standard.expression.IStandardExpressionParser; //导入依赖的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!");
}
 
开发者ID:jpenren,项目名称:thymeleaf-spring-data-dialect,代码行数:44,代码来源:PageUtils.java

示例14: processAttribute

import org.thymeleaf.standard.expression.IStandardExpressionParser; //导入依赖的package包/类
@Override
protected ProcessorResult processAttribute(Arguments theArguments, Element theElement, String theAttributeName) {
	final String attributeValue = theElement.getAttributeValue(theAttributeName);

	final Configuration configuration = theArguments.getConfiguration();
	final IStandardExpressionParser expressionParser = StandardExpressions.getExpressionParser(configuration);

	final IStandardExpression expression = expressionParser.parseExpression(configuration, theArguments, attributeValue);
	final Object value = expression.execute(configuration, theArguments);

	theElement.removeAttribute(theAttributeName);
	theElement.clearChildren();

	if (value == null) {
		return ProcessorResult.ok();
	}

	Context context = new Context();
	context.setVariable("resource", value);

	String name = null;
	if (value != null) {
		Class<? extends Object> nextClass = value.getClass();
		do {
			name = myClassToName.get(nextClass);
			nextClass = nextClass.getSuperclass();
		} while (name == null && nextClass.equals(Object.class) == false);
		
		if (name == null) {
			if (value instanceof IBaseResource) {
				name = myFhirContext.getResourceDefinition((IBaseResource)value).getName();
			} else if (value instanceof IDatatype) {
				name = value.getClass().getSimpleName();
				name = name.substring(0, name.length() - 2);
			} else {
				throw new DataFormatException("Don't know how to determine name for type: " + value.getClass());
			}
			name = name.toLowerCase();
			if (!myNameToNarrativeTemplate.containsKey(name)) {
				name = null;
			}
		}
	}

	if (name == null) {
		if (myIgnoreMissingTemplates) {
			ourLog.debug("No narrative template available for type: {}", value.getClass());
			return ProcessorResult.ok();
		} else {
			throw new DataFormatException("No narrative template for class " + value.getClass());
		}
	}

	String result = myProfileTemplateEngine.process(name, context);
	String trim = result.trim();
	if (!isBlank(trim + "AAA")) {
		Document dom = getXhtmlDOMFor(new StringReader(trim));
		
		Element firstChild = (Element) dom.getFirstChild();
		for (int i = 0; i < firstChild.getChildren().size(); i++) {
			Node next = firstChild.getChildren().get(i);
			if (i == 0 && firstChild.getChildren().size() == 1) {
				if (next instanceof org.thymeleaf.dom.Text) {
					org.thymeleaf.dom.Text nextText = (org.thymeleaf.dom.Text) next;
					nextText.setContent(nextText.getContent().trim());
				}
			}
			theElement.addChild(next);
		}
		
	}
	

	return ProcessorResult.ok();
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:76,代码来源:BaseThymeleafNarrativeGenerator.java

示例15: evaluate

import org.thymeleaf.standard.expression.IStandardExpressionParser; //导入依赖的package包/类
private static Object evaluate(Arguments arguments, String expression) {
    Configuration configuration = arguments.getConfiguration();
    IStandardExpressionParser expressionParser = StandardExpressions.getExpressionParser(configuration);
    IStandardExpression standardExpression = expressionParser.parseExpression(configuration, arguments, expression);
    return standardExpression.execute(configuration, arguments);
}
 
开发者ID:jmiguelsamper,项目名称:thymeleaf-extras-sqldialect,代码行数:7,代码来源:ExpressionUtil.java


注:本文中的org.thymeleaf.standard.expression.IStandardExpressionParser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。