1 33 package net.sf.jga.parser; 34 35 import java.text.MessageFormat ; 36 import net.sf.jga.fn.adaptor.Constant; 37 38 47 48 class EnumHandler { 49 static final boolean handlesEnums = true; 50 51 static FunctorRef checkEnum(Class type, String name) throws ParseException { 52 if (type.isEnum()) { 53 try { 54 return new GeneratorRef(new Constant(Enum.valueOf(type, name)), type); 55 } 56 catch (IllegalArgumentException x) { 57 String msg = "enum {0} has no {1} value"; 58 Object [] args = new Object [] { type.getName(), name }; 59 ParseException px = new ParseException(MessageFormat.format(msg, args)); 60 px.initCause(x); 61 throw px; 62 } 63 } 64 65 return null; 66 } 67 } 68 | Popular Tags |