java.text.Collator.getStrength()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(12.0k)|赞(0)|评价(0)|浏览(125)

本文整理了Java中java.text.Collator.getStrength()方法的一些代码示例,展示了Collator.getStrength()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Collator.getStrength()方法的具体详情如下:
包路径:java.text.Collator
类名称:Collator
方法名:getStrength

Collator.getStrength介绍

[英]Returns the strength value for this collator.
[中]返回此折叠器的强度值。

代码示例

代码示例来源:origin: pentaho/pentaho-kettle

int getDefaultCollationStrength( Locale aLocale ) {
 int defaultStrength = Collator.IDENTICAL;
 if ( aLocale != null ) {
  Collator curDefCollator = Collator.getInstance( aLocale );
  if ( curDefCollator != null ) {
   defaultStrength = curDefCollator.getStrength();
  }
 }
 return defaultStrength;
}

代码示例来源:origin: com.h2database/h2

private Set parseSetCollation() {
  Set command = new Set(session, SetTypes.COLLATION);
  String name = readAliasIdentifier();
  command.setString(name);
  if (equalsToken(name, CompareMode.OFF)) {
    return command;
  }
  Collator coll = CompareMode.getCollator(name);
  if (coll == null) {
    throw DbException.getInvalidValueException("collation", name);
  }
  if (readIf("STRENGTH")) {
    if (readIf("PRIMARY")) {
      command.setInt(Collator.PRIMARY);
    } else if (readIf("SECONDARY")) {
      command.setInt(Collator.SECONDARY);
    } else if (readIf("TERTIARY")) {
      command.setInt(Collator.TERTIARY);
    } else if (readIf("IDENTICAL")) {
      command.setInt(Collator.IDENTICAL);
    }
  } else {
    command.setInt(coll.getStrength());
  }
  return command;
}

代码示例来源:origin: lealone/Lealone

private Set parseSetCollation() {
  Set command = new Set(session, SetTypes.COLLATION);
  String name = readAliasIdentifier();
  command.setString(name);
  if (equalsToken(name, CompareMode.OFF)) {
    return command;
  }
  Collator coll = CompareMode.getCollator(name);
  if (coll == null) {
    throw DbException.getInvalidValueException("collation", name);
  }
  if (readIf("STRENGTH")) {
    if (readIf("PRIMARY")) {
      command.setInt(Collator.PRIMARY);
    } else if (readIf("SECONDARY")) {
      command.setInt(Collator.SECONDARY);
    } else if (readIf("TERTIARY")) {
      command.setInt(Collator.TERTIARY);
    } else if (readIf("IDENTICAL")) {
      command.setInt(Collator.IDENTICAL);
    }
  } else {
    command.setInt(coll.getStrength());
  }
  return command;
}

代码示例来源:origin: apache/phoenix

collator.getStrength(), collator.getDecomposition(),
BooleanUtils.isTrue(useSpecialUpperCaseCollator)));

代码示例来源:origin: com.salesforce.i18n/i18n-util

@Override
public synchronized int getStrength() {
  return this.originalCollator.getStrength();
}
@Override

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/com.ibm.icu.base

/**
 * Returns this Collator's strength property. The strength property
 * determines the minimum level of difference considered significant.
 * </p>
 * {@icunote} This can return QUATERNARY strength, which is not supported by the
 * JDK version.
 * <p>
 * See the Collator class description for more details.
 * </p>
 * @return this Collator's current strength property.
 * @see #setStrength
 * @see #PRIMARY
 * @see #SECONDARY
 * @see #TERTIARY
 * @see #QUATERNARY
 * @see #IDENTICAL
 * @stable ICU 2.8
 */
public int getStrength()
{
  return collator.getStrength();
}

代码示例来源:origin: at.bestsolution.eclipse/com.ibm.icu.base

/**
 * Returns this Collator's strength property. The strength property
 * determines the minimum level of difference considered significant.
 * </p>
 * {@icunote} This can return QUATERNARY strength, which is not supported by the
 * JDK version.
 * <p>
 * See the Collator class description for more details.
 * </p>
 * @return this Collator's current strength property.
 * @see #setStrength
 * @see #PRIMARY
 * @see #SECONDARY
 * @see #TERTIARY
 * @see #QUATERNARY
 * @see #IDENTICAL
 * @stable ICU 2.8
 */
public int getStrength()
{
  return collator.getStrength();
}

代码示例来源:origin: org.apache.karaf.bundles/org.apache.karaf.bundles.xalan-2.7.1

public StringComparable(final String text, final Locale locale, final Collator collator, final String caseOrder){
   m_text =  text;
   m_locale = locale;
   m_collator = (RuleBasedCollator)collator;
   m_caseOrder = caseOrder;
   m_mask = getMask(m_collator.getStrength());
}

代码示例来源:origin: org.apache.xalan/com.springsource.org.apache.xalan

public StringComparable(final String text, final Locale locale, final Collator collator, final String caseOrder){
   m_text =  text;
   m_locale = locale;
   m_collator = (RuleBasedCollator)collator;
   m_caseOrder = caseOrder;
   m_mask = getMask(m_collator.getStrength());
}

代码示例来源:origin: org.unix4j/unix4j-base

private static Comparator<? super String> getCollator(boolean ignoreCase, boolean ignoreLeadingBlanks, boolean onlyDictionaryChars) {
    final Collator collator = Collator.getInstance();
    collator.setStrength(ignoreCase ? Collator.SECONDARY : Math.max(Collator.TERTIARY, collator.getStrength()));
    final Comparator<? super String> comparator;
    if (ignoreLeadingBlanks) {
      comparator = new TrimBlanksStringComparator(Mode.Leading, collator);
    } else {
      comparator = collator;
    }
    if (onlyDictionaryChars) {
      return new DictionaryStringComparator(comparator);
    }
    return comparator;
  };
}

代码示例来源:origin: tools4j/unix4j

private static Comparator<? super String> getCollator(boolean ignoreCase, boolean ignoreLeadingBlanks, boolean onlyDictionaryChars) {
    final Collator collator = Collator.getInstance();
    collator.setStrength(ignoreCase ? Collator.SECONDARY : Math.max(Collator.TERTIARY, collator.getStrength()));
    final Comparator<? super String> comparator;
    if (ignoreLeadingBlanks) {
      comparator = new TrimBlanksStringComparator(Mode.Leading, collator);
    } else {
      comparator = collator;
    }
    if (onlyDictionaryChars) {
      return new DictionaryStringComparator(comparator);
    }
    return comparator;
  };
}

代码示例来源:origin: org.apache.karaf.bundles/org.apache.karaf.bundles.xalan-2.7.1

private final int getCaseDiff (final String text, final String pattern){
  final int savedStrength = m_collator.getStrength();
  final int savedDecomposition = m_collator.getDecomposition();
  m_collator.setStrength(Collator.TERTIARY);// not to ignore case  
  m_collator.setDecomposition(Collator.CANONICAL_DECOMPOSITION );// corresponds NDF
   final int diff[] =getFirstCaseDiff (text, pattern, m_locale);
 m_collator.setStrength(savedStrength);// restore
 m_collator.setDecomposition(savedDecomposition); //restore
 if(diff != null){  
   if((m_caseOrder).equals("upper-first")){
     if(diff[0] == UPPER_CASE){
       return -1;
     }else{
       return 1;
     }
   }else{// lower-first
     if(diff[0] == LOWER_CASE){
       return -1;
     }else{
       return 1;
     }
   }
 }else{// No case differences
   return 0;
 }
 
}

代码示例来源:origin: org.apache.xalan/com.springsource.org.apache.xalan

private final int getCaseDiff (final String text, final String pattern){
  final int savedStrength = m_collator.getStrength();
  final int savedDecomposition = m_collator.getDecomposition();
  m_collator.setStrength(Collator.TERTIARY);// not to ignore case  
  m_collator.setDecomposition(Collator.CANONICAL_DECOMPOSITION );// corresponds NDF
   final int diff[] =getFirstCaseDiff (text, pattern, m_locale);
 m_collator.setStrength(savedStrength);// restore
 m_collator.setDecomposition(savedDecomposition); //restore
 if(diff != null){  
   if((m_caseOrder).equals("upper-first")){
     if(diff[0] == UPPER_CASE){
       return -1;
     }else{
       return 1;
     }
   }else{// lower-first
     if(diff[0] == LOWER_CASE){
       return -1;
     }else{
       return 1;
     }
   }
 }else{// No case differences
   return 0;
 }
 
}

代码示例来源:origin: org.apache.xalan/com.springsource.org.apache.xalan

public int compareTo(Object o) {
 final String pattern = ((StringComparable)o).toString();
 if(m_text.equals(pattern)){//Code-point equals 
  return 0;
 }
 final int savedStrength = m_collator.getStrength(); 
 int comp = 0;
  // Is there difference more significant than case-order?     
  if(((savedStrength == Collator.PRIMARY) || (savedStrength == Collator.SECONDARY))){  
    comp = m_collator.compare(m_text, pattern );     
  }else{// more than SECONDARY
    m_collator.setStrength(Collator.SECONDARY);
    comp = m_collator.compare(m_text, pattern );
    m_collator.setStrength(savedStrength);
  }
  if(comp != 0){//Difference more significant than case-order 
   return comp ; 
  }      
   
  // No difference more significant than case-order.     
  // Find case difference
   comp = getCaseDiff(m_text, pattern);
   if(comp != 0){  
     return comp;
   }else{// No case differences. Less significant difference could exist 
     return m_collator.compare(m_text, pattern );
   }      
}

代码示例来源:origin: org.apache.karaf.bundles/org.apache.karaf.bundles.xalan-2.7.1

public int compareTo(Object o) {
 final String pattern = ((StringComparable)o).toString();
 if(m_text.equals(pattern)){//Code-point equals 
  return 0;
 }
 final int savedStrength = m_collator.getStrength(); 
 int comp = 0;
  // Is there difference more significant than case-order?     
  if(((savedStrength == Collator.PRIMARY) || (savedStrength == Collator.SECONDARY))){  
    comp = m_collator.compare(m_text, pattern );     
  }else{// more than SECONDARY
    m_collator.setStrength(Collator.SECONDARY);
    comp = m_collator.compare(m_text, pattern );
    m_collator.setStrength(savedStrength);
  }
  if(comp != 0){//Difference more significant than case-order 
   return comp ; 
  }      
   
  // No difference more significant than case-order.     
  // Find case difference
   comp = getCaseDiff(m_text, pattern);
   if(comp != 0){  
     return comp;
   }else{// No case differences. Less significant difference could exist 
     return m_collator.compare(m_text, pattern );
   }      
}

代码示例来源:origin: com.h2database/com.springsource.org.h2

private Set parseSetCollation() throws SQLException {
  Set command = new Set(session, SetTypes.COLLATION);
  String name = readAliasIdentifier();
  command.setString(name);
  if (name.equals(CompareMode.OFF)) {
    return command;
  }
  Collator coll = CompareMode.getCollator(name);
  if (coll == null) {
    throw getSyntaxError();
  }
  if (readIf("STRENGTH")) {
    if (readIf("PRIMARY")) {
      command.setInt(Collator.PRIMARY);
    } else if (readIf("SECONDARY")) {
      command.setInt(Collator.SECONDARY);
    } else if (readIf("TERTIARY")) {
      command.setInt(Collator.TERTIARY);
    } else if (readIf("IDENTICAL")) {
      command.setInt(Collator.IDENTICAL);
    }
  } else {
    command.setInt(coll.getStrength());
  }
  return command;
}

代码示例来源:origin: neradb/openddal

private Set parseSetCollation() {
  Set command = new Set(session, SetTypes.COLLATION);
  String name = readAliasIdentifier();
  command.setString(name);
  if (equalsToken(name, CompareMode.OFF)) {
    return command;
  }
  Collator coll = CompareMode.getCollator(name);
  if (coll == null) {
    throw DbException.getInvalidValueException("collation", name);
  }
  if (readIf("STRENGTH")) {
    if (readIf("PRIMARY")) {
      command.setInt(Collator.PRIMARY);
    } else if (readIf("SECONDARY")) {
      command.setInt(Collator.SECONDARY);
    } else if (readIf("TERTIARY")) {
      command.setInt(Collator.TERTIARY);
    } else if (readIf("IDENTICAL")) {
      command.setInt(Collator.IDENTICAL);
    }
  } else {
    command.setInt(coll.getStrength());
  }
  return command;
}

代码示例来源:origin: org.wowtools/h2

private Set parseSetCollation() {
  Set command = new Set(session, SetTypes.COLLATION);
  String name = readAliasIdentifier();
  command.setString(name);
  if (equalsToken(name, CompareMode.OFF)) {
    return command;
  }
  Collator coll = CompareMode.getCollator(name);
  if (coll == null) {
    throw DbException.getInvalidValueException("collation", name);
  }
  if (readIf("STRENGTH")) {
    if (readIf("PRIMARY")) {
      command.setInt(Collator.PRIMARY);
    } else if (readIf("SECONDARY")) {
      command.setInt(Collator.SECONDARY);
    } else if (readIf("TERTIARY")) {
      command.setInt(Collator.TERTIARY);
    } else if (readIf("IDENTICAL")) {
      command.setInt(Collator.IDENTICAL);
    }
  } else {
    command.setInt(coll.getStrength());
  }
  return command;
}

代码示例来源:origin: com.eventsourcing/h2

private Set parseSetCollation() {
  Set command = new Set(session, SetTypes.COLLATION);
  String name = readAliasIdentifier();
  command.setString(name);
  if (equalsToken(name, CompareMode.OFF)) {
    return command;
  }
  Collator coll = CompareMode.getCollator(name);
  if (coll == null) {
    throw DbException.getInvalidValueException("collation", name);
  }
  if (readIf("STRENGTH")) {
    if (readIf("PRIMARY")) {
      command.setInt(Collator.PRIMARY);
    } else if (readIf("SECONDARY")) {
      command.setInt(Collator.SECONDARY);
    } else if (readIf("TERTIARY")) {
      command.setInt(Collator.TERTIARY);
    } else if (readIf("IDENTICAL")) {
      command.setInt(Collator.IDENTICAL);
    }
  } else {
    command.setInt(coll.getStrength());
  }
  return command;
}

代码示例来源:origin: wplatform/jdbc-shards

private Set parseSetCollation() {
  Set command = new Set(session, SetTypes.COLLATION);
  String name = readAliasIdentifier();
  command.setString(name);
  if (equalsToken(name, CompareMode.OFF)) {
    return command;
  }
  Collator coll = CompareMode.getCollator(name);
  if (coll == null) {
    throw DbException.getInvalidValueException("collation", name);
  }
  if (readIf("STRENGTH")) {
    if (readIf("PRIMARY")) {
      command.setInt(Collator.PRIMARY);
    } else if (readIf("SECONDARY")) {
      command.setInt(Collator.SECONDARY);
    } else if (readIf("TERTIARY")) {
      command.setInt(Collator.TERTIARY);
    } else if (readIf("IDENTICAL")) {
      command.setInt(Collator.IDENTICAL);
    }
  } else {
    command.setInt(coll.getStrength());
  }
  return command;
}

相关文章