com.codetaco.math.function.FuncStringTrim Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of math Show documentation
Show all versions of math Show documentation
Equation processing for Java
package com.codetaco.math.function;
import com.codetaco.math.Function;
import com.codetaco.math.ValueStack;
import com.codetaco.math.token.TokVariable;
import java.text.ParseException;
/**
*
* FuncStringTrim class.
*
*
* @author Chris DeGreef [email protected]
* @since 1.3.9
*/
public class FuncStringTrim extends Function {
/**
*
* Constructor for FuncStringTrim.
*
*/
public FuncStringTrim() {
super();
}
/**
*
* Constructor for FuncStringTrim.
*
*
* @param var a {@link com.codetaco.math.token.TokVariable} object.
*/
public FuncStringTrim(final TokVariable var) {
super(var);
}
/**
* {@inheritDoc}
*/
@Override
public void resolve(final ValueStack values) throws Exception {
if (values.size() < getParameterCount()) {
throw new Exception("missing operands for " + toString());
}
try {
final String target = values.popString();
values.push(target.trim());
} catch (final ParseException e) {
e.fillInStackTrace();
throw new Exception(toString() + "; " + e.getMessage(), e);
}
}
/**
* {@inheritDoc}
*/
@Override
public String toString() {
return "function(trim)";
}
}