1 53 54 package org.swixml.converters; 55 56 import org.jdom.Attribute; 57 58 import java.awt.*; 59 import java.lang.reflect.Field ; 60 61 77 78 public class ConstraintsConverter { 79 80 public static final Class TEMPLATE = Object .class; 81 82 88 public static Object convert(final Class type, final Attribute attr) { 89 Object constrain = null; 90 if (attr != null) { 91 if (BorderLayout.class.equals( type )) { 92 String value = attr.getValue(); 93 Field [] fields = BorderLayout.class.getFields(); 94 for (int i = 0; i < fields.length; i++) { 95 if (value.endsWith( fields[i].getName() )) { 96 try { 97 constrain = fields[i].get( BorderLayout.class ); 98 } catch (Exception e) { 99 } 100 break; 101 } 102 } 103 } else if (CardLayout.class.equals( type )) { 104 constrain = attr.getValue(); 108 } 109 } 110 return constrain; 111 } 112 113 114 119 public Class convertsTo() { 120 return TEMPLATE; 121 } 122 } 123 | Popular Tags |