net.sf.jasperreports.hibernate.HibernateQueryExecuterFactoryBundle Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jasperreports-hibernate Show documentation
Show all versions of jasperreports-hibernate Show documentation
JasperReports Hibernate Jakarta EE
The newest version!
/*
* Copyright (C) 2005 - 2023 Cloud Software Group, Inc. All rights reserved.
* http://www.jaspersoft.com
* Licensed under commercial Jaspersoft Subscription License Agreement
*/
package net.sf.jasperreports.hibernate;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.query.HibernateConstants;
import net.sf.jasperreports.engine.query.JRQueryExecuterFactoryBundle;
import net.sf.jasperreports.engine.query.QueryExecuterFactory;
import net.sf.jasperreports.engine.util.JRSingletonCache;
/**
* @author Teodor Danciu ([email protected])
*/
public class HibernateQueryExecuterFactoryBundle implements JRQueryExecuterFactoryBundle {
private static final JRSingletonCache cache = new JRSingletonCache(
QueryExecuterFactory.class);
private static final HibernateQueryExecuterFactoryBundle INSTANCE = new HibernateQueryExecuterFactoryBundle();
private static final String[] LANGUAGES = new String[] { HibernateConstants.QUERY_LANGUAGE_HQL, HibernateConstants.QUERY_LANGUAGE_HQL.toUpperCase() };
private HibernateQueryExecuterFactoryBundle() {
}
/**
*
*/
public static HibernateQueryExecuterFactoryBundle getInstance() {
return INSTANCE;
}
@Override
public String[] getLanguages() {
return LANGUAGES;
}
@Override
public QueryExecuterFactory getQueryExecuterFactory(String language) throws JRException {
for (String lang : getLanguages()) {
if (lang.equalsIgnoreCase(language))
return cache.getCachedInstance(JRHibernateQueryExecuterFactory.class.getName());
}
return null;
}
public static boolean isDomainLanguage(String lang) {
String[] langs = HibernateQueryExecuterFactoryBundle.getInstance().getLanguages();
for (String l : langs)
if (l.equals(lang))
return true;
return false;
}
}