Examples of TemplateSequenceModel


Examples of freemarker.template.TemplateSequenceModel

                }
                index++;
            }
        }
        else if (list instanceof TemplateSequenceModel) {
            TemplateSequenceModel tsm = (TemplateSequenceModel) list;
            int size = tsm.size();
            for (index =0; index <size; index++) {
              clear();
                loopVar = tsm.get(index);
                put(iteratorBlock.getIndexName(), loopVar);
                hasNext = (size > index + 1);
                TemplateBooleanModel hasNextModel = (size > index +1) ?  TemplateBooleanModel.TRUE : TemplateBooleanModel.FALSE;
                put(iteratorBlock.getIndexName() + "_has_next", hasNextModel);
                put(iteratorBlock.getIndexName() + "_index", new SimpleNumber(index));
View Full Code Here

Examples of freemarker.template.TemplateSequenceModel

                    }
                } else {
                    recursionStops =
                        new IdentityHashMap<TemplateModel, Object>();
                }
                TemplateSequenceModel seq = (TemplateSequenceModel)model;
                Class componentType = requiredType.getComponentType();
                Object array = Array.newInstance(componentType, seq.size());
                recursionStops.put(model, array);
                try {
                    int size = seq.size();
                    for (int i = 0; i < size; i++) {
                        Object val = unwrap(seq.get(i), componentType,
                                recursionStops);
                        if(val == CAN_NOT_UNWRAP) {
                            return CAN_NOT_UNWRAP;
                        }
                        Array.set(array, i, val);
View Full Code Here

Examples of freemarker.template.TemplateSequenceModel

        }
        if(model instanceof TemplateBooleanModel) {
            return ((TemplateBooleanModel)model).getAsBoolean() ? Boolean.TRUE : Boolean.FALSE;
        }
        if(model instanceof TemplateSequenceModel) {
            TemplateSequenceModel seq = (TemplateSequenceModel)model;
            ArrayList<Object> list = new ArrayList<Object>(seq.size());
            for(int i = 0; i < seq.size(); ++i) {
                list.add(unwrap(seq.get(i), permissive));
            }
            return list;
        }
        if(model instanceof TemplateCollectionModel) {
            TemplateCollectionModel coll = (TemplateCollectionModel)model;
View Full Code Here

Examples of freemarker.template.TemplateSequenceModel

   

    // A hacky routine used by VisitNode and RecurseNode
   
    TemplateSequenceModel evaluateStringsToNamespaces(Environment env) throws TemplateException {
        TemplateSequenceModel val = (TemplateSequenceModel) getAsTemplateModel(env);
        SimpleSequence result = new SimpleSequence(val.size());
        for (int i=0; i<values.size(); i++) {
            if (values.get(i) instanceof StringLiteral) {
                String s = ((StringLiteral) values.get(i)).getAsString();
                try {
                    TemplateNamespace ns = env.importLib(s, null);
                    result.add(ns);
                }
                catch (IOException ioe) {
                    throw new TemplateException("Could not import library '" + s + "', " + ioe.getMessage(), env);
                }
            }
            else {
                result.add(val.get(i));
            }
        }
        return result;
    }
View Full Code Here

Examples of freemarker.template.TemplateSequenceModel

                    throws TemplateModelException {
                if (chunkIndex >= numberOfChunks) {
                    return null;
                }
               
                return new TemplateSequenceModel() {
                   
                    private final int baseIndex = chunkIndex * chunkSize;

                    public TemplateModel get(int relIndex)
                            throws TemplateModelException {
View Full Code Here

Examples of freemarker.template.TemplateSequenceModel

                String[] subvars;
                Object obj = params.get(0);
                if (obj instanceof TemplateScalarModel) {
                    subvars = new String[]{((TemplateScalarModel) obj).getAsString()};
                } else if (obj instanceof TemplateSequenceModel) {
                    TemplateSequenceModel seq = (TemplateSequenceModel) obj;
                    int ln = seq.size();
                    subvars = new String[ln];
                    for (int i = 0; i < ln; i++) {
                        Object item = seq.get(i);
                        try {
                            subvars[i] = ((TemplateScalarModel) item)
                                    .getAsString();
                        } catch (ClassCastException e) {
                            if (!(item instanceof TemplateScalarModel)) {
View Full Code Here

Examples of freemarker.template.TemplateSequenceModel

            }
        }

        public TemplateModel getGroups() {
            if (groups == null) {
                groups = new TemplateSequenceModel() {
                    public int size() throws TemplateModelException {
                        try {
                            return matcher.groupCount() + 1;
                        }
                        catch (Exception e) {
View Full Code Here

Examples of freemarker.template.TemplateSequenceModel

    public TemplateModel get(Environment env, BuiltInExpression caller,
            TemplateModel model)
    throws TemplateException {
        String id = null, interpretString = null;
        if (model instanceof TemplateSequenceModel) {
            TemplateSequenceModel tsm = (TemplateSequenceModel) model;
            TemplateModel tm = tsm.get(1);
            if (tm != null) {
                if(tm instanceof TemplateScalarModel) {
                    id = ((TemplateScalarModel) tm).getAsString();
                }
                else {
                    throw new TemplateModelException("Expecting string as second item of sequence of left of ?interpret built-in");
                }
            }
            tm = tsm.get(0);
            if (!(tm instanceof TemplateScalarModel)) {
                throw new TemplateModelException("Expecting string as first item of sequence of left of ?interpret built-in");
            }
            interpretString = ((TemplateScalarModel) tm).getAsString();
        }
View Full Code Here

Examples of freemarker.template.TemplateSequenceModel

        throws TemplateModelException {
            if (chunkIndex >= numberOfChunks) {
                return null;
            }

            return new TemplateSequenceModel() {

                private final int baseIndex = chunkIndex * chunkSize;

                public TemplateModel get(int relIndex)
                throws TemplateModelException {
View Full Code Here

Examples of freemarker.template.TemplateSequenceModel

            String[] subvars;
            Object obj = params.get(0);
            if (obj instanceof TemplateScalarModel) {
                subvars = new String[]{((TemplateScalarModel) obj).getAsString()};
            } else if (obj instanceof TemplateSequenceModel) {
                TemplateSequenceModel seq = (TemplateSequenceModel) obj;
                int ln = seq.size();
                subvars = new String[ln];
                for (int i = 0; i < ln; i++) {
                    Object item = seq.get(i);
                    try {
                        subvars[i] = ((TemplateScalarModel) item)
                        .getAsString();
                    } catch (ClassCastException e) {
                        if (!(item instanceof TemplateScalarModel)) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.