public static IKeyBuilder newInstance(int capacity,CollatorEnum collatorChoice,Locale locale,Object strength,DecompositionEnum mode){
  if (collatorChoice == CollatorEnum.ASCII) {
    return new KeyBuilder(capacity);
  }
  if (locale == null) {
    locale=Locale.getDefault();
    if (log.isInfoEnabled())     log.info("Using default locale: " + locale.getDisplayName());
  }
  final boolean icu=collatorChoice == CollatorEnum.ICU;
  if (icu && !DefaultKeyBuilderFactory.isICUAvailable()) {
    throw new UnsupportedOperationException(DefaultKeyBuilderFactory.ICU_NOT_AVAILABLE);
  }
  final byte[] buf=createBuffer(capacity);
  final int len=0;
switch (collatorChoice) {
case ICU:
    return new KeyBuilder(new ICUSortKeyGenerator(locale,strength,mode),len,buf);
case JDK:
  return new KeyBuilder(new JDKSortKeyGenerator(locale,strength,mode),len,buf);
default :
throw new UnsupportedOperationException("Collator not supported: " + collatorChoice);
}
}

public static IKeyBuilder newInstance ( int capacity , CollatorEnum collatorChoice , Locale locale , Object strength , DecompositionEnum mode ) { if ( collatorChoice == CollatorEnum . ASCII ) { return new KeyBuilder ( capacity ) ; } if ( locale == null ) { locale = Locale . getDefault ( ) ; if ( log . isInfoEnabled ( ) ) log . info ( "Using default locale: " + locale . getDisplayName ( ) ) ; } final boolean icu = collatorChoice == CollatorEnum . ICU ; if ( icu && ! DefaultKeyBuilderFactory . isICUAvailable ( ) ) { throw new UnsupportedOperationException ( DefaultKeyBuilderFactory . ICU_NOT_AVAILABLE ) ; } final byte [ ] buf = createBuffer ( capacity ) ; final int len = 0 ; switch ( collatorChoice ) { case ICU : return new KeyBuilder ( new ICUSortKeyGenerator ( locale , strength , mode ) , len , buf ) ; case JDK : return new KeyBuilder ( new JDKSortKeyGenerator ( locale , strength , mode ) , len , buf ) ; default : throw new UnsupportedOperationException ( "Collator not supported: " + collatorChoice ) ; } }
create a new instance that optionally supports unicode sort keys .
