Bug 100670 - [Geometry] java.beans.XMLEncoder ignores important Draw2D Geometries
Summary: [Geometry] java.beans.XMLEncoder ignores important Draw2D Geometries
Status: NEW
Alias: None
Product: GEF
Classification: Tools
Component: GEF-Legacy Draw2d (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: gef-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-17 17:02 EDT by Ian Levesque CLA
Modified: 2010-11-04 06:34 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ian Levesque CLA 2005-06-17 17:02:38 EDT
It is difficult to serialize hierarchies of Figures to XML because many
primitive classes do not conform to basic javabeans requirements (they lack
simple getter/setter pairs for fields).  This could be easily fixed with liberal
use of the "Generate Getter/Setters" command by someone with the ability to
commit to CVS.

To reproduce one example:

import org.eclipse.draw2d.geometry.Rectangle
import java.beans.XMLEncoder
import java.beans.XMLDecoder
import java.io.ByteArrayOutputStream
import java.io.ByteArrayInputStream

....

Rectangle inputRect = new Rectangle(50, 25, 100, 200);

ByteArrayOutputStream temporaryStream = new ByteArrayOutputStream();
XMLEncoder encoder = new XMLEncoder(temporaryStream);
encoder.writeObject(inputRect);
encoder.close();

byte[] buffer = temporaryStream.toByteArray();

XMLDecoder decoder = new XMLDecoder(new ByteArrayInputStream(buffer));
Rectangle outputRect = (Rectangle)decoder.readObject();
decoder.close();

if(!inputRect.equals(outputRect))
	System.out.println("Not equal! Before: " + inputRect + "  After: " + outputRect);