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


Java TemplateScalarModel.getAsString方法代码示例

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


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

示例1: getBooleanArg

import freemarker.template.TemplateScalarModel; //导入方法依赖的package包/类
/**
 * Gets boolean arg.
 * <p>
 * Will automatically interpret string true/false as boolean.
 */
public static Boolean getBooleanArg(TemplateModel obj, Boolean defaultValue) throws TemplateModelException {
    if (obj instanceof TemplateBooleanModel) {
        return ((TemplateBooleanModel) obj).getAsBoolean();
    }
    else if (obj instanceof TemplateScalarModel) {
        TemplateScalarModel s = (TemplateScalarModel) obj;
        String val = s.getAsString();
        // SCIPIO: empty check is desirable and makes it so caller can request default by specifying ""
        if (!val.isEmpty()) {
            return "true".equalsIgnoreCase(s.getAsString());
        }
    } else if (obj != null) {
        throw new TemplateModelException("Expected boolean model or string model representation of boolean, but got a " +
                obj.getClass() + " instead");
    }
    return defaultValue;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:23,代码来源:TransformUtil.java

示例2: getArg

import freemarker.template.TemplateScalarModel; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static String getArg(Map args, String key) {
    String  result = "";
    Object o = args.get(key);
    if (o != null) {
        if (Debug.verboseOn()) Debug.logVerbose("Arg Object : " + o.getClass().getName(), module);
        if (o instanceof TemplateScalarModel) {
            TemplateScalarModel s = (TemplateScalarModel) o;
            try {
                result = s.getAsString();
            } catch (TemplateModelException e) {
                Debug.logError(e, "Template Exception", module);
            }
        } else {
          result = o.toString();
        }
    }
    return result;
}
 
开发者ID:gildaslemoal,项目名称:elpi,代码行数:20,代码来源:OfbizCurrencyTransform.java

示例3: getArg

import freemarker.template.TemplateScalarModel; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static String getArg(Map args, String key) {
    String  result = "";
    Object obj = args.get(key);
    if (obj != null) {
        if (Debug.verboseOn()) Debug.logVerbose("Arg Object : " + obj.getClass().getName(), module);
        if (obj instanceof TemplateScalarModel) {
            TemplateScalarModel s = (TemplateScalarModel) obj;
            try {
                result = s.getAsString();
            } catch (TemplateModelException e) {
                Debug.logError(e, "Template Exception", module);
            }
        } else {
          result = obj.toString();
        }
    }
    return result;
}
 
开发者ID:gildaslemoal,项目名称:elpi,代码行数:20,代码来源:OfbizContentTransform.java

示例4: getArg

import freemarker.template.TemplateScalarModel; //导入方法依赖的package包/类
private static String getArg(Map args, String key) {
    String  result = "";
    Object o = args.get(key);
    if (o != null) {
        if (Debug.verboseOn()) Debug.logVerbose("Arg Object : " + o.getClass().getName(), module);
        if (o instanceof TemplateScalarModel) {
            TemplateScalarModel s = (TemplateScalarModel) o;
            try {
                result = s.getAsString();
            } catch (TemplateModelException e) {
                Debug.logError(e, "Template Exception", module);
            }
        } else {
          result = o.toString();
        }
    }
    return result;
}
 
开发者ID:gildaslemoal,项目名称:elpi,代码行数:19,代码来源:OfbizUrlTransform.java

示例5: exec

import freemarker.template.TemplateScalarModel; //导入方法依赖的package包/类
@Override
public Object exec(List arguments) throws TemplateModelException
{
    ExecutionStatistics.get().begin(NAME);
    if (arguments.size() < 1)
    {
        throw new TemplateModelException("Error, method expects one or two arguments (Integer, [verbosity:String])");
    }
    SimpleNumber simpleNumber = (SimpleNumber) arguments.get(0);
    int effort = simpleNumber.getAsNumber().intValue();

    Verbosity verbosity = Verbosity.SHORT;
    if (arguments.size() > 1)
    {
        final TemplateScalarModel verbosityModel = (TemplateScalarModel) arguments.get(1);
        String verbosityString = verbosityModel.getAsString();
        verbosity = Verbosity.valueOf(verbosityString.toUpperCase());
    }

    String result = EffortReportService.getEffortLevelDescription(verbosity, effort);

    ExecutionStatistics.get().end(NAME);
    return result;
}
 
开发者ID:windup,项目名称:windup,代码行数:25,代码来源:GetEffortDescriptionForPoints.java

示例6: exec

import freemarker.template.TemplateScalarModel; //导入方法依赖的package包/类
public Object exec(List list)
  throws TemplateModelException
{
  if (list.size() < 1) {
    throw new TemplateModelException("Wrong arguments");
  }

  TemplateScalarModel model = (TemplateScalarModel)list.get(0);

  if ((null == model) || (null == model.getAsString())) {
    return "";
  }

  return camel(model.getAsString());
}
 
开发者ID:javahaohao,项目名称:gen_code,代码行数:16,代码来源:UnderlineCapFirst.java

示例7: exec

import freemarker.template.TemplateScalarModel; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Object exec(List args) throws TemplateModelException {
    if (args == null || args.size() < 1 || args.size() > 3 ) {
        throw new TemplateModelException("Invalid number of arguments (expected: 1-3)");
    }
    Environment env = CommonFtlUtil.getCurrentEnvironment();
    TemplateModel object = (TemplateModel) args.get(0);
    
    String wrapperStr = null;
    String modeStr = null;
    if (args.size() >= 2) {        
        TemplateScalarModel wrapperModel = (TemplateScalarModel) args.get(1);
        if (wrapperModel != null) {
            wrapperStr = wrapperModel.getAsString();
        }
        
        if (args.size() >= 3) {
            TemplateScalarModel modeModel = (TemplateScalarModel) args.get(2);
            if (modeModel != null) {
                modeStr = modeModel.getAsString();
            }
        }
    }

    Object res = LangFtlUtil.rewrapObject(object, WrappingOptions.makeOptions(wrapperStr, modeStr, env), env);
    return res;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:29,代码来源:RewrapObjectMethod.java

示例8: getAsString

import freemarker.template.TemplateScalarModel; //导入方法依赖的package包/类
/**
 * Returns the given model as string, optionally bypassing auto-escaping done by EscapingModels.
 * 
 * @see org.ofbiz.webapp.ftl.EscapingModel
 */
public static String getAsString(TemplateScalarModel model, boolean nonEscaping) throws TemplateModelException {
    if (nonEscaping && (model instanceof EscapingModel)) {
        return (String) ((EscapingModel) model).getWrappedObject();
    } else {
        return model.getAsString();
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:13,代码来源:LangFtlUtil.java

示例9: getAsStringNonEscaping

import freemarker.template.TemplateScalarModel; //导入方法依赖的package包/类
/**
 * Returns the given model as string, bypassing auto-escaping done by EscapingModels.
 * <p>
 * WARN (TODO?: REVIEW?): this can crash when model is CollectionModel or MapModel, childs of TemplateScalarModel.
 * we let it crash because non-strict typing may be dangerous and hide errors...
 * 
 * @see org.ofbiz.webapp.ftl.EscapingModel
 */
public static String getAsStringNonEscaping(TemplateScalarModel model) throws TemplateModelException {
    if (model instanceof EscapingModel) {
        return (String) ((EscapingModel) model).getWrappedObject();
    } else {
        return model.getAsString();
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:16,代码来源:LangFtlUtil.java


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