/** * Set the structure of the parameters that are expected as input by * this function. This must be called before getOutputDef() is called. * * @param paramDefs the structure of the input parameters * @throws Exception if the number or types of parameters are not acceptable by * this function */ public void setParameterDefs(ArrayList<Attribute> paramDefs) throws Exception { m_parameterDefs = paramDefs; if (!m_func.legalNumParams(m_parameterDefs.size())) { throw new Exception("[BuiltInMath] illegal number of parameters for function: " + m_functionName); } }
public String toString() { String result = m_func.toString() + "("; for (int i = 0; i < m_parameterDefs.size(); i++) { result += m_parameterDefs.get(i).name(); if (i != m_parameterDefs.size() - 1) { result += ", "; } else { result += ")"; } } return result; }
} else if (name.equals(BuiltInMath.MathFunc.ROUND.toString())) { result = new BuiltInMath(BuiltInMath.MathFunc.ROUND); } else if (name.equals(BuiltInString.StringFunc.UPPERCASE.toString())) { result = new BuiltInString(BuiltInString.StringFunc.UPPERCASE); } else if (name.equals(BuiltInString.StringFunc.SUBSTRING.toString())) { result = new BuiltInString(BuiltInString.StringFunc.SUBSTRING); } else if (name.equals(BuiltInString.StringFunc.TRIMBLANKS.toString())) { result = new BuiltInString(BuiltInString.StringFunc.TRIMBLANKS);
} else if (name.equals(BuiltInMath.MathFunc.ROUND.toString())) { result = new BuiltInMath(BuiltInMath.MathFunc.ROUND); } else if (name.equals(BuiltInString.StringFunc.UPPERCASE.toString())) { result = new BuiltInString(BuiltInString.StringFunc.UPPERCASE); } else if (name.equals(BuiltInString.StringFunc.SUBSTRING.toString())) { result = new BuiltInString(BuiltInString.StringFunc.SUBSTRING); } else if (name.equals(BuiltInString.StringFunc.TRIMBLANKS.toString())) { result = new BuiltInString(BuiltInString.StringFunc.TRIMBLANKS);
if (!m_func.legalNumParams(incoming.length)) { throw new Exception("[BuiltInString] wrong number of parameters!"); String result = m_func.eval(args); int resultI = m_outputDef.indexOfValue(result); if (resultI < 0) {
if (!m_func.legalNumParams(incoming.length)) { throw new Exception("[BuiltInString] wrong number of parameters!"); String result = m_func.eval(args); int resultI = m_outputDef.indexOfValue(result); if (resultI < 0) {
/** * Get the structure of the result produced by this function. * Subclasses must implement. * * @return the structure of the result produced by this function. */ public Attribute getOutputDef() { if (m_outputDef == null) { if (m_func == StringFunc.SUBSTRING) { // there is no way we can compute the legal values for this attribute // in advance of the application of this function. So return a string attribute m_outputDef = new Attribute("BuiltInStringResult:substring", (ArrayList<String>)null); } // for the other functions we can compute the resulting set of values Attribute inputVals = m_parameterDefs.get(0); ArrayList<String> newVals = new ArrayList<String>(); for (int i = 0; i < inputVals.numValues(); i++) { String inVal = inputVals.value(i); newVals.add(m_func.eval(new Object[] {inVal})); } m_outputDef = new Attribute("BuiltInStringResult:" + m_func.toString(), newVals); } return m_outputDef; }
/** * Get the structure of the result produced by this function. * Subclasses must implement. * * @return the structure of the result produced by this function. */ public Attribute getOutputDef() { if (m_outputDef == null) { if (m_func == StringFunc.SUBSTRING) { // there is no way we can compute the legal values for this attribute // in advance of the application of this function. So return a string attribute m_outputDef = new Attribute("BuiltInStringResult:substring", (ArrayList<String>)null); } // for the other functions we can compute the resulting set of values Attribute inputVals = m_parameterDefs.get(0); ArrayList<String> newVals = new ArrayList<String>(); for (int i = 0; i < inputVals.numValues(); i++) { String inVal = inputVals.value(i); newVals.add(m_func.eval(new Object[] {inVal})); } m_outputDef = new Attribute("BuiltInStringResult:" + m_func.toString(), newVals); } return m_outputDef; }
BuiltInString(StringFunc func) { m_func = func; m_functionName = m_func.toString(); }
/** * Set the structure of the parameters that are expected as input by * this function. This must be called before getOutputDef() is called. * * @param paramDefs the structure of the input parameters * @throws Exception if the number or types of parameters are not acceptable by * this function */ public void setParameterDefs(ArrayList<Attribute> paramDefs) throws Exception { m_parameterDefs = paramDefs; if (!m_func.legalNumParams(m_parameterDefs.size())) { throw new Exception("[BuiltInMath] illegal number of parameters for function: " + m_functionName); } }
/** * Returns an array of the names of the parameters expected * as input by this function. May return null if the function * can accept an unbounded number of arguments. * * @return an array of the parameter names (or null if the function * can accept any number of arguments). */ public String[] getParameterNames() { return m_func.getParameterNames(); }
/** * Returns an array of the names of the parameters expected * as input by this function. May return null if the function * can accept an unbounded number of arguments. * * @return an array of the parameter names (or null if the function * can accept any number of arguments). */ public String[] getParameterNames() { return m_func.getParameterNames(); }
BuiltInString(StringFunc func) { m_func = func; m_functionName = m_func.toString(); }
public String toString() { String result = m_func.toString() + "("; for (int i = 0; i < m_parameterDefs.size(); i++) { result += m_parameterDefs.get(i).name(); if (i != m_parameterDefs.size() - 1) { result += ", "; } else { result += ")"; } } return result; }