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


Java SimpleScalar类代码示例

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


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

示例1: createTagRenderer

import freemarker.template.SimpleScalar; //导入依赖的package包/类
@Override
@SuppressWarnings("nls")
protected TagRenderer createTagRenderer(HtmlMutableListState state, Environment env, Map<?, ?> params,
	TemplateDirectiveBody body, TemplateModel[] loopVars) throws TemplateModelException
{
	String tag = "div";
	if( params.containsKey("tag") )
	{
		tag = ((SimpleScalar) params.get("tag")).getAsString();
	}

	boolean hideDisabledOptions = false;
	if( params.containsKey("hideDisabledOptions") )
	{
		hideDisabledOptions = ((TemplateBooleanModel) params.get("hideDisabledOptions")).getAsBoolean();
	}

	return new ButtonListTagRenderer(tag, (HtmlListState) state, env, body, loopVars, hideDisabledOptions);
}
 
开发者ID:equella,项目名称:Equella,代码行数:20,代码来源:ButtonListDirective.java

示例2: exec

import freemarker.template.SimpleScalar; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public Object exec(List arguments) throws TemplateModelException {
  if (arguments.size() != 1) {
    throw new TemplateModelException("Wrong number of arguments. Must be 1.");
  }

  String userPartOfStep = "";
  Step step = getStepFromFreemarker(arguments.get(0));
  if (hasUser(step)) {
    String userActorName = getUserActor(step).getName();
    String wordsOfUserEventClassName = getLowerCaseWordsOfClassName(step.getUserEventClass());
    userPartOfStep = userActorName + " " + wordsOfUserEventClassName + USER_POSTFIX;
  }
  
  return new SimpleScalar(userPartOfStep);
}
 
开发者ID:bertilmuth,项目名称:requirementsascode,代码行数:18,代码来源:UserPartOfStep.java

示例3: exec

import freemarker.template.SimpleScalar; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public Object exec(List arguments) throws TemplateModelException {
  if (arguments.size() != 1) {
    throw new TemplateModelException("Wrong number of arguments. Must be 1.");
  }

  Step step = getStep(arguments.get(0));

  String reactWhile = "";
  if (step.getPredicate() instanceof ReactWhile) {
    ReactWhile reactWhilePredicate = (ReactWhile) step.getPredicate();
    reactWhile = REACT_WHILE_PREFIX
        + getLowerCaseWordsOfClassName(getReactWhileConditionClass(reactWhilePredicate)) + REACT_WHILE_POSTFIX;
  }

  return new SimpleScalar(reactWhile);
}
 
开发者ID:bertilmuth,项目名称:requirementsascode,代码行数:19,代码来源:ReactWhileOfStep.java

示例4: getWrappedObject

import freemarker.template.SimpleScalar; //导入依赖的package包/类
/**
* Gets BeanModel from FreeMarker context and returns the object that it wraps.
* @param varName the name of the variable in the FreeMarker context.
* @param env the FreeMarker Environment
*/
public static <T> T getWrappedObject(String varName, Environment env) {
    Object obj = null;
    try {
        obj = env.getVariable(varName);
        if (obj != null) {
            if (obj == TemplateModel.NOTHING) {
                obj = null;
            } else if (obj instanceof BeanModel) {
                BeanModel bean = (BeanModel) obj;
                obj = bean.getWrappedObject();
            } else if (obj instanceof SimpleScalar) {
                obj = obj.toString();
            }
        }
    } catch (TemplateModelException e) {
        Debug.logInfo(e.getMessage(), module);
    }
    return UtilGenerics.<T>cast(obj);
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:25,代码来源:FreeMarkerWorker.java

示例5: 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;
            // SCIPIO: This needs to bypass auto-escaping
            //return new BigDecimal(s.getAsString());
            try {
                return new BigDecimal(LangFtlUtil.getAsStringNonEscaping(s));
            } catch (TemplateModelException e) {
                Debug.logError(e, "Template Exception", module);
            }
        }
        return new BigDecimal(o.toString());
    }
    return BigDecimal.ZERO;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:26,代码来源:OfbizCurrencyTransform.java

示例6: execPush

import freemarker.template.SimpleScalar; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected Object execPush(List args, boolean setLast) throws TemplateModelException {
    if (args == null || args.size() != 2) {
        throw new TemplateModelException("Invalid number of arguments (expected: 2)");
    }
    TemplateModel nameModel = (TemplateModel) args.get(0);
    if (!(nameModel instanceof TemplateScalarModel)) {
        throw new TemplateModelException("First argument not an instance of TemplateScalarModel (string)");
    }
    TemplateModel valueModel = (TemplateModel) args.get(1);

    Environment env = CommonFtlUtil.getCurrentEnvironment();
    ContextFtlUtil.pushRequestStack(LangFtlUtil.getAsStringNonEscaping(((TemplateScalarModel) nameModel)), valueModel, setLast, env);
    
    return new SimpleScalar("");
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:17,代码来源:RequestStackMethod.java

示例7: exec

import freemarker.template.SimpleScalar; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
public Object exec(List arguments) throws TemplateModelException {
	if (arguments != null && !arguments.isEmpty() && arguments.get(0) != null && StringUtils.isNotEmpty(arguments.get(0).toString())) {
		Integer width = null;
		String ellipsis = null;
		if (arguments.size() == 2) {
			if (arguments.get(1) != null) {
				width = Integer.valueOf(arguments.get(1).toString());
			}
		} else if (arguments.size() > 2) {
			if (arguments.get(1) != null) {
				width = Integer.valueOf(arguments.get(1).toString());
			}
			if (arguments.get(2) != null) {
				ellipsis = arguments.get(2).toString();
			}
		}
		return new SimpleScalar(abbreviate(arguments.get(0).toString(), width, ellipsis));
	}
	return null;
}
 
开发者ID:justinbaby,项目名称:my-paper,代码行数:22,代码来源:AbbreviateMethod.java

示例8: execute

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

    List<RetailStore> retailStoreList = retailStores.enabledRetailStores();

    if (pVar != null) {
        // Sets the result into the current template as if using <#assign
        // name=model>.
        env.setVariable(pVar.getAsString(), DefaultObjectWrapper.getDefaultInstance().wrap(retailStoreList));
    } else {
        // Sets the result into the current template as if using <#assign
        // name=model>.
        env.setVariable("retailStores", DefaultObjectWrapper.getDefaultInstance().wrap(retailStoreList));
    }
}
 
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:19,代码来源:FetchRetailStoresDirective.java

示例9: transformSimpleSequenceAsStringList

import freemarker.template.SimpleScalar; //导入依赖的package包/类
/**
 * Transform simple sequence as string list.
 *
 * @param sequence the sequence
 * @param paramName the param name
 * @return the list
 * @throws TemplateModelException the template model exception
 */
private List<String> transformSimpleSequenceAsStringList(SimpleSequence sequence, String paramName)
        throws TemplateModelException {
    List<String> list = new ArrayList<>();
    int size = sequence.size();

    for (int i = 0; i < size; i++) {
        TemplateModel model = sequence.get(i);

        if (!(model instanceof SimpleScalar)) {
            throw new IllegalArgumentException(paramName + "'s item must be string");
        }

        list.add(((SimpleScalar)model).getAsString());
    }

    return list;
}
 
开发者ID:aspectran,项目名称:aspectran,代码行数:26,代码来源:AbstractTrimDirectiveModel.java

示例10: execute

import freemarker.template.SimpleScalar; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public void execute(Environment env, Map params,
                    TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException {
    String name = DirectiveKit.getRequiredParam(params, "name");
    params.remove("name");

    if (!name.endsWith(".ftl")) {
        name = name + ".ftl";
    }
    String encoding = DirectiveKit.getParam(params, "encoding", StringPool.UTF_8);
    String includeTemplateName = TemplateCache.getFullTemplatePath(env, getTemplatePath(env), name);
    Configuration configuration = env.getConfiguration();
    final Template template = configuration.getTemplate(includeTemplateName, env.getLocale(), encoding, true);
    for (Object key : params.keySet()) {
        TemplateModel paramModule = new SimpleScalar(params.get(key).toString());
        env.setVariable(key.toString(), paramModule);
    }
    env.include(template);
}
 
开发者ID:GojaFramework,项目名称:goja,代码行数:21,代码来源:ExtendsDirective.java

示例11: exec

import freemarker.template.SimpleScalar; //导入依赖的package包/类
@Override
public TemplateModel exec(List arguments) throws TemplateModelException {
    String url;
    if (arguments.size() >= MIN_ARGUMENTS) {
        String controller = ((SimpleScalar) arguments.get(0)).getAsString();
        Route route = Router.getReverseRoute(controller);
        if (route != null) {
            url = route.getUrl();
            Matcher matcher = PARAMETER_PATTERN.matcher(url);
            int i = 1;
            while (matcher.find()) {
                String argument = ((SimpleScalar) arguments.get(i)).getAsString();
                url = StringUtils.replace(url, "{" + matcher.group(1) + "}", argument);
                i++;
            }
        } else {
            throw new TemplateModelException("Reverse route for " + controller + " could not be found!");
        }
    } else {
        throw new TemplateModelException("Missing at least one argument (ControllerClass:ControllerMethod) for reverse routing!");
    }

    return new SimpleScalar(url);
}
 
开发者ID:svenkubiak,项目名称:mangooio,代码行数:25,代码来源:RouteMethod.java

示例12: exec

import freemarker.template.SimpleScalar; //导入依赖的package包/类
/**
 * Compacts an input string.
 * <p>
 * {@inheritDoc}
 */
@Override
public TemplateModel exec(List arguments)
    throws TemplateModelException {
  try {
    String toCompact = ((TemplateScalarModel) arguments.get(0)).getAsString();
    if (toCompact == null || toCompact.length() == 0) {
      return new SimpleScalar("");
    }
    StringBuilder result = new StringBuilder();
    result.append(Character.toUpperCase(toCompact.charAt(0)));
    for (int i = 1; i < toCompact.length(); i++) {
      char prev = toCompact.charAt(i - 1);
      char curr = toCompact.charAt(i);
      if ((Character.isUpperCase(curr) && Character.isLowerCase(prev))
          || prev == UNDERSCORE) {
        result.append(Character.toUpperCase(curr));
      }
    }
    return new SimpleScalar(result.toString());
  } catch (Exception ex) {
    throw new TemplateModelException("Could execute compactString method.",
        ex);
  }
}
 
开发者ID:jspresso,项目名称:jspresso-ce,代码行数:30,代码来源:CompactString.java

示例13: exec

import freemarker.template.SimpleScalar; //导入依赖的package包/类
/**
 * Infer a SQL column name from a property name. By default: - use camel
 * parser to separate words with "_" - check for sql reserved key words
 * {@inheritDoc}
 */
@SuppressWarnings("rawtypes")
@Override
public TemplateModel exec(List arguments) throws TemplateModelException {

  String root = arguments.get(0).toString();
  String suffix = null;
  if (arguments.size() > 1 && arguments.get(1) != null) {
    suffix = arguments.get(1).toString();
  }

  String sqlColumnName = new SqlHelper(formatter, keyWordProvider).transformToSql(root, suffix);
  try {
    return new SimpleScalar(sqlColumnName);
  } catch (Exception ex) {
    throw new TemplateModelException("Could not infer SQL column name.", ex);
  }
}
 
开发者ID:jspresso,项目名称:jspresso-ce,代码行数:23,代码来源:GenerateSqlName.java

示例14: 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

示例15: exec

import freemarker.template.SimpleScalar; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public Object exec(List args) throws TemplateModelException {
    if (args == null || args.size() != 2)
        throw new TemplateModelException("Invalid number of arguements");
    if (!(args.get(0) instanceof TemplateScalarModel))
        throw new TemplateModelException("First argument not an instance of TemplateScalarModel");
    if (!(args.get(1) instanceof BeanModel) && !(args.get(1) instanceof TemplateNumberModel) && !(args.get(1) instanceof TemplateScalarModel))
        throw new TemplateModelException("Second argument not an instance of BeanModel nor TemplateNumberModel nor TemplateScalarModel");

    Environment env = Environment.getCurrentEnvironment();
    BeanModel req = (BeanModel)env.getVariable("request");
    HttpServletRequest request = (HttpServletRequest) req.getWrappedObject();

    String name = ((TemplateScalarModel) args.get(0)).getAsString();
    Object value = null;
    if (args.get(1) instanceof TemplateScalarModel)
        value = ((TemplateScalarModel) args.get(1)).getAsString();
    if (args.get(1) instanceof TemplateNumberModel)
        value = ((TemplateNumberModel) args.get(1)).getAsNumber();
    if (args.get(1) instanceof BeanModel)
        value = ((BeanModel) args.get(1)).getWrappedObject();

    request.setAttribute(name, value);
    return new SimpleScalar("");
}
 
开发者ID:gildaslemoal,项目名称:elpi,代码行数:26,代码来源:SetRequestAttributeMethod.java


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