Java Code Examples for org.apache.commons.lang3.StringUtils#compareIgnoreCase()

The following examples show how to use org.apache.commons.lang3.StringUtils#compareIgnoreCase() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RelatedTopics.java    From ontopia with Apache License 2.0 6 votes vote down vote up
private int _compare(Object o1, Object o2) {
  // NOTE: helper method that compares object in much the same way as 
  if (o1 instanceof String && o2 instanceof String) {
    // sort string case insensitively
    return StringUtils.compareIgnoreCase((String)o1, (String)o2);
  } else if (o1 instanceof Comparable && o2 instanceof Comparable) {
    // compare comparable objects
    return ((Comparable)o1).compareTo((Comparable)o2);
  } else if (o1 instanceof TopicIF && o2 instanceof TopicIF) {
    // compare topics
    TopicIF t1 = (TopicIF)o1;
    TopicIF t2 = (TopicIF)o2;
    String s1 = sort.toString(t1);
    String s2 = sort.toString(t2);
    return StringUtils.compareIgnoreCase(s1, s2);      
  }
  //! else if (o1 instanceof TMObjectIF && o2 instanceof TMObjectIF) {
  //!   // compare tmobjects
  //!   TMObjectIF t1 = (TMObjectIF)o1;
  //!   TMObjectIF t2 = (TMObjectIF)o2;
  //!   return ObjectUtils.compareIgnoreCase(t1.getObjectId(), t2.getObjectId());
  //! }
  throw new OntopiaRuntimeException("Unsupported sort keys: " + o1 + " and " + o2);
}
 
Example 2
Source File: TopicMapReferenceComparator.java    From ontopia with Apache License 2.0 5 votes vote down vote up
/**
 * INTERNAL: Compares two TopicMapReferenceIFs.
 */
@Override
public int compare(TopicMapReferenceIF tmr1, TopicMapReferenceIF tmr2) {
  String title1 = tmr1.getTitle();
  String title2 = tmr2.getTitle();
  return StringUtils.compareIgnoreCase(title1, title2);
}
 
Example 3
Source File: TopicComparator.java    From ontopia with Apache License 2.0 5 votes vote down vote up
@Override
public int compare(Topic t1, Topic t2) {
  if (t1 == null && t2 == null) return 0;
  else if (t1 == null)
    return 1;
  else if (t2 == null)
    return -1;
  return StringUtils.compareIgnoreCase(t1.getName(), t2.getName());
}
 
Example 4
Source File: FilterOperatorUtils.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the priority for scan based filtering. Multivalue column evaluation is costly, so
 * reorder such that multivalue columns are evaluated after single value columns.
 *
 * TODO: additional cost based prioritization to be added
 *
 * @param scanBasedFilterOperator the filter operator to prioritize
 * @param debugOptions  debug-options to enable/disable the optimization
 * @return the priority to be associated with the filter
 */
private static int getScanBasedFilterPriority(ScanBasedFilterOperator scanBasedFilterOperator, int basePriority,
    @Nullable Map<String, String> debugOptions) {
  if (debugOptions != null
      && StringUtils.compareIgnoreCase(debugOptions.get(USE_SCAN_REORDER_OPTIMIZATION), "false") == 0) {
    return basePriority;
  }

  if (scanBasedFilterOperator.getDataSourceMetadata().isSingleValue()) {
    return basePriority;
  } else {
    // Lower priority for multi-value column
    return basePriority + 1;
  }
}
 
Example 5
Source File: NameComparator.java    From ontopia with Apache License 2.0 4 votes vote down vote up
@Override
public int compare(Object o1, Object o2) {
  TopicNameIF n1 = (TopicNameIF)o1;
  TopicNameIF n2 = (TopicNameIF)o2;    
  return StringUtils.compareIgnoreCase(n1.getValue(), n2.getValue());
}
 
Example 6
Source File: OccurrenceComparator.java    From ontopia with Apache License 2.0 4 votes vote down vote up
@Override
public int compare(Object o1, Object o2) {
  OccurrenceIF occ1 = (OccurrenceIF)o1;
  OccurrenceIF occ2 = (OccurrenceIF)o2;    
  return StringUtils.compareIgnoreCase(occ1.getValue(), occ2.getValue());
}
 
Example 7
Source File: IdentityComparator.java    From ontopia with Apache License 2.0 4 votes vote down vote up
@Override
public int compare(Object o1, Object o2) {
  LocatorIF i1 = (LocatorIF)o1;
  LocatorIF i2 = (LocatorIF)o2;
  return StringUtils.compareIgnoreCase(i1.getAddress(), i2.getAddress());
}
 
Example 8
Source File: OntopolyRepository.java    From ontopia with Apache License 2.0 4 votes vote down vote up
@Override
public int compare(TopicMapReference r1, TopicMapReference r2) {
    return StringUtils.compareIgnoreCase(r1.getName(), r2.getName());
}