public boolean compete ( NamespaceSpecification other ) { // if no wildcard for other then we check coverage if ( "" . equals ( other . wildcard ) ) { return covers ( other . ns ) ; } // split the namespaces at wildcards String [ ] otherParts = split ( other . ns , other . wildcard ) ; // if the given namepsace specification does not use its wildcard // then we just look if the current namespace specification covers it if ( otherParts . length == 1 ) { return covers ( other . ns ) ; } // if no wildcard for the current namespace specification if ( "" . equals ( wildcard ) ) { return other . covers ( ns ) ; } // also for the current namespace specification String [ ] parts = split ( ns , wildcard ) ; // now check if the current namespace specification is just an URI if ( parts . length == 1 ) { return other . covers ( ns ) ; } // now each namespace specification contains wildcards // suppose we have // ns = a1*a2*...*an // and // other.ns = b1*b2*...*bm // then we only need to check matchPrefix(a1, b1) and matchPrefix(an, bn) where // matchPrefix(a, b) means a starts with b or b starts with a. return matchPrefix ( parts [ 0 ] , otherParts [ 0 ] ) && matchPrefix ( parts [ parts . length - 1 ] , otherParts [ otherParts . length - 1 ] ) ; }
Check if this namespace specification competes with another namespace specification .