@Test public void testNullWordss() { assertEquals( 0, comparator.compare( null, null ) ); assertEquals( -1, comparator.compare( null, " abc " ) ); assertEquals( 1, comparator.compare( " abc def ghi ", null ) ); }
public int compare( String value, String assertion ) { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13749_COMPARING_STRING, value, assertion ) ); } if ( value == assertion ) { return 0; } if ( ( value == null ) || ( assertion == null ) ) { return ( assertion == null ) ? 1 : -1; } String trimmedAssertion = Strings.trim( assertion ); int pos = value.indexOf( trimmedAssertion ); if ( pos != -1 ) { int assertionLength = trimmedAssertion.length(); if ( assertionLength == value.length() ) { return 0; } if ( pos == 0 ) { char after = value.charAt( assertionLength ); if ( !Character.isLetterOrDigit( after ) ) { return 0; } else { return -1; } } if ( pos + assertionLength == value.length() ) { char before = value.charAt( value.length() - assertionLength - 1 ); if ( !Character.isLetterOrDigit( before ) ) { return 0; } else { return -1; } } char before = value.charAt( value.length() - assertionLength ); char after = value.charAt( assertionLength ); if ( Character.isLetterOrDigit( after ) ) { return -1; } if ( !Character.isLetterOrDigit( before ) ) { return -1; } return 0; } return -1; }
WordComparator extends LdapComparator<String> { public int compare( String value, String assertion ) { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13749_COMPARING_STRING, value, assertion ) ); } if ( value == assertion ) { return 0; } if ( ( value == null ) || ( assertion == null ) ) { return ( assertion == null ) ? 1 : -1; } String trimmedAssertion = Strings.trim( assertion ); int pos = value.indexOf( trimmedAssertion ); if ( pos != -1 ) { int assertionLength = trimmedAssertion.length(); if ( assertionLength == value.length() ) { return 0; } if ( pos == 0 ) { char after = value.charAt( assertionLength ); if ( !Character.isLetterOrDigit( after ) ) { return 0; } else { return -1; } } if ( pos + assertionLength == value.length() ) { char before = value.charAt( value.length() - assertionLength - 1 ); if ( !Character.isLetterOrDigit( before ) ) { return 0; } else { return -1; } } char before = value.charAt( value.length() - assertionLength ); char after = value.charAt( assertionLength ); if ( Character.isLetterOrDigit( after ) ) { return -1; } if ( !Character.isLetterOrDigit( before ) ) { return -1; } return 0; } return -1; } }
WordComparator extends LdapComparator<String> { public int compare( String value, String assertion ) { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13749_COMPARING_STRING, value, assertion ) ); } if ( value == assertion ) { return 0; } if ( ( value == null ) || ( assertion == null ) ) { return ( assertion == null ) ? 1 : -1; } String trimmedAssertion = Strings.trim( assertion ); int pos = value.indexOf( trimmedAssertion ); if ( pos != -1 ) { int assertionLength = trimmedAssertion.length(); if ( assertionLength == value.length() ) { return 0; } if ( pos == 0 ) { char after = value.charAt( assertionLength ); if ( !Character.isLetterOrDigit( after ) ) { return 0; } else { return -1; } } if ( pos + assertionLength == value.length() ) { char before = value.charAt( value.length() - assertionLength - 1 ); if ( !Character.isLetterOrDigit( before ) ) { return 0; } else { return -1; } } char before = value.charAt( value.length() - assertionLength ); char after = value.charAt( assertionLength ); if ( Character.isLetterOrDigit( after ) ) { return -1; } if ( !Character.isLetterOrDigit( before ) ) { return -1; } return 0; } return -1; } WordComparator( String oid ); }
WordComparator extends LdapComparator<String> { public int compare( String value, String assertion ) { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13749_COMPARING_STRING, value, assertion ) ); } if ( value == assertion ) { return 0; } if ( ( value == null ) || ( assertion == null ) ) { return ( assertion == null ) ? 1 : -1; } String trimmedAssertion = Strings.trim( assertion ); int pos = value.indexOf( trimmedAssertion ); if ( pos != -1 ) { int assertionLength = trimmedAssertion.length(); if ( assertionLength == value.length() ) { return 0; } if ( pos == 0 ) { char after = value.charAt( assertionLength ); if ( !Character.isLetterOrDigit( after ) ) { return 0; } else { return -1; } } if ( pos + assertionLength == value.length() ) { char before = value.charAt( value.length() - assertionLength - 1 ); if ( !Character.isLetterOrDigit( before ) ) { return 0; } else { return -1; } } char before = value.charAt( value.length() - assertionLength ); char after = value.charAt( assertionLength ); if ( Character.isLetterOrDigit( after ) ) { return -1; } if ( !Character.isLetterOrDigit( before ) ) { return -1; } return 0; } return -1; } WordComparator( String oid ); int compare( String value, String assertion ); }
WordComparator extends LdapComparator<String> { public int compare( String value, String assertion ) { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_13749_COMPARING_STRING, value, assertion ) ); } if ( value == assertion ) { return 0; } if ( ( value == null ) || ( assertion == null ) ) { return ( assertion == null ) ? 1 : -1; } String trimmedAssertion = Strings.trim( assertion ); int pos = value.indexOf( trimmedAssertion ); if ( pos != -1 ) { int assertionLength = trimmedAssertion.length(); if ( assertionLength == value.length() ) { return 0; } if ( pos == 0 ) { char after = value.charAt( assertionLength ); if ( !Character.isLetterOrDigit( after ) ) { return 0; } else { return -1; } } if ( pos + assertionLength == value.length() ) { char before = value.charAt( value.length() - assertionLength - 1 ); if ( !Character.isLetterOrDigit( before ) ) { return 0; } else { return -1; } } char before = value.charAt( value.length() - assertionLength ); char after = value.charAt( assertionLength ); if ( Character.isLetterOrDigit( after ) ) { return -1; } if ( !Character.isLetterOrDigit( before ) ) { return -1; } return 0; } return -1; } WordComparator( String oid ); int compare( String value, String assertion );  }