Search in sources :

Example 1 with Namespaces

use of org.apache.synapse.mediators.annotations.Namespaces in project wso2-synapse by wso2.

the class AnnotatedCommandMediator method getNamespaces.

/**
 * Creates a Map of namespace prefixes and namespaces from a Namespace annotation
 * and the default Namespace annotation on the command class.
 */
protected Map<String, String> getNamespaces(Namespaces namespaces) {
    Map<String, String> allNamespaces = new HashMap<String, String>();
    Namespaces defaultNamespaces = ((Class<?>) getCommand()).getAnnotation(Namespaces.class);
    // First add any default namespaces
    if (defaultNamespaces != null) {
        for (String namespaceValue : defaultNamespaces.value()) {
            int i = namespaceValue.indexOf(':');
            if (i > 0) {
                String prefix = namespaceValue.substring(0, i);
                String namespace = namespaceValue.substring(i + 1);
                allNamespaces.put(prefix, namespace);
            }
        }
    }
    // add any namespaces which will overwrite any previously added default namespaces
    if (namespaces != null) {
        for (String namespaceValue : namespaces.value()) {
            int i = namespaceValue.indexOf(':');
            if (i > 0) {
                String prefix = namespaceValue.substring(0, i);
                String namespace = namespaceValue.substring(i + 1);
                allNamespaces.put(prefix, namespace);
            }
        }
    }
    return allNamespaces;
}
Also used : Namespaces(org.apache.synapse.mediators.annotations.Namespaces) HashMap(java.util.HashMap)

Aggregations

HashMap (java.util.HashMap)1 Namespaces (org.apache.synapse.mediators.annotations.Namespaces)1