Merge pull request #170 from johngrimes/xhtmlnode-location-serializable

Make XhtmlNode$Location serializable
This commit is contained in:
Grahame Grieve 2020-04-13 08:25:55 +10:00 committed by GitHub
commit d935dac0d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -50,6 +50,7 @@ package org.hl7.fhir.utilities.xhtml;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -67,7 +68,8 @@ public class XhtmlNode implements IBaseXhtml {
private static final long serialVersionUID = -4362547161441436492L;
public static class Location {
public static class Location implements Serializable {
private static final long serialVersionUID = -4079302502900219721L;
private int line;
private int column;
public Location(int line, int column) {

View File

@ -1,5 +1,8 @@
package org.hl7.fhir.utilities.tests;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
import org.junit.Test;
import org.slf4j.Logger;
@ -71,4 +74,13 @@ public class XhtmlNodeTest {
assertEquals("<div xmlns=\"http://www.w3.org/1999/xhtml\"><img src=\"http://pbs.twimg.com/profile_images/544507893991485440/r_vo3uj2_bigger.png\" alt=\"Twitter Avatar\"/>@fhirabend</div>", output);
}
@Test
public void testSerializable() throws IOException {
XhtmlNode node = new XhtmlNode();
node.setValueAsString("<?xml version=\"1.0\" encoding=\"UTF-8\"?><div xmlns=\"http://www.w3.org/1999/xhtml\">Test</div>");
ByteArrayOutputStream bout = new ByteArrayOutputStream();
ObjectOutputStream oout = new ObjectOutputStream(bout);
oout.writeObject(node);
}
}