public static Object unwrap(ObjectHandler oh, int scopeIndex, Wrapper[] wrappers, List<Object> scopes) throws GuardException { Object scope = oh.coerce(scopes.get(scopeIndex)); // The value may be buried by . notation if (wrappers != null) { for (Wrapper wrapper : wrappers) { scope = oh.coerce(wrapper.call(ObjectHandler.makeList(scope))); } } return scope; }
private Object createAndGet(List<Object> scopes) { // Make a new wrapper for this set of scopes and add it to the set Wrapper wrapper = getWrapper(name, scopes); previousSet.add(wrapper); if (prevWrappers == null || prevWrappers.length != previousSet.size()) { prevWrappers = previousSet.toArray(EMPTY_WRAPPERS); } // If this fails the guard, there is a bug try { return oh.coerce(wrapper.call(scopes)); } catch (GuardException e) { throw new GuardException("BUG: Unexpected guard failure: " + name + " " + previousSet + " " + singletonList(scopes)); } }
try { current = prevWrapper; return oh.coerce(prevWrapper.call(scopes)); } catch (GuardException ge) {
@Override public Object call(List<Object> scopes) throws GuardException { guardCall(scopes); Object scope = oh.coerce(unwrap(scopes)); try { if (scope == null) return null; if (method == null) { return field.get(scope); } else { return method.invoke(scope, arguments); } } catch (IllegalArgumentException | IllegalAccessException e) { throw new MustacheException("Error accessing " + getTargetDescription() + " on " + elementToString(scope) + ", scope: [" + elementsToString(scopes, scopeIndex) + "]" + ", guards: " + Arrays.toString(guards), e); } catch (InvocationTargetException e) { throw new MustacheException("Error invoking " + getTargetDescription() + " on " + elementToString(scope), e.getTargetException()); } catch (Exception e) { throw new MustacheException("Error invoking " + getTargetDescription() + " on " + elementToString(scope), e); } }
public static Object unwrap(ObjectHandler oh, int scopeIndex, Wrapper[] wrappers, List<Object> scopes) throws GuardException { Object scope = oh.coerce(scopes.get(scopeIndex)); // The value may be buried by . notation if (wrappers != null) { for (Wrapper wrapper : wrappers) { scope = oh.coerce(wrapper.call(ObjectHandler.makeList(scope))); } } return scope; }
public static Object unwrap(ObjectHandler oh, int scopeIndex, Wrapper[] wrappers, List<Object> scopes) throws GuardException { Object scope = oh.coerce(scopes.get(scopeIndex)); // The value may be buried by . notation if (wrappers != null) { for (Wrapper wrapper : wrappers) { scope = oh.coerce(wrapper.call(ObjectHandler.makeList(scope))); } } return scope; }
private Object createAndGet(List<Object> scopes) { // Make a new wrapper for this set of scopes and add it to the set Wrapper wrapper = getWrapper(name, scopes); previousSet.add(wrapper); if (prevWrappers == null || prevWrappers.length != previousSet.size()) { prevWrappers = previousSet.toArray(EMPTY_WRAPPERS); } // If this fails the guard, there is a bug try { return oh.coerce(wrapper.call(scopes)); } catch (GuardException e) { throw new GuardException("BUG: Unexpected guard failure: " + name + " " + previousSet + " " + singletonList(scopes)); } }
private Object createAndGet(List<Object> scopes) { // Make a new wrapper for this set of scopes and add it to the set Wrapper wrapper = getWrapper(name, scopes); previousSet.add(wrapper); if (prevWrappers == null || prevWrappers.length != previousSet.size()) { prevWrappers = previousSet.toArray(new Wrapper[previousSet.size()]); } // If this fails the guard, there is a bug try { return oh.coerce(wrapper.call(scopes)); } catch (GuardException e) { throw new GuardException("BUG: Unexpected guard failure: " + name + " " + previousSet + " " + singletonList(scopes)); } }
try { current = prevWrapper; return oh.coerce(prevWrapper.call(scopes)); } catch (GuardException ge) {
try { current = prevWrapper; return oh.coerce(prevWrapper.call(scopes)); } catch (GuardException ge) {
@Override public Object call(List<Object> scopes) throws GuardException { guardCall(scopes); Object scope = oh.coerce(unwrap(scopes)); try { if (scope == null) return null; if (method == null) { return field.get(scope); } else { return method.invoke(scope, arguments); } } catch (IllegalArgumentException | IllegalAccessException e) { throw new MustacheException("Error accessing " + getTargetDescription() + " on " + elementToString(scope) + ", scope: [" + elementsToString(scopes, scopeIndex) + "]" + ", guards: " + Arrays.toString(guards), e); } catch (InvocationTargetException e) { throw new MustacheException("Error invoking " + getTargetDescription() + " on " + elementToString(scope), e.getTargetException()); } catch (Exception e) { throw new MustacheException("Error invoking " + getTargetDescription() + " on " + elementToString(scope), e); } }
@Override public Object call(List<Object> scopes) throws GuardException { guardCall(scopes); Object scope = oh.coerce(unwrap(scopes)); try { if (scope == null) return null; if (method == null) { return field.get(scope); } else { return method.invoke(scope, arguments); } } catch (IllegalArgumentException | IllegalAccessException e) { throw new MustacheException("Error accessing " + getTargetDescription() + " on " + elementToString(scope) + ", scope: [" + elementsToString(scopes, scopeIndex) + "]" + ", guards: " + Arrays.toString(guards), e); } catch (InvocationTargetException e) { throw new MustacheException("Error invoking " + getTargetDescription() + " on " + elementToString(scope), e.getTargetException()); } catch (Exception e) { throw new MustacheException("Error invoking " + getTargetDescription() + " on " + elementToString(scope), e); } }