FieldFunction.java :  » GWT » itemscript » org » itemscript » template » expression » Java Open Source

Java Open Source » GWT » itemscript 
itemscript » org » itemscript » template » expression » FieldFunction.java

package org.itemscript.template.expression;

import org.itemscript.core.JsonSystem;
import org.itemscript.core.values.JsonValue;
import org.itemscript.template.TemplateExec;

public class FieldFunction extends FunctionBase {
    private final String path;

    public FieldFunction(JsonSystem system, String path) {
        super(system, null);
        this.path = path;
    }

    //@Override
    public JsonValue execute(TemplateExec template, JsonValue context, JsonValue value) {
        if (path.length() == 0) {
            return context;
        } else {
            if (context != null && context.isContainer()) {
                return context.asContainer()
                        .getByPath(path);
            } else {
                return null;
            }
        }
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.