XmlPolicyModelMarshallerpublic final class XmlPolicyModelMarshaller extends PolicyModelMarshaller
Fields Summary |
---|
private static final com.sun.xml.ws.policy.privateutil.PolicyLogger | LOGGER | private final boolean | marshallInvisible |
Constructors Summary |
---|
XmlPolicyModelMarshaller(boolean marshallInvisible)
this.marshallInvisible = marshallInvisible;
|
Methods Summary |
---|
public void | marshal(PolicySourceModel model, java.lang.Object storage)
if (storage instanceof TypedXmlWriter) {
marshal(model, (TypedXmlWriter) storage);
} else if (storage instanceof XMLStreamWriter) {
marshal(model, (XMLStreamWriter) storage);
} else {
throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0022_STORAGE_TYPE_NOT_SUPPORTED(storage.getClass().getName())));
}
| public void | marshal(java.util.Collection models, java.lang.Object storage)
for (PolicySourceModel model : models) {
marshal(model, storage);
}
| private void | marshal(PolicySourceModel model, com.sun.xml.txw2.TypedXmlWriter writer)Marshal a policy onto the given TypedXmlWriter.
final TypedXmlWriter policy = writer._element(PolicyConstants.POLICY, TypedXmlWriter.class);
marshalPolicyAttributes(model, policy);
marshal(model.getRootNode(), policy);
| private void | marshal(PolicySourceModel model, javax.xml.stream.XMLStreamWriter writer)Marshal a policy onto the given XMLStreamWriter.
final StaxSerializer serializer = new StaxSerializer(writer);
final TypedXmlWriter policy = TXW.create(PolicyConstants.POLICY, TypedXmlWriter.class, serializer);
final Map<String, String> nsMap = model.getNamespaceToPrefixMapping();
if (!marshallInvisible && nsMap.containsKey(PolicyConstants.SUN_POLICY_NAMESPACE_URI)) {
nsMap.remove(PolicyConstants.SUN_POLICY_NAMESPACE_URI);
}
for (Map.Entry<String, String> nsMappingEntry : nsMap.entrySet()) {
policy._namespace(nsMappingEntry.getKey(), nsMappingEntry.getValue());
}
marshalPolicyAttributes(model, policy);
marshal(model.getRootNode(), policy);
policy.commit();
serializer.flush();
| private void | marshal(ModelNode rootNode, com.sun.xml.txw2.TypedXmlWriter writer)Marshal given ModelNode and child elements on given TypedXmlWriter.
for (ModelNode node : rootNode) {
final AssertionData data = node.getNodeData();
if (marshallInvisible || data == null || !data.isPrivateAttributeSet()) {
TypedXmlWriter child = null;
if (data == null) {
child = writer._element(node.getType().asQName(), TypedXmlWriter.class);
} else {
child = writer._element(data.getName(), TypedXmlWriter.class);
final String value = data.getValue();
if (value != null) {
child._pcdata(value);
}
for (Entry<QName, String> entry : data.getAttributesSet()) {
child._attribute(entry.getKey(), entry.getValue());
}
}
marshal(node, child);
}
}
| private static void | marshalPolicyAttributes(PolicySourceModel model, com.sun.xml.txw2.TypedXmlWriter writer)Marshal the Policy root element attributes onto the TypedXmlWriter.
final String policyId = model.getPolicyId();
if (policyId != null) {
writer._attribute(PolicyConstants.WSU_ID, policyId);
}
final String policyName = model.getPolicyName();
if (policyName != null) {
writer._attribute(PolicyConstants.POLICY_NAME, policyName);
}
|
|