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


Java SimpleScalar.getAsString方法代码示例

本文整理汇总了Java中freemarker.template.SimpleScalar.getAsString方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleScalar.getAsString方法的具体用法?Java SimpleScalar.getAsString怎么用?Java SimpleScalar.getAsString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在freemarker.template.SimpleScalar的用法示例。


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

示例1: getAmount

import freemarker.template.SimpleScalar; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static BigDecimal getAmount(Map args, String key) {
    if (args.containsKey(key)) {
        Object o = args.get(key);

        // handle nulls better
        if (o == null) {
            o = 0.00;
        }
        if (Debug.verboseOn()) Debug.logVerbose("Amount Object : " + o.getClass().getName(), module);

        if (o instanceof SimpleScalar) {
            SimpleScalar s = (SimpleScalar) o;
            return new BigDecimal(s.getAsString());
        }
        return new BigDecimal(o.toString());
    }
    return BigDecimal.ZERO;
}
 
开发者ID:gildaslemoal,项目名称:elpi,代码行数:20,代码来源:OfbizCurrencyTransform.java

示例2: getExpireTime

import freemarker.template.SimpleScalar; //导入方法依赖的package包/类
public long getExpireTime(Map args) {
    Object o = args.get("expireTime");
    Debug.logInfo("ExpireTime Object - " + o, module);
    long expireTime = 0;
    if (o != null) {
        if (o instanceof SimpleScalar) {
            SimpleScalar s = (SimpleScalar) o;
            String ets = s.getAsString();
            Debug.logInfo("ExpireTime String - " + ets, module);
            try {
                expireTime = Long.parseLong(ets);
            } catch (Exception e) {
                Debug.logError(e, module);
            }
        }
    }
    return expireTime;
}
 
开发者ID:gildaslemoal,项目名称:elpi,代码行数:19,代码来源:JpCacheIncludeTransform.java

示例3: exec

import freemarker.template.SimpleScalar; //导入方法依赖的package包/类
@Override
public Object exec(List args) throws TemplateModelException {
    if (args.size() != 1) {
        throw new TemplateModelException("There should be a single argument of type string " +
                "passed to format description method");
    }

    SimpleScalar arg1 = (SimpleScalar) args.get(0);
    String inputString = arg1.getAsString();

    // Replacing spaces that should not be considered in text wrapping with non breaking spaces
    inputString = replaceLeadingSpaces(inputString);

    inputString = inputString.replaceAll("<", "&lt;");
    inputString = inputString.replaceAll(">", "&gt;");

    // Replacing new line characters
    inputString = replaceNewLines(inputString);

    inputString = inputString.replaceAll("\t", "&nbsp;&nbsp;&nbsp;&nbsp;");
    inputString = inputString.replaceAll("```([^```]*)```", "<pre>$1</pre>");
    inputString = inputString.replaceAll("`([^`]*)`", "<code>$1</code>");

    return inputString;
}
 
开发者ID:wso2,项目名称:siddhi,代码行数:26,代码来源:FormatDescriptionMethod.java

示例4: resolveLayoutType

import freemarker.template.SimpleScalar; //导入方法依赖的package包/类
private LayoutType resolveLayoutType(Map params) throws TemplateException
{
    LayoutType layoutType = LayoutType.HORIZONTAL;
    SimpleScalar layoutModel = (SimpleScalar) params.get("layout");
    if (layoutModel != null)
    {
        String lt = layoutModel.getAsString();
        try
        {
            layoutType = LayoutType.valueOf(lt.toUpperCase());
        }
        catch (IllegalArgumentException e)
        {
            throw new TemplateException("Layout: " + lt + " is not supported.", e, null);
        }
    }
    return layoutType;
}
 
开发者ID:windup,项目名称:windup,代码行数:19,代码来源:RenderLinkDirective.java

示例5: exec

import freemarker.template.SimpleScalar; //导入方法依赖的package包/类
@Override
public Object exec(@SuppressWarnings("rawtypes") List arguments) throws TemplateModelException
{
    if (arguments.size() != 1)
    {
        throw new TemplateModelException("Error, method expects one argument (String)");
    }
    SimpleScalar arg = (SimpleScalar) arguments.get(0);
    String qualifedClassName = arg.getAsString();
    JavaClassModel classModel = javaClassService.getByName(qualifedClassName);
    List<AbstractJavaSourceModel> results = new ArrayList<>();
    if (classModel instanceof AmbiguousJavaClassModel)
    {
        AmbiguousJavaClassModel ambiguousJavaClassModel = (AmbiguousJavaClassModel) classModel;
        for (JavaClassModel referencedClass : ambiguousJavaClassModel.getReferences())
        {
            addSourceFilesToResult(results, referencedClass);
        }
    }
    else
    {
        addSourceFilesToResult(results, classModel);
    }
    return results;
}
 
开发者ID:windup,项目名称:windup,代码行数:26,代码来源:FindSourceFilesByClassNameMethod.java

示例6: execute

import freemarker.template.SimpleScalar; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body)
    throws TemplateException, IOException {
    if (log.isTraceEnabled()) {
        log.trace(params);
    }

    TemplateModel pProduct = (TemplateModel) params.get("product");
    SimpleScalar pType = (SimpleScalar) params.get("type");

    if (pProduct != null && pProduct instanceof BeanModel && pType != null) {
        Product product = null;
        String type = null;

        Object beanModel = ((BeanModel) pProduct).getWrappedObject();

        if (beanModel instanceof Product) {
            product = (Product) beanModel;
        } else {
            throw new IllegalArgumentException("The source-object must be of type Product");
        }

        if (pType != null)
            type = pType.getAsString();

        PriceResult result = product.getPrice();

        if (result != null && type != null) {
            Double price = result.getPrice(type);

            if (price != null && price > 0 && body != null) {
                body.render(env.getOut());
            }
        }
    }
}
 
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:38,代码来源:PriceExistsDirective.java

示例7: execute

import freemarker.template.SimpleScalar; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body)
    throws TemplateException, IOException {
    TemplateModel pValue = (TemplateModel) params.get("value");
    SimpleScalar pVar = (SimpleScalar) params.get("var");

    if (pVar == null)
        throw new IllegalArgumentException("The var parameter cannot be null in set-directive");

    String var = pVar.getAsString();
    Object value = null;

    if (pValue != null) {
        if (pValue instanceof StringModel) {
            value = ((StringModel) pValue).getWrappedObject();
        } else if (pValue instanceof SimpleHash) {
            value = ((SimpleHash) pValue).toMap();
        } else {
            value = DeepUnwrap.unwrap(pValue);
        }
    } else if (body != null) {
        StringWriter sw = new StringWriter();

        try {
            body.render(sw);
            value = sw.toString().trim();
        } finally {
            IOUtils.closeQuietly(sw);
        }
    }

    env.setVariable(var, DefaultObjectWrapper.getDefaultInstance().wrap(value));
}
 
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:35,代码来源:SetDirective.java

示例8: execute

import freemarker.template.SimpleScalar; //导入方法依赖的package包/类
public void execute(Environment env, Map params, TemplateModel[] loopVars,
		TemplateDirectiveBody body) throws TemplateException, IOException {
	
	//Create a new var to inject in inner tag execution
	BeansWrapper wrapper=(BeansWrapper)(env.getConfiguration().getObjectWrapper());
	DecoratorVars vars=new DecoratorVars();
	env.setVariable(decoratorVars,new BeanModel(vars,wrapper));
	
	//Execute innter tag template
	ByteArrayOutputStream baos=MacroHelper.renderInnerTag(body);
	
	//Create a new model with macro params and string of innter tag execution
	Map<String,Object> paramToDecorator=MacroHelper.extractParams(params);
	paramToDecorator.put("_doLayout_", baos);
	paramToDecorator.putAll(vars.getValues());
	
	StringModel templateModel = (StringModel) env.getDataModel().get(FreemarkerViewRenderer.ROOT_MODEL);
	if (templateModel!=null){
		Map map = ((MapWrapper)templateModel.getWrappedObject()).get();
		paramToDecorator.putAll(map);
	}
	
	//Execute template 
	SimpleScalar strModelTpl=(SimpleScalar) params.get("tpl");
	String tplName=strModelTpl.getAsString();
	freemarkerTemplateRenderer.render(tplName, paramToDecorator, env.getOut());
}
 
开发者ID:jerolba,项目名称:funsteroid,代码行数:28,代码来源:DecoratorMacro.java

示例9: getString

import freemarker.template.SimpleScalar; //导入方法依赖的package包/类
public static String getString(Map params, String paramName){
	Object objParam=params.get(paramName);
	if (objParam instanceof SimpleScalar){
		SimpleScalar valueModel=(SimpleScalar) params.get(paramName);
		if (valueModel!=null){
			return valueModel.getAsString();
		}
	}
	return null;
}
 
开发者ID:jerolba,项目名称:funsteroid,代码行数:11,代码来源:MacroHelper.java

示例10: getInclude

import freemarker.template.SimpleScalar; //导入方法依赖的package包/类
public String getInclude(Map args) {
    Object o = args.get("include");
    Debug.logInfo("Include Object - " + o, module);
    String include = null;
    if (o != null) {
        if (o instanceof SimpleScalar) {
            SimpleScalar s = (SimpleScalar) o;
            include = s.getAsString();
            Debug.logInfo("Include String - " + include, module);
        }
    }
    return include;
}
 
开发者ID:gildaslemoal,项目名称:elpi,代码行数:14,代码来源:JpCacheIncludeTransform.java

示例11: exec

import freemarker.template.SimpleScalar; //导入方法依赖的package包/类
@Override
		@SuppressWarnings("rawtypes")
		public Object exec(List arguments) throws TemplateModelException {
//			return "[TODO: activityToLayout " + arguments.get(0) + "]";
			SimpleScalar scalar = (SimpleScalar) arguments.get(0);
			String line = scalar.getAsString();
			line = line.replace("Activity", "");
			
			return "activity_" + CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, line);			
		}
 
开发者ID:vijaysharm,项目名称:ehyo-android,代码行数:11,代码来源:TemplateMethods.java

示例12: getBlockName

import freemarker.template.SimpleScalar; //导入方法依赖的package包/类
public static String getBlockName(Environment env, Map params, String paramName) throws TemplateException {

        SimpleScalar blockNameScalar = (SimpleScalar) params.get(paramName);
        if (blockNameScalar == null) {
            throw new TemplateException("This directive must have '" + paramName + "' attribute.", env);
        }
        return blockNameScalar.getAsString();
    }
 
开发者ID:yamingd,项目名称:argo,代码行数:9,代码来源:BlockDirectiveUtils.java

示例13: execute

import freemarker.template.SimpleScalar; //导入方法依赖的package包/类
@Override
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException
{
    final Writer writer = env.getOut();
    SimpleScalar ruleIDStringModel = (SimpleScalar) params.get("ruleID");
    if (ruleIDStringModel == null || ruleIDStringModel.getAsString() == null)
        return;

    SimpleScalar renderTypeScalar = (SimpleScalar) params.get("renderType");
    final String renderType;
    if (renderTypeScalar == null)
        renderType = RENDER_TYPE_TAG;
    else
        renderType = renderTypeScalar.getAsString();

    SimpleScalar cssClassScalar = (SimpleScalar) params.get("class");
    String cssClass;
    if (cssClassScalar == null || StringUtils.isBlank(cssClassScalar.getAsString())) {
        cssClass = "";
    }
    else {
        cssClass = cssClassScalar.getAsString();
    }

    String ruleID = ruleIDStringModel.getAsString();

    writer.append("<a title='View Rule: " + ruleID + "' href='" + RenderRuleProviderReportRuleProvider.OUTPUT_FILENAME + "#" + ruleID + "'>");
    if (RENDER_TYPE_GLYPH.equals(renderType))
        writer.append("<span class='glyphicon glyphicon-link "+cssClass+"'></span>");
    else if (RENDER_TYPE_TAG.equals(renderType))
        writer.append("<span class='tag "+cssClass+"'>&lt;rule/></span>");
    else
        writer.append("<span class='plain "+cssClass+"'>"+ ruleID +"</span>");
    writer.append("</a>");
}
 
开发者ID:windup,项目名称:windup,代码行数:36,代码来源:RenderRuleLinkDirective.java

示例14: exec

import freemarker.template.SimpleScalar; //导入方法依赖的package包/类
@Override
public Object exec(@SuppressWarnings("rawtypes") List arguments) throws TemplateModelException
{
    if (arguments.size() != 1)
        throw new TemplateModelException("Expected one String argument - the name of the tag.");

    SimpleScalar stringModel = (SimpleScalar) arguments.get(0);
    String tagName = stringModel.getAsString();

    return new TagGraphService(graphContext).getTagByName(tagName);
}
 
开发者ID:windup,项目名称:windup,代码行数:12,代码来源:GetTagModelByNameMethod.java

示例15: resolveCssClass

import freemarker.template.SimpleScalar; //导入方法依赖的package包/类
private String resolveCssClass(Map params)
{
    SimpleScalar css = (SimpleScalar) params.get("class");
    if (css == null)
        return "";
    else
        return css.getAsString();
}
 
开发者ID:windup,项目名称:windup,代码行数:9,代码来源:RenderLinkDirective.java


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