1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package coras.representations;
22
23 import java.io.ByteArrayInputStream;
24
25 import no.sintef.assetrepository.Representation;
26 import no.sintef.umt.XmiLightTransformer;
27 import no.sintef.umt.XmiReader;
28
29 import org.w3c.dom.Document;
30 import org.w3c.dom.Node;
31
32
33 /***
34 * @author fvr
35 *
36 * TODO To change the template for this generated type comment go to
37 * Window - Preferences - Java - Code Style - Code Templates
38 */
39 public class ZumlZargoModel extends UMLModelRepresentation implements BinaryRepresentation {
40
41 private Node xmiLight = null;
42
43 /***
44 * @param representation
45 */
46 protected ZumlZargoModel(Representation representation) {
47 super(representation);
48 }
49
50 public byte[] getBinaryContent() {
51 Object content = getContent();
52 if (content == null || content instanceof byte[]) {
53 return (byte[]) content;
54 } else {
55 return null;
56 }
57 }
58
59 public synchronized Node getXmiLight() {
60 if (xmiLight == null) {
61 try {
62 ByteArrayInputStream bais = new ByteArrayInputStream(getBinaryContent());
63 Document doc = XmiReader.getZumlZargoXmi(bais);
64 xmiLight = XmiLightTransformer.getTransformer().getXmiLight(doc);
65 } catch (Exception e) {
66
67 xmiLight = null;
68 }
69 }
70 return xmiLight;
71 }
72
73 }