1 17 package org.apache.ldap.server.schema; 18 19 20 import javax.naming.NamingException ; 21 import java.io.Serializable ; 22 import java.util.Comparator ; 23 24 25 33 public class SerializableComparator implements Comparator , Serializable 34 { 35 private static final long serialVersionUID = 3257566226288162870L; 36 37 38 private static ComparatorRegistry registry = null; 39 40 private String matchingRuleOid; 41 42 private transient Comparator wrapped; 43 44 45 49 50 55 public static void setRegistry( ComparatorRegistry registry ) 56 { 57 SerializableComparator.registry = registry; 58 } 59 60 61 65 66 public SerializableComparator( String matchingRuleOid ) 67 { 68 this.matchingRuleOid = matchingRuleOid; 69 } 70 71 72 76 77 80 public int compare( Object o1, Object o2 ) 81 { 82 if ( wrapped == null ) 83 { 84 try 85 { 86 wrapped = registry.lookup( matchingRuleOid ); 87 } 88 catch ( NamingException e ) 89 { 90 e.printStackTrace(); 91 } 92 } 93 94 return wrapped.compare( o1, o2 ); 95 } 96 } 97 | Popular Tags |