Some toString impls to make debugging easier.

This commit is contained in:
Michael Bayne
2016-06-15 11:49:37 -07:00
parent 115f496947
commit 1170d4500e
2 changed files with 17 additions and 1 deletions
@@ -73,6 +73,9 @@ public abstract class BasicCollector implements Mustache.Collector
Map<?,?> map = (Map<?,?>)ctx; Map<?,?> map = (Map<?,?>)ctx;
return map.containsKey(name) ? map.get(name) : Template.NO_FETCHER_FOUND; return map.containsKey(name) ? map.get(name) : Template.NO_FETCHER_FOUND;
} }
@Override public String toString () {
return "MAP_FETCHER";
}
}; };
protected static final Mustache.VariableFetcher LIST_FETCHER = new Mustache.VariableFetcher() { protected static final Mustache.VariableFetcher LIST_FETCHER = new Mustache.VariableFetcher() {
@@ -85,6 +88,9 @@ public abstract class BasicCollector implements Mustache.Collector
return Template.NO_FETCHER_FOUND; return Template.NO_FETCHER_FOUND;
} }
} }
@Override public String toString () {
return "LIST_FETCHER";
}
}; };
protected static final Mustache.VariableFetcher ITER_FETCHER = new Mustache.VariableFetcher() { protected static final Mustache.VariableFetcher ITER_FETCHER = new Mustache.VariableFetcher() {
@@ -99,12 +105,18 @@ public abstract class BasicCollector implements Mustache.Collector
return Template.NO_FETCHER_FOUND; return Template.NO_FETCHER_FOUND;
} }
} }
@Override public String toString () {
return "ITER_FETCHER";
}
}; };
protected static final Mustache.VariableFetcher THIS_FETCHER = new Mustache.VariableFetcher() { protected static final Mustache.VariableFetcher THIS_FETCHER = new Mustache.VariableFetcher() {
public Object get (Object ctx, String name) throws Exception { public Object get (Object ctx, String name) throws Exception {
return ctx; return ctx;
} }
@Override public String toString () {
return "THIS_FETCHER";
}
}; };
protected static abstract class ArrayHelper implements Mustache.VariableFetcher { protected static abstract class ArrayHelper implements Mustache.VariableFetcher {
@@ -107,7 +107,7 @@ public class Template
/** A sentinel object that can be returned by a {@link Mustache.Collector} to indicate that a /** A sentinel object that can be returned by a {@link Mustache.Collector} to indicate that a
* variable does not exist in a particular context. */ * variable does not exist in a particular context. */
public static final Object NO_FETCHER_FOUND = new Object(); public static final Object NO_FETCHER_FOUND = new String("<no fetcher found>");
/** /**
* Executes this template with the given context, returning the results as a string. * Executes this template with the given context, returning the results as a string.
@@ -377,6 +377,10 @@ public class Template
Key okey = (Key)other; Key okey = (Key)other;
return okey.cclass == cclass && okey.name == name; return okey.cclass == cclass && okey.name == name;
} }
@Override public String toString () {
return cclass.getName() + ":" + name;
}
} }
protected static final String DOT_NAME = ".".intern(); protected static final String DOT_NAME = ".".intern();