eu.etaxonomy.cdm.model.common
Class AbstractStringComparator

java.lang.Object
  extended by eu.etaxonomy.cdm.model.common.AbstractStringComparator
All Implemented Interfaces:
Comparator<TaxonNode>
Direct Known Subclasses:
TaxonNodeByNameComparator

@Component
public abstract class AbstractStringComparator
extends Object
implements Comparator<TaxonNode>

Abstract Comparator for Strings which allows define substitution rules which are applied to the String to be compared before the actual comparison takes place. By this it is e.g. possible to influence the position of objects in sorted lists etc.

Intended usage: To allow maximum flexibility the property setSubstitutionRules(Map) should be set in the spring application context.

Author:
a.kohlbecker

Field Summary
protected  Map<Pattern,String> substitutionRules
           
 
Constructor Summary
AbstractStringComparator()
           
 
Method Summary
protected  String applySubstitutionRules(String s)
          Applies the first matching substitutionRules set by #setSubstitutionRules() to the given String.
 void setSubstitutionRules(Map<String,String> substitutionRules)
          Set the private field substitutionRules.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
compare, equals
 

Field Detail

substitutionRules

protected Map<Pattern,String> substitutionRules
Constructor Detail

AbstractStringComparator

public AbstractStringComparator()
Method Detail

setSubstitutionRules

public void setSubstitutionRules(Map<String,String> substitutionRules)
Set the private field substitutionRules. The substitutionRules consist of a regular expression as key and a string to be prepended as value.

Parameters:
rules -

applySubstitutionRules

protected String applySubstitutionRules(String s)
Applies the first matching substitutionRules set by #setSubstitutionRules() to the given String. A rules is applied in the following way: If the regular expression matches the given string s the String mapped by the regular expression is prepended to s.

Parameters:
s -
Returns:


Copyright © 2007-2013 EDIT. All Rights Reserved.