1 17 18 package org.objectweb.jac.aspects.persistence; 19 20 23 24 public class RectangleStringConverter implements StringConverter { 25 26 public String objectToString(Object obj) 27 { 28 java.awt.Rectangle rect = (java.awt.Rectangle )obj; 29 return rect.x+","+rect.y+","+rect.width+","+rect.height; 30 } 31 32 public Object stringToObject(String str) 33 { 34 int start = 0; 35 int end = str.indexOf(","); 36 java.awt.Rectangle rect = new java.awt.Rectangle (); 37 rect.x = Integer.parseInt(str.substring(start,end)); 38 start = end+1; 39 end = str.indexOf(",",start); 40 rect.y = Integer.parseInt(str.substring(start,end)); 41 start = end+1; 42 end = str.indexOf(",",start); 43 rect.width = Integer.parseInt(str.substring(start,end)); 44 start = end+1; 45 rect.height = Integer.parseInt(str.substring(start)); 46 return rect; 47 } 48 } 49 | Popular Tags |