1 23 package org.mdarad.framework.expr; 24 25 import java.util.Collection ; 26 import java.util.Hashtable ; 27 import java.util.Map ; 28 29 42 public abstract class CriteriaTranslator { 43 44 47 final static public String HIBERNATE_TRANSLATOR = "HIBERNATE_TRANSLATOR"; 48 49 52 private static Map instances; 53 54 57 protected CriteriaTranslator() { 58 super(); 59 } 60 61 69 public static CriteriaTranslator getInstance(String translatorType) throws InvalidTranslatorTypeException { 70 71 if (translatorType == null) { 72 throw new InvalidTranslatorTypeException("The translator type should not be null"); 73 } 74 75 if (instances == null) { 77 instances = new Hashtable (); 78 } 79 80 CriteriaTranslator translator = (CriteriaTranslator) instances.get(translatorType); 82 if (translator == null) { 84 if (translatorType.equals(HIBERNATE_TRANSLATOR)) { 85 translator = new HibernateCriteriaTranslator(); 86 instances.put(translatorType, translator); 87 } 88 else { 89 throw new InvalidTranslatorTypeException("The translator type " + translatorType + " is not implemented"); 90 } 91 } 92 93 return translator; 94 } 95 96 103 public abstract String getExpressionStatement(Class entity, Collection criteria); 104 105 113 public abstract Object getCriterionObject(Class entity, Collection criteria); 114 115 } 116 | Popular Tags |