All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nflabs.zeppelin.zengine.ZWebContext Maven / Gradle / Ivy

Go to download

Zengine is java framework for data analysis on Hadoop. see http://nflabs.github.io/zeppelin/#/zengine

There is a newer version: 0.3.3
Show newest version
package com.nflabs.zeppelin.zengine;

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

import com.nflabs.zeppelin.result.Result;

/**
 * Zeppelin Web Context. Passed to Zeppelin UDF's web template.
 * ZWebContext have result data of execution.
 * Normally result in ZWebContext is used to visualize data in web template file.
 * @author moon
 *
 */
public class ZWebContext {

	private Result result;
	private Map params;
	Map paramInfos = new HashMap();

	
	public ZWebContext(Result resultDataObject) {
		this.result = resultDataObject;
		this.params = new HashMap();
	}
	/**
	 * 
	 * @param params 
	 * @param resultDataObject result data after execution
	 */
	public ZWebContext(Map params, Result resultDataObject) {
		this.result = resultDataObject;
		this.params = params;
	}
	
	/**
	 * Get result data
	 * @return result
	 */
	public Result result(){
		return result;
	}
	
	/**
	 * Get params;
	 * @return 
	 */
	public Object param(String name){
		return param(name, null);
	}

	/**
	 * Get params;
	 * @param name name of parameter
	 * @param defaultValue defaultValue of the param
	 * @return 
	 */
	public Object param(String name, Object defaultValue){
		if(paramInfos.containsKey(name)==false){
			paramInfos.put(name, new ParamInfo(name, defaultValue));
		}
		
		Object r = params.get(name);
		if(r==null){
			return defaultValue;
		} else {
			return r;
		}
	}

	
	public Map getParamInfos(){
		return paramInfos;
	}
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy