Karthik
The problem with your code is that its missing a VariableFactory, a
class used to actually make the variables.
VariableTable vtsrc = jep.getVariableTable();
VariableTable vt = new VariableTable();
// this is the line your missing
vt.setVariableFactory(new VariableFactory());
vt.copyVariablesFrom(vtsrc); //throws null pointer exception
Its probably not the easiest way to get a list of variables, its
easiest just to get the list of variables and iterate through the list
removing the constants
jep.addVariable("x", 5.0);
jep.addVariable("y", 5.0);
jep.addVariable("z", 5.0);
Collection<Variable> vars = vtsrc.getVariables();
System.out.println("before");
System.out.println(vars);
Iterator<Variable> itt = vars.iterator();
while(itt.hasNext()) {
Variable v=itt.next();
if(v.isConstant()) {
itt.remove();
}
}
System.out.println("after");
System.out.println(vars);
Richard
On Tue, Oct 2, 2012 at 9:03 AM, <
krno...@gmail.com> wrote:
> Hi,
>
> I am trying to find a way to get only the list of variables without the
> constants. I found VariableTable.copyVariablesFrom and copyConstantsFrom but
> when i used it I get a null pointer exception.
>
> VariableTable vtsrc = jep.getVariableTable();
> VariableTable vt = new VariableTable();
> vt.copyVariablesFrom(vtsrc); //throws null pointer exception
>
> Is there something wrong in the way I am using this?
>
> thanks
> Karthik
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Jep Java Users" group.
> To view this discussion on the web visit
>
https://groups.google.com/d/msg/jep-users/-/OOkN37qMX0MJ.
> To post to this group, send email to
jep-...@googlegroups.com.
> To unsubscribe from this group, send email to
>
jep-users+...@googlegroups.com.
> For more options, visit this group at
>
http://groups.google.com/group/jep-users?hl=en.