Java Code Examples for com.opensymphony.xwork2.util.TextParseUtil#translateVariables()

The following examples show how to use com.opensymphony.xwork2.util.TextParseUtil#translateVariables() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TextParserSample.java    From Android_Code_Arbiter with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void unsafeTextParseUtil(String input) {
    TextParseUtil.translateVariables(input, null);
    TextParseUtil.translateVariables(input, null, null);
    TextParseUtil.translateVariables('a', input, null);
    TextParseUtil.translateVariables('a', input, null, null);
    TextParseUtil.translateVariables(new char[]{'a'}, input, null, null, null);
    TextParseUtil.translateVariables(new char[]{'a'}, input, null, null, null, 0);
    TextParseUtil.translateVariables('a', input, null, null, null, 0);
}
 
Example 2
Source File: TextParserSample.java    From Android_Code_Arbiter with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void safeTextParseUtil(ValueStack stack, TextParseUtil.ParsedValueEvaluator parsedValueEvaluator, Class type) {
    String input = "1+1";
    TextParseUtil.translateVariables(input, stack);
    TextParseUtil.translateVariables(input, stack, parsedValueEvaluator);
    TextParseUtil.translateVariables('a', input, stack);
    TextParseUtil.translateVariables('a', input, stack, type);
    TextParseUtil.translateVariables(new char[]{'a'}, input, stack, type, parsedValueEvaluator);
    TextParseUtil.translateVariables(new char[]{'a'}, input, stack, type, parsedValueEvaluator, 0);
    TextParseUtil.translateVariables('a', input, stack, type, parsedValueEvaluator, 0);
}
 
Example 3
Source File: PlainTextErrorResult.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void execute( ActionInvocation invocation )
    throws Exception
{
    HttpServletResponse response = (HttpServletResponse) invocation.getInvocationContext().get(
        StrutsStatics.HTTP_RESPONSE );

    response.setContentType( "text/plain; charset=UTF-8" );
    response.setHeader( "Content-Disposition", "inline" );
    response.setStatus( HttpServletResponse.SC_INTERNAL_SERVER_ERROR );

    ValueStack stack = ActionContext.getContext().getValueStack();
    String finalMessage = parse ? TextParseUtil.translateVariables( message, stack ) : message;

    finalMessage = formatFinalMessage( finalMessage );

    // ---------------------------------------------------------------------
    // Write final message
    // ---------------------------------------------------------------------

    PrintWriter writer = null;

    try
    {
        writer = response.getWriter();
        writer.print( finalMessage );
        writer.flush();
    }
    finally
    {
        if ( writer != null )
        {
            writer.close();
        }
    }
}