Package freemarker.template

Examples of freemarker.template.TemplateNumberModel


        this.target = target;
        this.isMinus = isMinus;
    }
   
    TemplateModel _eval(Environment env) throws TemplateException {
        TemplateNumberModel targetModel = null;
        TemplateModel tm = target.eval(env);
        try {
            targetModel = (TemplateNumberModel) tm;
        } catch (ClassCastException cce) {
            throw new NonNumericalException(target, tm, env);
        }
        if (!isMinus) {
            return targetModel;
        }
        target.assertNonNull(targetModel, env);
        Number n = targetModel.getAsNumber();
        n = ArithmeticEngine.CONSERVATIVE_ENGINE.multiply(MINUS_ONE, n);
        return new SimpleNumber(n);
    }
View Full Code Here


    {
        int bufferSize = defaultBufferSize;
        boolean singleLine = false;
        if (args != null) {
            try {
                TemplateNumberModel num = (TemplateNumberModel)args.get(BUFFER_SIZE_KEY);
                if (num != null)
                    bufferSize = num.getAsNumber().intValue();
            } catch (ClassCastException e) {
                throw new TemplateModelException("Expecting numerical argument to " + BUFFER_SIZE_KEY);
            }
            try {
                TemplateBooleanModel flag = (TemplateBooleanModel)args.get(SINGLE_LINE_KEY);
View Full Code Here

            }
        }

        private void testProperty(TemplateHashModel h, int objIdx, int mIdx)
                throws TemplateModelException, AssertionError {
            TemplateNumberModel pv = (TemplateNumberModel) h.get("p" + mIdx);
            final int expected = objIdx * 1000 + mIdx;
            final int got = pv.getAsNumber().intValue();
            if (got != expected) {
                throw new AssertionError("Property assertation failed; " +
                        "expected " + expected + ", but got " + got);
            }
        }
View Full Code Here

                return "phil";
            }
        });

        // TemplateNumberModel
        params.put("property5", new TemplateNumberModel() {
            public Number getAsNumber() throws TemplateModelException {
                return new Integer("10");
            }
        });
        params.put("property6", new TemplateNumberModel() {
            public Number getAsNumber() throws TemplateModelException {
                return new Float("1.1");
            }
        });
View Full Code Here

                return "phil";
            }
        });

        // TemplateNumberModel
        params.put("property5", new TemplateNumberModel() {
            public Number getAsNumber() throws TemplateModelException {
                return new Integer("10");
            }
        });
        params.put("property6", new TemplateNumberModel() {
            public Number getAsNumber() throws TemplateModelException {
                return new Float("1.1");
            }
        });
View Full Code Here

                return "phil";
            }
        });

        // TemplateNumberModel
        params.put("property5", new TemplateNumberModel() {
            public Number getAsNumber() throws TemplateModelException {
                return new Integer("10");
            }
        });
        params.put("property6", new TemplateNumberModel() {
            public Number getAsNumber() throws TemplateModelException {
                return new Float("1.1");
            }
        });
View Full Code Here

                return "phil";
            }
        });

        // TemplateNumberModel
        params.put("property5", new TemplateNumberModel() {
            public Number getAsNumber() throws TemplateModelException {
                return new Integer("10");
            }
        });
        params.put("property6", new TemplateNumberModel() {
            public Number getAsNumber() throws TemplateModelException {
                return new Float("1.1");
            }
        });
View Full Code Here

     * @param configuration
     * @return
     */
    @Override
    public TemplateNumberModel transform(final RDFBackend<Node> nodeRDFBackend, final Node node, final Map<String, String> configuration) throws IllegalArgumentException {
        return new TemplateNumberModel() {
            @Override
            public Number getAsNumber() throws TemplateModelException {
                return delegate.transform(nodeRDFBackend, node, configuration);
            }
        };
View Full Code Here

     * @param configuration
     * @return
     */
    @Override
    public TemplateNumberModel transform(final RDFBackend<Node> nodeRDFBackend, final Node node, final Map<String, String> configuration) throws IllegalArgumentException {
        return new TemplateNumberModel() {
            @Override
            public Number getAsNumber() throws TemplateModelException {
                return delegate.transform(nodeRDFBackend,node, configuration);
            }
        };
View Full Code Here

     * @param configuration
     * @return
     */
    @Override
    public TemplateNumberModel transform(final RDFBackend<Node> nodeRDFBackend, final Node node, final Map<String, String> configuration) throws IllegalArgumentException {
        return new TemplateNumberModel() {
            @Override
            public Number getAsNumber() throws TemplateModelException {
                return delegate.transform(nodeRDFBackend, node, configuration);
            }
        };
View Full Code Here

TOP

Related Classes of freemarker.template.TemplateNumberModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.