Returns a Formula for the given String. @param formulaString The String to be converted to a Formula @return A Formula for the given String. @throws IllegalArgumentException if the given String is null or empty
(String formulaString)
| 70 | * if the given String is null or empty |
| 71 | */ |
| 72 | public static Formula getFormulaFor(String formulaString) |
| 73 | { |
| 74 | if (formulaString == null || formulaString.isEmpty()) |
| 75 | { |
| 76 | throw new IllegalArgumentException("Formula cannot be empty"); |
| 77 | } |
| 78 | try |
| 79 | { |
| 80 | return getFormulaFor(Integer.valueOf(formulaString)); |
| 81 | } |
| 82 | catch (NumberFormatException e) |
| 83 | { |
| 84 | // Okay, just not an integer |
| 85 | try |
| 86 | { |
| 87 | return getFormulaFor(Double.valueOf(formulaString)); |
| 88 | } |
| 89 | catch (NumberFormatException e2) |
| 90 | { |
| 91 | // Okay, just not a double |
| 92 | return new JEPFormula(formulaString); |
| 93 | } |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * Returns a Formula for the given Number. |