1 17 18 package org.objectweb.jac.aspects.gui.web; 19 20 import java.io.PrintWriter; 21 import org.apache.log4j.Logger; 22 import org.objectweb.jac.aspects.gui.GuiAC; 23 import org.objectweb.jac.core.rtti.FieldItem; 24 import org.objectweb.jac.util.Enum; 25 import org.objectweb.jac.util.InvalidIndexException; 26 27 public class EnumViewer extends AbstractFieldView 28 implements HTMLViewer 29 { 30 static Logger loggerContext = Logger.getLogger("gui"); 31 32 Object value; 33 Enum enum; 34 35 public EnumViewer(Object value, 36 Object substance, FieldItem field) { 37 super(substance,field); 38 if (field!=null) 39 this.enum = (Enum)field.getAttribute(GuiAC.FIELD_ENUM); 40 else 41 logger.warn("EnumViewer: Cannot determine enum because field is null"); 42 setValue(value); 43 } 44 45 public EnumViewer() { 46 } 47 48 public void setField(FieldItem field) { 49 super.setField(field); 50 if (field!=null) 51 this.enum = (Enum)field.getAttribute(GuiAC.FIELD_ENUM); 52 else 53 logger.warn("EnumViewer: Cannot determine enum because field is null"); 54 } 55 56 public void setValue(Object value) { 57 this.value = value; 58 } 59 60 public void genHTML(PrintWriter out) { 61 if (value!=null) { 62 try { 63 out.print(enum.int2string(((Integer)value).intValue())); 64 } catch(InvalidIndexException e) { 65 out.print(((Integer)value).intValue()); 66 } 67 } 68 } 69 } 70 71 | Popular Tags |