public class TextContainerAnalyzerDiscriminator implements Discriminator {
@Override
public String getAnalyzerDefinitionName(Object value, Object entity,
String field) {
LocaleId localeId;
if (entity instanceof HTextFlow) {
HTextFlow tf = (HTextFlow) entity;
localeId = tf.getDocument().getLocale().getLocaleId();
} else if (entity instanceof HTextFlowTarget) {
HTextFlowTarget tft = (HTextFlowTarget) entity;
localeId = tft.getLocale().getLocaleId();
} else if (entity instanceof TransMemoryUnitVariant) {
TransMemoryUnitVariant tuv = (TransMemoryUnitVariant) entity;
localeId = new LocaleId(tuv.getLanguage());
} else {
throw new IllegalArgumentException("Illegal text container type: "
+ entity.getClass().getName());
}
return getAnalyzerDefinitionName(localeId.getId());
}