source: ccr/trunk/nhin-vista/projects/NHINC/Current/Product/Production/Adapters/General/AdapterReidentificationLib/src/gov/hhs/fha/nhinc/adapter/reidentification/data/PseudonymMapsXML.java@ 507

Last change on this file since 507 was 507, checked in by George Lilly, 15 years ago

NHIN gateway and adaptor for use on linux with VistA EHR and RPMS

File size: 1.5 KB
Line 
1package gov.hhs.fha.nhinc.adapter.reidentification.data;
2
3import com.thoughtworks.xstream.XStream;
4
5/**
6 * This class is used to serialize the POJO reidentification classes into an
7 * XML string and also to de-serialize an XML string into a set of POJO
8 * reidentification classes.
9 */
10public class PseudonymMapsXML {
11
12 /**
13 * XStream initialized for PseudonymMaps
14 */
15 private static XStream xStream;
16
17 /**
18 * Lazy initializer for the definition of the xstream
19 */
20 private static XStream getXStream() {
21 if (xStream == null) {
22 xStream = new XStream();
23 xStream.alias("pseudonymMaps", PseudonymMaps.class);
24 xStream.addImplicitCollection(PseudonymMaps.class, "pseudonymMaps");
25 xStream.alias("pseudonymMap", PseudonymMap.class);
26 }
27 return xStream;
28 }
29
30 /**
31 * This method serializes a PseudonymsMaps object into an XML string and
32 * returns that string.
33 */
34 public static String serialize(PseudonymMaps pseudonymMaps) {
35 return getXStream().toXML(pseudonymMaps);
36 }
37
38 /**
39 * This method takes an XML representation of the PseudonymMaps and
40 * returns the POJO objects that represent that same data.
41 */
42 public static PseudonymMaps deserialize(String xml) {
43
44 PseudonymMaps pseudonymMaps = new PseudonymMaps();
45 Object obj = getXStream().fromXML(xml);
46 if (obj instanceof PseudonymMaps) {
47 pseudonymMaps = (PseudonymMaps) obj;
48 }
49
50 return pseudonymMaps;
51 }
52}
Note: See TracBrowser for help on using the repository browser.