Package com.github.mustachejava.reflect

Examples of com.github.mustachejava.reflect.ReflectionObjectHandler


    assertEquals(getContents(root, "isempty.txt"), sw.toString());
  }

  public void testNumber0IsFalse() throws IOException {
    DefaultMustacheFactory c = createMustacheFactory();
    c.setObjectHandler(new ReflectionObjectHandler() {
      @Override
      public Writer falsey(Iteration iteration, Writer writer, Object object, Object[] scopes) {
        if (object instanceof Number) {
          if (((Number) object).intValue() == 0) {
            return iteration.next(writer, object, scopes);
View Full Code Here


  }

  @Test
  public void testObjectHandler() throws IOException {
    DefaultMustacheFactory mf = new DefaultMustacheFactory();
    mf.setObjectHandler(new ReflectionObjectHandler() {
      @Override
      public Object coerce(Object object) {
        if (object instanceof Collection) {
          return new DecoratedCollection((Collection) object);
        }
View Full Code Here

public class ExamplesTest {
  @Test
  public void testExpressionsInNames() throws IOException {
    DefaultMustacheFactory mf = new DefaultMustacheFactory();
    mf.setObjectHandler(new ReflectionObjectHandler() {
      @Override
      public Wrapper find(String name, Object[] scopes) {
        // Worst expression parser ever written follows
        String[] split = name.split("[*]");
        if (split.length > 1) {
View Full Code Here

  }

  @BeforeClass
  public static void setup() {
    roh = new ReflectionObjectHandler() {
      /**
       * Find a wrapper given the current context. If not found, return null.
       *
       * @param scopeIndex the index into the scope array
       * @param wrappers   the current set of wrappers to get here
View Full Code Here

            "    <li>3</li>\n" +
            "</ol>";
    Object scope = new Object() {
      int[] test = { 0, 1, 2, 3 };
    };
    ReflectionObjectHandler oh = new ReflectionObjectHandler() {
      @Override
      public Object coerce(final Object object) {
        if (object != null && object.getClass().isArray()) {
          return new ArrayMap(object);
        }
View Full Code Here

import static org.junit.Assert.fail;

public class FailOnMissingTest {
  @Test
  public void testFail() {
    ReflectionObjectHandler roh = new ReflectionObjectHandler() {
      @Override
      public Binding createBinding(String name, final TemplateContext tc, Code code) {
        return new GuardedBinding(this, name, tc, code) {
          @Override
          protected synchronized Wrapper getWrapper(String name, Object[] scopes) {
View Full Code Here

TOP

Related Classes of com.github.mustachejava.reflect.ReflectionObjectHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.