Package org.apache.velocity.context

Examples of org.apache.velocity.context.AbstractContext


        EventCartridge eventCartridge = new EventCartridge();
        eventCartridge.addEventHandler(new PropertiesReferenceInsertionHandler(currentGenerate.getConfigDescriptor(),
                props));

        Context context = new AbstractContext() {
            @Override
            public Object internalRemove(Object key) {
                return descriptorProps.remove(key);
            }

            @Override
            public Object internalPut(String key, Object value) {
                return descriptorProps.put(key, value);
            }

            @Override
            public Object[] internalGetKeys() {
                Set<Object> keys = new LinkedHashSet<Object>(props.keySet());
                keys.addAll(descriptorProps.keySet());
                return keys.toArray(new Object[keys.size()]);
            }

            @Override
            public Object internalGet(String key) {
                if (descriptorProps.containsKey(key)) {
                    return descriptorProps.get(key);
                } else {
                    return PropertiesLoader.evaluate(key, props);
                }
            }

            @Override
            public boolean internalContainsKey(Object key) {
                return descriptorProps.containsKey(key) || props.containsKey(key);
            }
        };

        eventCartridge.attachToContext(context); // ����ʹ��${a.b.c}
        context.put("D", "$"); // ������${D}������$

        return context;
    }
View Full Code Here


        EventCartridge eventCartridge = new EventCartridge();
        eventCartridge.addEventHandler(new PropertiesReferenceInsertionHandler(currentGenerate.getConfigDescriptor(),
                                                                               props));

        Context context = new AbstractContext() {
            @Override
            public Object internalRemove(Object key) {
                return descriptorProps.remove(key);
            }

            @Override
            public Object internalPut(String key, Object value) {
                return descriptorProps.put(key, value);
            }

            @Override
            public Object[] internalGetKeys() {
                Set<Object> keys = new LinkedHashSet<Object>(props.keySet());
                keys.addAll(descriptorProps.keySet());
                return keys.toArray(new Object[keys.size()]);
            }

            @Override
            public Object internalGet(String key) {
                if (descriptorProps.containsKey(key)) {
                    return descriptorProps.get(key);
                } else {
                    return PropertiesLoader.evaluate(key, props);
                }
            }

            @Override
            public boolean internalContainsKey(Object key) {
                return descriptorProps.containsKey(key) || props.containsKey(key);
            }
        };

        eventCartridge.attachToContext(context); // 允许使用${a.b.c}
        context.put("D", "$"); // 可以用${D}来生成$

        return context;
    }
View Full Code Here

        EventCartridge eventCartridge = new EventCartridge();
        eventCartridge.addEventHandler(new PropertiesReferenceInsertionHandler(currentGenerate.getConfigDescriptor(),
                props));

        Context context = new AbstractContext() {
            @Override
            public Object internalRemove(Object key) {
                return descriptorProps.remove(key);
            }

            @Override
            public Object internalPut(String key, Object value) {
                return descriptorProps.put(key, value);
            }

            @Override
            public Object[] internalGetKeys() {
                Set<Object> keys = new LinkedHashSet<Object>(props.keySet());
                keys.addAll(descriptorProps.keySet());
                return keys.toArray(new Object[keys.size()]);
            }

            @Override
            public Object internalGet(String key) {
                if (descriptorProps.containsKey(key)) {
                    return descriptorProps.get(key);
                } else {
                    return PropertiesLoader.evaluate(key, props);
                }
            }

            @Override
            public boolean internalContainsKey(Object key) {
                return descriptorProps.containsKey(key) || props.containsKey(key);
            }
        };

        eventCartridge.attachToContext(context); // ����ʹ��${a.b.c}
        context.put("D", "$"); // ������${D}������$

        return context;
    }
View Full Code Here

TOP

Related Classes of org.apache.velocity.context.AbstractContext

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.