Policy p = null;
if (Constants.isPolicyElement(e.getElementType())) {
p = builder.getPolicy(e.getElement());
} else if (Constants.isPolicyRef(e.getElementType())) {
PolicyReference ref = builder.getPolicyReference(e.getElement());
if (null != ref) {
p = resolveReference(ref, di);
}
}
if (null != p) {
if (elementPolicy == null) {
elementPolicy = new Policy();
}
elementPolicy = elementPolicy.merge(p);
}
}
}
if (includeAttributes && ex.getExtensionAttributes() != null) {
for (Map.Entry<QName, Object> ent : ex.getExtensionAttributes().entrySet()) {
if (Constants.isPolicyURIsAttr(ent.getKey())) {
Object attr = ent.getValue();
// can be of type a String, a QName, a list of Srings or a list of QNames
String uris = null;
if (attr instanceof QName) {
uris = ((QName)attr).getLocalPart();
} else if (attr instanceof String) {
uris = (String)attr;
}
if (null != uris) {
StringTokenizer st = new StringTokenizer(uris);
while (st.hasMoreTokens()) {
String uri = st.nextToken();
PolicyReference ref = new PolicyReference();
ref.setURI(uri);
Policy p = resolveReference(ref, di);
if (null != p) {
elementPolicy = elementPolicy == null
? new Policy().merge(p) : elementPolicy.merge(p);
}