1 53 54 package org.swixml.converters; 55 56 import org.jdom.Attribute; 57 import org.swixml.Converter; 58 import org.swixml.Localizer; 59 60 import java.awt.*; 61 import java.util.StringTokenizer ; 62 63 70 public class PointConverter implements Converter { 71 72 public static final Class TEMPLATE = Point.class; 73 74 80 public Object convert( final Class type, final Attribute attr, Localizer localizer ) { 81 if (attr != null) { 82 StringTokenizer st = new StringTokenizer ( attr.getValue(), "," ); 83 int x = 0; 84 int y = 0; 85 if (st.hasMoreTokens()) { 86 x = Integer.parseInt( st.nextToken().trim() ); 87 } 88 if (st.hasMoreTokens()) { 89 y = Integer.parseInt( st.nextToken().trim() ); 90 } 91 return new Point( x, y ); 92 } 93 return null; 94 } 95 96 97 102 public Class convertsTo() { 103 return TEMPLATE; 104 } 105 } | Popular Tags |