use of org.apache.cayenne.util.XMLSerializable in project cayenne by apache.
the class CayenneTransferable method getTransferData.
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
if (flavor == CAYENNE_FLAVOR) {
return data;
} else {
StringWriter out = new StringWriter();
XMLEncoder encoder = new XMLEncoder(new PrintWriter(out), "\t");
ConfigurationNodeVisitor visitor = new EmptyConfigurationNodeVisitor();
encoder.println("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
if (data instanceof XMLSerializable) {
((XMLSerializable) data).encodeAsXML(encoder, visitor);
} else if (data instanceof List) {
for (Object o : (List) data) {
((XMLSerializable) o).encodeAsXML(encoder, visitor);
}
}
return out.toString();
}
}
Aggregations