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

jadex.bdi.runtime.impl.ParameterInfo Maven / Gradle / Ivy

package jadex.bdi.runtime.impl;

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

import jadex.bdi.model.MParameter;
import jadex.bdi.model.MParameter.EvaluationMode;
import jadex.bdi.runtime.IParameter;
import jadex.common.ClassInfo;
import jadex.common.UnparsedExpression;

/**
 *  Parameter info.
 */
public class ParameterInfo 
{
	/** The name. */
	protected String name;
	
	/** The type. */
	protected String type;
	
	/** The value as string. */
	protected String value;
	
	/** Other parameter properties. */
	protected Map props;

	/**
	 *  Get the name.
	 *  @return the name
	 */
	public String getName() 
	{
		return name;
	}

	/**
	 *  Set the name.
	 *  @param name the name to set
	 */
	public ParameterInfo setName(String name) 
	{
		this.name = name;
		return this;
	}

	/**
	 *  Get the type.
	 *  @return the type
	 */
	public String getType() 
	{
		return type;
	}

	/**
	 *  Set the type.
	 *  @param type the type to set
	 */
	public ParameterInfo setType(String type) 
	{
		this.type = type;
		return this;
	}

	/**
	 *  Get the value.
	 *  @return the value
	 */
	public String getValue() 
	{
		return value;
	}

	/**
	 *  Set the value.
	 *  @param value the value to set
	 */
	public ParameterInfo setValue(String value) 
	{
		this.value = value;
		return this;
	}

	/**
	 * @return the props
	 */
	public Map getProps() 
	{
		return props;
	}

	/**
	 * @param props the props to set
	 */
	public ParameterInfo setProps(Map props) 
	{
		this.props = props;
		return this;
	}
	
	/**
	 *  Add a property.
	 */
	public ParameterInfo addProp(String name, String val)
	{
		if(props==null)
			props = new HashMap();
		props.put(name, val);
		return this;
	}
	
	/**
	 *  Create a parameter info for a rparameter.
	 *  @param p The parameter.
	 *  @return The parameter info.
	 */
	public static ParameterInfo createParameterInfo(IParameter p, ClassLoader cl)
	{
		MParameter mp = ((MParameter)p.getModelElement());
		ClassInfo ci = new ClassInfo(mp.getType(cl));
		ParameterInfo pi = new ParameterInfo()
				.setName(p.getName())
				.setType(ci.getClassNameOnly())
				.setValue(""+p.getValue());
		pi.addProp("evaluationmode", mp.getEvaluationMode().getString());
		if(mp.getDefaultValue()!=null)
			pi.addProp("defaultvalue", mp.getDefaultValue().getValue());
		if(mp.getDefaultValues()!=null)
		{
			StringBuilder sb = new StringBuilder();
			List lups = mp.getDefaultValues();
			if(lups.size()>0)
			{
				for(int i=0; i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy