public boolean matches()

in mixins/om-mixins/src/main/java/org/apache/axiom/soap/impl/common/RolePlayerChecker.java [56:93]


    public boolean matches(AxiomElement header, String unused1, String unused2) {
        // If we're filtering on namespace, check that first since the compare is simpler.
        if (namespace != null) {
            OMNamespace headerNamespace = header.getNamespace();
            if (headerNamespace == null || !namespace.equals(headerNamespace.getNamespaceURI())) {
                return false;
            }
        }

        String role = SOAPHeaderBlockHelper.getRole(header, soapHelper);
        SOAPVersion version = soapHelper.getVersion();

        // 1. If role is ultimatedest, go by what the rolePlayer says
        if (role == null
                || role.equals("")
                || (version instanceof SOAP12Version
                        && role.equals(SOAP12Constants.SOAP_ROLE_ULTIMATE_RECEIVER))) {
            return (rolePlayer == null || rolePlayer.isUltimateDestination());
        }

        // 2. If role is next, always return true
        if (role.equals(version.getNextRoleURI())) return true;

        // 3. If role is none, always return false
        if (version instanceof SOAP12Version && role.equals(SOAP12Constants.SOAP_ROLE_NONE)) {
            return false;
        }

        // 4. Return t/f depending on match
        List<String> roles = (rolePlayer == null) ? null : rolePlayer.getRoles();
        if (roles != null) {
            for (String thisRole : roles) {
                if (thisRole.equals(role)) return true;
            }
        }

        return false;
    }