struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlenart <...@git.apache.org>
Subject [GitHub] struts pull request: Improve LocalizedTextUtil defend NPE
Date Wed, 11 Mar 2015 10:54:04 GMT
Github user lukaszlenart commented on the pull request:

    https://github.com/apache/struts/pull/35#issuecomment-78242017
  
    So you can use a `StubValueContext` like this one
    ```java
    public class StubValueStack implements ValueStack {
        Map<String, Object> ctx = new HashMap<String, Object>();
        CompoundRoot root = new CompoundRoot();
        
        public Map<String, Object> getContext() {
            return ctx;
        }
    
        public void setDefaultType(Class defaultType) {
        }
    
        public void setExprOverrides(Map<Object, Object> overrides) {
        }
    
        public Map<Object, Object> getExprOverrides() {
            return null;
        }
    
        public CompoundRoot getRoot() {
            return root;
        }
    
        public void setValue(String expr, Object value) {
            ctx.put(expr, value);
        }
    
        public void setParameter(String expr, Object value) {
            throw new UnsupportedOperationException("not implemented");
        }
    
        public void setValue(String expr, Object value, boolean throwExceptionOnFailure) {
            ctx.put(expr, value);
        }
    
        public String findString(String expr) {
            return (String) ctx.get(expr);
        }
    
        public String findString(String expr, boolean throwExceptionOnFailure) {
            return findString(expr, false);
        }
    
        public Object findValue(String expr) {
            return findValue(expr, false);
        }
    
        public Object findValue(String expr, boolean throwExceptionOnFailure) {
            return ctx.get(expr);
        }
    
        public Object findValue(String expr, Class asType) {
            return findValue(expr, asType, false);
        }
    
        public Object findValue(String expr, Class asType, boolean throwExceptionOnFailure)
{
            return ctx.get(expr);
        }
    
        public Object peek() {
            return root.peek();
        }
    
        public Object pop() {
            return root.pop();
        }
    
        public void push(Object o) {
            root.push(o);
        }
    
        public void set(String key, Object o) {
            ctx.put(key, o);
        }
    
        public int size() {
            return root.size();
        }
    }
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Mime
View raw message