Refine search
/** * Inquires if the name is a LambdaArgument * @param arg A possible Lambda formal parameter name * @return true if arg is a LambdaArgument, false otherwise. */ public boolean isLambdaArgument(String arg) { if (lambdaArgs == null) { return false; } for (int i = lambdaArgs.size() - 1; i >= 0; i--) { Map<String, Object> lmap = lambdaArgs.elementAt(i); if (lmap.containsKey(arg)) { return true; } } return false; }
/** Transfer an element from the real to the virtual stack. This assumes * that the virtual stack is currently empty. */ @SuppressWarnings("unchecked") protected void get_from_real() { Symbol stack_sym; /* don't transfer if the real stack is empty */ if (real_next >= real_stack.size()) return; /* get a copy of the first Symbol we have not transfered */ stack_sym = (Symbol)real_stack.elementAt(real_stack.size()-1-real_next); /* record the transfer */ real_next++; /* put the state number from the Symbol onto the virtual stack */ vstack.push(new Integer(stack_sym.parse_state)); }
/** * Utility function to see if the stack contains the given URL. * * @param stack non-null reference to a Stack. * @param url URL string on which an equality test will be performed. * * @return true if the stack contains the url argument. */ private boolean stackContains(Stack stack, String url) { int n = stack.size(); boolean contains = false; for (int i = 0; i < n; i++) { String url2 = (String) stack.elementAt(i); if (url2.equals(url)) { contains = true; break; } } return contains; }
/** * Utility function to see if the stack contains the given URL. * * @param stack non-null reference to a Stack. * @param url URL string on which an equality test will be performed. * * @return true if the stack contains the url argument. */ private boolean stackContains(Stack stack, String url) { int n = stack.size(); boolean contains = false; for (int i = 0; i < n; i++) { String url2 = (String) stack.elementAt(i); if (url2.equals(url)) { contains = true; break; } } return contains; }
/** Do debug output for stack state. [CSA] */ public void debug_stack() { StringBuffer sb=new StringBuffer("## STACK:"); for (int i=0; i<stack.size(); i++) { Symbol s = (Symbol) stack.elementAt(i); sb.append(" <state "+s.parse_state+", sym "+s.sym+">"); if ((i%3)==2 || (i==(stack.size()-1))) { debug_message(sb.toString()); sb = new StringBuffer(" "); } } }
/** * Retrieves the Lambda argument associated with a formal parameter. * If the Lambda expression is nested within other Lambda expressions, the * arguments for the current Lambda expression is first searched, and if * not found, the arguments for the immediate nesting Lambda expression * then searched, and so on. * * @param arg The formal parameter for the Lambda argument * @return The object associated with formal parameter. Null if * no object has been associated with the parameter. * @since EL 3.0 */ public Object getLambdaArgument(String arg) { if (lambdaArgs == null) { return null; } for (int i = lambdaArgs.size() - 1; i >= 0; i--) { Map<String, Object> lmap = lambdaArgs.elementAt(i); Object v = lmap.get(arg); if (v != null) { return v; } } return null; }
/** Dump the parse stack for debugging purposes. */ public void dump_stack() { if (stack == null) { debug_message("# Stack dump requested, but stack is null"); return; } debug_message("============ Parse Stack Dump ============"); /* dump the stack */ for (int i=0; i<stack.size(); i++) { debug_message("Symbol: " + ((Symbol)stack.elementAt(i)).sym + " State: " + ((Symbol)stack.elementAt(i)).parse_state); } debug_message("=========================================="); }
/** * @param level nesting level, i.e., 0 returns the direct predecessor * @return container of current entitity, i.e., predecessor during traversal */ public Object predecessor(int level) { int size = stack.size(); if((size < 2) || (level < 0)) return null; else return stack.elementAt(size - (level + 2)); // size - 1 == current }
/** * @param level nesting level, i.e., 0 returns the direct predecessor * @return container of current entitity, i.e., predecessor during traversal */ public Object predecessor(int level) { int size = stack.size(); if((size < 2) || (level < 0)) return null; else return stack.elementAt(size - (level + 2)); // size - 1 == current }
/** * Returns the most recently pushed context which implements the specified class. * Will return null if no matching context is found. */ public Object getClosestContext( Class matchingClass ) { for (int i = _traversalContext.size()-1; i >= 0; i-- ) { Object o = _traversalContext.elementAt( i ); if (matchingClass.isInstance(o)) return o; } return null; }