use of org.apache.cayenne.configuration.ConfigurationNodeVisitor 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();
}
}
use of org.apache.cayenne.configuration.ConfigurationNodeVisitor in project cayenne by apache.
the class ProjectTest method testRootNode.
@Test
public void testRootNode() {
ConfigurationNode object = new ConfigurationNode() {
public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor) {
return null;
}
};
Project project = new Project(new ConfigurationTree<ConfigurationNode>(object));
assertSame(object, project.getRootNode());
assertFalse(project.isModified());
project.setModified(true);
assertTrue(project.isModified());
}
Aggregations