1 8 package org.lsmp.djep.groupJep; 9 10 import org.nfunk.jep.*; 11 import org.nfunk.jep.type.Complex; 12 import org.lsmp.djep.groupJep.values.*; 13 20 public class GroupJep extends JEP { 21 protected GroupI group; 22 27 public GroupJep(GroupI group) { 28 super(); 29 this.group = group; 30 super.numberFactory = group.getNumberFactory(); 31 opSet = new GOperatorSet(group); 32 } 33 private GroupJep() {} 34 public void addStandardFunctions() 35 { 36 group.addStandardFunctions(this); 39 } 40 41 public void addStandardConstants() 42 { 43 group.addStandardConstants(this); 44 } 45 46 public GroupJep(JEP j) { 47 super(j); 48 } 49 50 public GroupI getGroup() 51 { 52 return group; 53 } 54 55 59 public Complex getComplexValue() { 60 Object num = this.getValueAsObject(); 61 if(num instanceof Complex) return (Complex) num; 62 else if(num instanceof HasComplexValueI) 63 return ((HasComplexValueI) num).getComplexValue(); 64 else if(num instanceof Number ) 65 return new Complex((Number ) num); 66 return super.getComplexValue(); 67 } 68 69 75 public static Complex getComplexValue(Object num) 76 { 77 if(num instanceof Complex) return (Complex) num; 78 else if(num instanceof HasComplexValueI) 79 return ((HasComplexValueI) num).getComplexValue(); 80 else if(num instanceof Number ) 81 return new Complex((Number ) num); 82 else return null; 83 } 84 85 } 86 | Popular Tags |