view flys-backend/src/main/java/de/intevation/hibernate/MapResultTransformer.java @ 4737:718adea968e2

Add <dc:variable name="variable" expr="xpath"/> construct to datacage language. Each time during traversal of the template this element is found a variable called 'variable' is set to the result of the the evaluation of the XPpath 'xpath'. Example: <dc:variable name="x" expr="$x + 1"/> <!-- Assign x+1 to x -->
author Sascha L. Teichmann <teichmann@intevation.de>
date Wed, 02 Jan 2013 14:05:21 +0100
parents 3d3e40d9d6d7
children 18619c1e7c2a
line wrap: on
line source
package de.intevation.hibernate;

import java.util.HashMap;
import java.util.Map;

import org.hibernate.transform.BasicTransformerAdapter;

public class MapResultTransformer
extends      BasicTransformerAdapter
{
    public static final MapResultTransformer INSTANCE =
        new MapResultTransformer();

    public MapResultTransformer() {
    }

    @Override
    public Object transformTuple(Object [] tuple, String [] aliases) {
        Map<String, Object> map = new HashMap<String, Object>();
        for (int i = 0; i < tuple.length; ++i) {
            map.put(aliases[i], tuple[i]);
        }
        return map;
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org