/** * @see com.opensymphony.xwork2.util.ValueStack#size() */ public int size() { return root.size(); }
private boolean shouldCopyStack(ActionInvocation invocation, CompoundRoot root) throws Exception { Result result = invocation.getResult(); return root.size() > 1 && (result == null || ActionChainResult.class.isAssignableFrom(result.getClass())); }
public CompoundRoot cutStack(int index) { return new CompoundRoot(subList(index, size())); }
@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(); }
} else if (name instanceof String) { if ("top".equals(name)) { if (root.size() > 0) { return root.get(0); } else {