1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.opensaml.xacml.ctx.impl;
18
19 import java.util.Map.Entry;
20
21 import javax.xml.namespace.QName;
22
23 import org.opensaml.Configuration;
24 import org.opensaml.xacml.ctx.ResourceContentType;
25 import org.opensaml.xml.XMLObject;
26 import org.opensaml.xml.io.AbstractXMLObjectMarshaller;
27 import org.opensaml.xml.io.MarshallingException;
28 import org.opensaml.xml.util.XMLHelper;
29 import org.w3c.dom.Attr;
30 import org.w3c.dom.Element;
31
32
33 public class ResourceContentTypeMarshaller extends AbstractXMLObjectMarshaller {
34
35
36 public ResourceContentTypeMarshaller() {
37 super();
38 }
39
40
41
42
43
44
45
46
47
48 protected ResourceContentTypeMarshaller(String targetNamespaceURI, String targetLocalName) {
49 super(targetNamespaceURI, targetLocalName);
50 }
51
52
53 protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException {
54 ResourceContentType resourceContent = (ResourceContentType)xmlObject;
55
56 Attr attribute;
57 for (Entry<QName, String> entry : resourceContent.getUnknownAttributes().entrySet()) {
58 attribute = XMLHelper.constructAttribute(domElement.getOwnerDocument(), entry.getKey());
59 attribute.setValue(entry.getValue());
60 domElement.setAttributeNodeNS(attribute);
61 if (Configuration.isIDAttribute(entry.getKey())
62 || resourceContent.getUnknownAttributes().isIDAttribute(entry.getKey())) {
63 attribute.getOwnerElement().setIdAttributeNode(attribute, true);
64 }
65 }
66 }
67
68
69 protected void marshallElementContent(XMLObject xmlObject, Element domElement) throws MarshallingException {
70 ResourceContentType resourceContent = (ResourceContentType) xmlObject;
71
72 if(resourceContent.getValue() != null){
73 XMLHelper.appendTextContent(domElement, resourceContent.getValue());
74 }
75 }
76 }