public void push(Object o) { add(0, o); } }
public CompoundRoot cutStack(int index) { return new CompoundRoot(subList(index, size())); }
public Object peek() { return get(0); }
@Override public String getMessage(Object object) { boolean pop = false; if (useSensitiveContext && !stack.getRoot().contains(c)) { stack.push(c); pop = true; } String message = super.getMessage(object); if (pop) { stack.pop(); } return message; }
/** * @see com.opensymphony.xwork2.util.ValueStack#size() */ public int size() { return root.size(); }
public Class classForName(String className, Map context) throws ClassNotFoundException { Object root = Ognl.getRoot(context); try { if (root instanceof CompoundRoot) { if (className.startsWith("vs")) { CompoundRoot compoundRoot = (CompoundRoot) root; if ("vs".equals(className)) { return compoundRoot.peek().getClass(); } int index = Integer.parseInt(className.substring(2)); return compoundRoot.get(index - 1).getClass(); } } } catch (Exception e) { if (LOG.isDebugEnabled()) { LOG.debug("Got exception when tried to get class for name [#0]", e, className); } } return Thread.currentThread().getContextClassLoader().loadClass(className); }
protected OgnlValueStack(XWorkConverter xworkConverter, CompoundRootAccessor accessor, TextProvider prov, boolean allowStaticAccess) { setRoot(xworkConverter, accessor, new CompoundRoot(), allowStaticAccess); push(prov); }
/** * @see LocaleResolver#resolveLocale(PageContext) */ @Override public Locale resolveLocale(PageContext pageContext) { Locale result = null; ValueStack stack = ActionContext.getContext().getValueStack(); Iterator<Object> iterator = stack.getRoot().iterator(); while (iterator.hasNext()) { Object o = iterator.next(); if (o instanceof LocaleProvider) { LocaleProvider lp = (LocaleProvider) o; result = lp.getLocale(); break; } } if (result == null) { log.debug("Missing LocalProvider actions, init locale to default"); result = Locale.getDefault(); } return result; }
/** * @see com.opensymphony.xwork2.util.ValueStack#pop() */ public Object pop() { return root.pop(); }
/** * @see com.opensymphony.xwork2.util.ValueStack#peek() */ public Object peek() { return root.peek(); }
@Override public String getMessage(Object object) { boolean pop = false; if (useSensitiveContext && !stack.getRoot().contains(c)) { stack.push(c); pop = true; } String message = super.getMessage(object); if (pop) { stack.pop(); } return message; }
private boolean shouldCopyStack(ActionInvocation invocation, CompoundRoot root) throws Exception { Result result = invocation.getResult(); return root.size() > 1 && (result == null || ActionChainResult.class.isAssignableFrom(result.getClass())); }
protected OgnlValueStack(ValueStack vs, XWorkConverter xworkConverter, CompoundRootAccessor accessor, boolean allowStaticAccess) { setRoot(xworkConverter, accessor, new CompoundRoot(vs.getRoot()), allowStaticAccess); }
/** * @see I18nResourceProvider#getResource(String, String, Tag, javax.servlet.jsp.PageContext) */ @Override public String getResource(String resourceKey, String defaultValue, Tag tag, PageContext pageContext) { // if resourceKey isn't defined either, use defaultValue String key = (resourceKey != null) ? resourceKey : defaultValue; String message = null; ValueStack stack = TagUtils.getStack(pageContext); Iterator<Object> iterator = stack.getRoot().iterator(); while (iterator.hasNext()) { Object o = iterator.next(); if (o instanceof TextProvider) { TextProvider tp = (TextProvider) o; message = tp.getText(key, null, (String) null); break; } } // if user explicitly added a titleKey we guess this is an error if (message == null && resourceKey != null) { log.debug(Messages.getString("Localization.missingkey", resourceKey)); //$NON-NLS-1$ message = UNDEFINED_KEY + resourceKey + UNDEFINED_KEY; } return message; }
/** * Return the field value named <code>name</code> from <code>object</code>, * <code>object</code> should have the appropriate getter/setter. * * @param name name of the field * @param object to search field name on * @return Object as field value * @throws ValidationException */ protected Object getFieldValue(String name, Object object) throws ValidationException { boolean pop = false; if (!stack.getRoot().contains(object)) { stack.push(object); pop = true; } Object retVal = stack.findValue(name); if (pop) { stack.pop(); } return retVal; }
@Override public String intercept(ActionInvocation invocation) throws Exception { ValueStack stack = invocation.getStack(); CompoundRoot root = stack.getRoot(); if (root.size() >= this.compoundRootMinSize && isChainResult(invocation)) { List<CompoundRoot> list = new ArrayList<CompoundRoot>(root); list.remove(0); Collections.reverse(list); Map<String, Object> ctxMap = invocation.getInvocationContext().getContextMap(); Iterator<CompoundRoot> iterator = list.iterator(); int index = 1; // starts with 1, 0 has been removed while (iterator.hasNext()) { index = index + 1; Object o = iterator.next(); if (o != null) { if (!(o instanceof Unchainable)) { reflectionProvider.copy(o, invocation.getAction(), ctxMap, excludes, includes); } } else { LOG.warn("compound root element at index " + index + " is null"); } } } return invocation.invoke(); }
/** * Iterates over GXP parameters, pulls value from value stack for each * parameter, and appends the values to an argument list which will * be passed to a method on a GXP. * * @param overrides parameter map pushed onto the value stack * * @return list of arguments */ List getArgListFromValueStack(Map overrides) { ValueStack valueStack = valueStackFactory.createValueStack(ActionContext.getContext().getValueStack()); // add default values to the bottom of the stack. if no action provides // a getter for a param, the default value will be used. valueStack.getRoot().add(this.defaultValues); // push override parameters onto the stack. if (overrides != null && !overrides.isEmpty()) { valueStack.push(overrides); } List args = new ArrayList(params.size()); for (Param param : getParams()) { try { args.add(valueStack.findValue(param.getName(), param.getType())); } catch (Exception e) { throw new RuntimeException("Exception while finding '" + param.getName() + "'.", e); } } return args; }
v = objects[0]; } else { v = root.get(0);
boolean pop = false; if (!stack.getRoot().contains(object)) { stack.push(object); pop = true;