protected Ref json(FunctionLibFunction flf, char start, char end) throws PageException { // print.out("start:"+start+":"+cfml.getCurrent()); if (!cfml.isCurrent(start)) return null; Ref[] args = functionArg(flf.getName(), false, flf, end); // if (!cfml.forwardIfCurrent(end)) // throw new ExpressionException("Invalid Syntax Closing ["+end+"] not found"); return new BIFCall(pc, flf, args); }
private boolean isDynamic(FunctionLibFunction flf) { return flf.getArgType() == FunctionLibFunction.ARG_DYNAMIC; }
/** * Liest die Argumente eines Funktonsaufruf ein und prft ob die Funktion innerhalb der FLD * (Function Library Descriptor) definiert ist. Falls sie existiert wird die Funktion gegen diese * geprft und ein build-in-function CFXD Element generiert, ansonsten ein normales funcion-call * Element. <br> * EBNF:<br> * <code>[impOp{"," impOp}];</code> * * @param name Identifier der Funktion als Zeichenkette * @param checkLibrary Soll geprft werden ob die Funktion innerhalb der Library existiert. * @param flf FLD Function definition . * @return CFXD Element * @throws PageException */ private Ref[] functionArg(String name, boolean checkLibrary, FunctionLibFunction flf, char end) throws PageException { // get Function Library checkLibrary = checkLibrary && flf != null; // Function Attributes ArrayList arr = new ArrayList(); ArrayList arrFuncLibAtt = null; int libLen = 0; if (checkLibrary) { arrFuncLibAtt = flf.getArg(); libLen = arrFuncLibAtt.size(); } int count = 0; do { cfml.next(); cfml.removeSpace(); // finish if (cfml.isCurrent(end)) break; // too many Attributes boolean isDynamic = false; int max = -1; if (checkLibrary) { isDynamic = isDynamic(flf); max = flf.getArgMax(); // Dynamic if (isDynamic) { if (max != -1 && max <= count) throw new ExpressionException("too many Attributes in function [" + name + "]"); } // Fix else { if (libLen <= count) throw new ExpressionException("too many Attributes in function [" + name + "]"); } } if (checkLibrary && !isDynamic) { // current attribues from library FunctionLibFunctionArg funcLibAtt = (FunctionLibFunctionArg) arrFuncLibAtt.get(count); short type = CFTypes.toShort(funcLibAtt.getType(), CFTypes.TYPE_UNKNOW); if (type == CFTypes.TYPE_VARIABLE_STRING) { arr.add(functionArgDeclarationVarString()); } else { arr.add(new Casting(pc, funcLibAtt.getTypeAsString(), type, functionArgDeclaration())); } } else { arr.add(functionArgDeclaration()); } // obj=andOrXor(); cfml.removeSpace(); count++; } while (cfml.isCurrent(',')); // end with ) ?? if (!cfml.forwardIfCurrent(end)) { if (name.startsWith("_json")) throw new ExpressionException("Invalid Syntax Closing [" + end + "] not found"); throw new ExpressionException( "Invalid Syntax Closing [" + end + "] for function [" + name + "] not found"); } // check min attributes if (checkLibrary && flf.getArgMin() > count) throw new ExpressionException("to less Attributes in function [" + name + "]"); cfml.removeSpace(); return (Ref[]) arr.toArray(new Ref[arr.size()]); }