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


Java TemplateBooleanModel.getAsBoolean方法代码示例

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


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

示例1: execute

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

    SimpleNumber width = (SimpleNumber) params.get("width");
    SimpleNumber height = (SimpleNumber) params.get("height");
    SimpleScalar uri = (SimpleScalar) params.get("uri");
    SimpleScalar var = (SimpleScalar) params.get("var");
    BeanModel pSource = (BeanModel) params.get("src");
    TemplateBooleanModel pParent = (TemplateBooleanModel) params.get("parent");

    if (pSource != null && uri != null)
        throw new IllegalArgumentException("The parameters 'src' and 'uri' cannot be set at the same time.");

    if (pSource == null && uri == null)
        throw new IllegalArgumentException("You must provide either a 'src' or 'uri' parameter.");

    Product product = null;
    String uriStr = null;
    boolean fallbackToParent = false;

    if (pParent != null) {
        fallbackToParent = pParent.getAsBoolean();
    }

    if (pSource != null) {

        if (!(pSource instanceof BeanModel))
            throw new IllegalArgumentException("The parameter 'src' must be of type BeanModel (Product)");

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

        if (beanModel instanceof Product) {
            product = (Product) beanModel;

            if (product.getMainImage() != null) {
                uriStr = product.getMainImage().getPath();
            }

            if (uriStr == null && product.isVariant() && fallbackToParent) {
                Product parent = product.getParent();

                if (parent != null && parent.getMainImage() != null) {
                    uriStr = parent.getMainImage().getPath();
                }
            }
        } else {
            throw new IllegalArgumentException("The source-object must be of type Product");
        }
    }

    if (uri != null || uriStr != null) {
        if (uri != null) {
            uriStr = uri.getAsString();
        }

        String varStr = null;

        if (var != null)
            varStr = var.getAsString();

        if (!Str.isEmpty(uriStr)) {
            String mediaAssetURL = catalogMediaHelper.toMediaAssetURL(uriStr,
                width == null ? null : width.getAsNumber().intValue(),
                height == null ? null : height.getAsNumber().intValue());

            if (varStr != null) {
                env.setVariable(varStr, DefaultObjectWrapper.getDefaultInstance().wrap(mediaAssetURL));
            } else {
                env.getOut().write(mediaAssetURL);
            }
        }
    }
}
 
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:79,代码来源:CatalogMediaAssetURLDirective.java

示例2: exec

import freemarker.template.TemplateBooleanModel; //导入方法依赖的package包/类
@Override
public Object exec(@SuppressWarnings("rawtypes") List arguments) throws TemplateModelException
{
    // Process arguments
    ExecutionStatistics.get().begin(NAME);
    if (arguments.size() < 2)
    {
        throw new TemplateModelException(
            "Error, method expects at least three arguments"
            + " (projectModel: ProjectModel, recursive: Boolean, [includeTags: Set<String>], [excludeTags: Set<String>])");
    }
    StringModel projectModelTraversalArg = (StringModel) arguments.get(0);
    ProjectModelTraversal projectModelTraversal = (ProjectModelTraversal) projectModelTraversalArg.getWrappedObject();

    TemplateBooleanModel recursiveBooleanModel = (TemplateBooleanModel) arguments.get(1);
    boolean recursive = recursiveBooleanModel.getAsBoolean();

    Set<String> includeTags = Collections.emptySet();
    if (arguments.size() >= 3)
    {
        includeTags = FreeMarkerUtil.simpleSequenceToSet((SimpleSequence) arguments.get(2));
    }

    Set<String> excludeTags = Collections.emptySet();
    if (arguments.size() >= 4)
    {
        excludeTags = FreeMarkerUtil.simpleSequenceToSet((SimpleSequence) arguments.get(3));
    }

    Set<String> issueCategories = Collections.emptySet();
    if (arguments.size() >= 5)
    {
        issueCategories = FreeMarkerUtil.simpleSequenceToSet((SimpleSequence) arguments.get(4));
    }

    // Get values for classification and hints.
    Map<Integer, Integer> classificationEffortDetails =
            classificationService.getMigrationEffortByPoints(projectModelTraversal, includeTags, excludeTags, issueCategories, recursive, false);
    Map<Integer, Integer> hintEffortDetails =
            inlineHintService.getMigrationEffortByPoints(projectModelTraversal, includeTags, excludeTags, issueCategories, recursive, false);

    Map<Integer, Integer> results = sumMaps(classificationEffortDetails, hintEffortDetails);

    ExecutionStatistics.get().end(NAME);


    int points = sumPoints(results);
    LOG.fine(String.format("%s() FM function called:\n\t\t\tEFFORT: %3d = %s = C%s + H%s; %s, %srecur, tags: %s, excl: %s",
            NAME, points, results, classificationEffortDetails, hintEffortDetails,
            projectModelTraversal, recursive ? "" : "!", includeTags, excludeTags));

    return results;
}
 
开发者ID:windup,项目名称:windup,代码行数:54,代码来源:GetEffortDetailsForProjectTraversalMethod.java

示例3: exec

import freemarker.template.TemplateBooleanModel; //导入方法依赖的package包/类
@Override
public Object exec(@SuppressWarnings("rawtypes") List arguments) throws TemplateModelException
{
    ExecutionStatistics.get().begin(NAME);
    if (arguments.size() < 3)
    {
        throw new TemplateModelException(
                    "Error, method expects at least three arguments (event:GraphRewrite, projectModelTraversal:ProjectModelTraversal, recursive:Boolean, [includeTags:Set<String>]. [excludeTags:Set<String>])");
    }

    GraphRewrite event = (GraphRewrite)((StringModel)arguments.get(0)).getWrappedObject();

    StringModel projectModelTraversalArg = (StringModel) arguments.get(1);
    ProjectModelTraversal traversal = (ProjectModelTraversal) projectModelTraversalArg.getWrappedObject();

    TemplateBooleanModel recursiveBooleanModel = (TemplateBooleanModel) arguments.get(2);
    boolean recursive = recursiveBooleanModel.getAsBoolean();

    Set<String> includeTags = Collections.emptySet();
    if (arguments.size() >= 4)
    {
        includeTags = FreeMarkerUtil.simpleSequenceToSet((SimpleSequence) arguments.get(3));
    }

    Set<String> excludeTags = Collections.emptySet();
    if (arguments.size() >= 5)
    {
        excludeTags = FreeMarkerUtil.simpleSequenceToSet((SimpleSequence) arguments.get(4));
    }

    Map<IssueCategoryModel, Integer> classificationEffortDetails = classificationService.getMigrationEffortBySeverity(event, traversal, includeTags,
                excludeTags, Collections.emptySet(), recursive);
    Map<IssueCategoryModel, Integer> hintEffortDetails = inlineHintService.getMigrationEffortBySeverity(event, traversal, includeTags, excludeTags,
            Collections.emptySet(), recursive);

    Map<IssueCategoryModel, Integer> results = new TreeMap<>(new IssueCategoryModel.IssueSummaryPriorityComparator());
    addAllIncidents(results, classificationEffortDetails);
    addAllIncidents(results, hintEffortDetails);

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

示例4: execute

import freemarker.template.TemplateBooleanModel; //导入方法依赖的package包/类
@Override
public void execute(Environment env, @SuppressWarnings("rawtypes") Map params, TemplateModel[] loopVars,
            TemplateDirectiveBody body)
            throws TemplateException, IOException
{
    StringModel projectStringModel = (StringModel) params.get("project");
    ProjectModel projectModel = null;
    if (projectStringModel != null)
        projectModel = (ProjectModel) projectStringModel.getWrappedObject();

    StringModel projectTraversalStringModel = (StringModel) params.get("projectTraversal");
    ProjectModelTraversal projectTraversal = null;
    if (projectTraversalStringModel != null)
        projectTraversal = (ProjectModelTraversal) projectTraversalStringModel.getWrappedObject();

    if (projectModel != null && projectTraversal != null)
        throw new WindupException(NAME + " both 'project' and 'projectTraversal' were specified. Only one of these values should be specified.");
    else if (projectModel == null && projectTraversal == null)
        throw new WindupException(NAME + " neither 'project' nor 'projectTraversal' were specified. At least one of these must be specified.");

    TemplateBooleanModel recursiveBooleanModel = (TemplateBooleanModel) params.get("recursive");
    boolean recursive = recursiveBooleanModel.getAsBoolean();
    SimpleScalar elementIDStringModel = (SimpleScalar) params.get("elementID");
    String elementID = elementIDStringModel.getAsString();

    Set<String> includeTags = FreeMarkerUtil.simpleSequenceToSet((SimpleSequence) params.get("includeTags"));
    Set<String> excludeTags = FreeMarkerUtil.simpleSequenceToSet((SimpleSequence) params.get("excludeTags"));

    TypeReferenceService typeReferenceService = new TypeReferenceService(context);
    Map<String, Integer> data;
    if (projectModel != null)
        data = typeReferenceService.getPackageUseFrequencies(projectModel, includeTags, excludeTags, 2, recursive);
    else
        data = typeReferenceService.getPackageUseFrequencies(projectTraversal, includeTags, excludeTags, 2, recursive);

    if (data.keySet().size() > 0)
    {
        drawPie(env.getOut(), data, elementID);
    }
    else
    {
        // if we aren't drawing a pie, remove the element that would have held it
        Writer writer = env.getOut();
        writer.append("<script type='text/javascript'>");
        writer.append("$('#" + elementID + "').parent().remove()");
        writer.append("</script>");
    }
}
 
开发者ID:windup,项目名称:windup,代码行数:49,代码来源:RenderApplicationPieChartDirective.java


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