[stringtemplate-interest] Primitives and Model Adapters

Terence Parr parrt at cs.usfca.edu
Fri Jan 28 12:28:38 PST 2011


hmm...easier/simpler to do this:

    public void registerRenderer(Class attributeType, AttributeRenderer r) {
		if ( attributeType.isPrimitive() ) {
			throw new IllegalArgumentException("can't register renderer for primitive type "+
											   attributeType.getSimpleName());
		}
	...

ter

On Jan 28, 2011, at 11:15 AM, Collin Fagan wrote:

> Not that I know of, I looked for a while and then wrote my own. It's a simple HashMap lookup, nothing fancy. Let me know and I can send it to you when I get home. 
> 
> 
> On Fri, Jan 28, 2011 at 12:10 PM, Terence Parr <parrt at cs.usfca.edu> wrote:
> 
> On Jan 28, 2011, at 5:59 AM, Collin Fagan wrote:
> 
> > I understand, no problem at all. In this case though can we do one of two things?
> >
> > 1. Throw an IllegalArgumentException when one tries to register a model adapter on a primitive.
> > 2. Translate any primitive into it's boxed type during registration. ST already seems to treat return values of primitive types like boxed types when the template is run.
> 
> is there a java method to convert int.class to Integer.class already?
> Ter
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
> 



More information about the stringtemplate-interest mailing list