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

org.lsmp.djep.sjep.PVariable Maven / Gradle / Ivy

Go to download

JEP is a Java library for parsing and evaluating mathematical expressions.

The newest version!
/* @author rich
 * Created on 14-Dec-2004
 */
package org.lsmp.djep.sjep;
import org.lsmp.djep.xjep.*;
import org.nfunk.jep.*;
/**
 * Represents a variable.
 * 
 * @author Rich Morris
 * Created on 14-Dec-2004
 */
public class PVariable extends AbstractPNode {

	XVariable variable;
	/**
	 * 
	 */
	public PVariable(PolynomialCreator pc,XVariable var) {
		super(pc);
		this.variable = var;
	}

	public boolean equals(PNodeI node)
	{
		if(node instanceof PVariable)
			if(variable.equals(((PVariable)node).variable))
				return true;	

		return false;
	}

	/**
	this < arg ---> -1
	this > arg ---> 1
	*/
	public int compareTo(PVariable vf)
	{
			return variable.getName().compareTo(vf.variable.getName());
	}
	
	public String toString()
	{
		return variable.getName();
	}
	
	public Node toNode() throws ParseException
	{
		return pc.nf.buildVariableNode(variable);
	}
	
	public PNodeI expand()	{ return this;	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy