1 9 package org.jboss.portal.portlet; 10 11 import javax.portlet.PortletMode; 12 13 import org.jboss.portal.common.value.Converter; 14 import org.jboss.portal.common.value.FormatConversionException; 15 import org.jboss.portal.common.value.NullConversionException; 16 17 21 public class PortletModeConverter implements Converter 22 { 23 24 public static final Converter INSTANCE = new PortletModeConverter(); 25 26 public boolean accept(Class clazz) 27 { 28 return PortletMode.class.equals(clazz); 29 } 30 31 public Object toObject(String value) throws NullConversionException, FormatConversionException 32 { 33 if (value == null) 34 { 35 throw new NullConversionException(); 36 } 37 return PortletUtils.decodePortletMode(value); 38 } 39 40 public String toString(Object value) throws NullConversionException, FormatConversionException 41 { 42 if (value == null) 43 { 44 throw new NullConversionException(); 45 } 46 if (value instanceof PortletMode) 47 { 48 return ((PortletMode)value).toString(); 49 } 50 else 51 { 52 throw new FormatConversionException(); 53 } 54 } 55 } 56 | Popular Tags |