protected CollectionMatch selectBestCollectionMatch ( CollectionMatch previousMatch , CollectionMatch currentMatch ) { CollectionMatch bestMatch = null ; if ( previousMatch == null ) { bestMatch = currentMatch ; } else if ( previousMatch . isDenyMatchByOmission ( ) ) { bestMatch = previousMatch ; } else if ( currentMatch . isDenyMatchByOmission ( ) ) { bestMatch = currentMatch ; } else if ( previousMatch . isDenyMatch ( ) ) { bestMatch = previousMatch ; } else if ( currentMatch . isDenyMatch ( ) ) { bestMatch = currentMatch ; } else if ( previousMatch . isPermitMatch ( ) ) { bestMatch = previousMatch ; } else if ( currentMatch . isPermitMatch ( ) ) { bestMatch = currentMatch ; } else if ( previousMatch . isExactMatch ( ) ) { bestMatch = previousMatch ; } else if ( currentMatch . isExactMatch ( ) ) { bestMatch = currentMatch ; } else if ( previousMatch . isPathMatch ( ) && previousMatch . getUrlPattern ( ) . length ( ) >= currentMatch . getUrlPattern ( ) . length ( ) ) { bestMatch = previousMatch ; } else { bestMatch = currentMatch ; } return bestMatch ; }
Exact match is best then path match with longest URI matched finally extension match .