本文整理汇总了Java中net.sf.jasperreports.repo.RepositoryUtil类的典型用法代码示例。如果您正苦于以下问题:Java RepositoryUtil类的具体用法?Java RepositoryUtil怎么用?Java RepositoryUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RepositoryUtil类属于net.sf.jasperreports.repo包,在下文中一共展示了RepositoryUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getContributors
import net.sf.jasperreports.repo.RepositoryUtil; //导入依赖的package包/类
@Override
public List<ParameterContributor> getContributors(ParameterContributorContext context) throws JRException
{
List<ParameterContributor> contributors = new ArrayList<ParameterContributor>();
String dataAdapterUri = JRPropertiesUtil.getInstance(context.getJasperReportsContext()).getProperty(context.getDataset(), PROPERTY_DATA_ADAPTER_LOCATION);
if (dataAdapterUri != null)
{
DataAdapterResource dataAdapterResource = RepositoryUtil.getInstance(context.getJasperReportsContext()).getResourceFromLocation(dataAdapterUri, DataAdapterResource.class);
ParameterContributor dataAdapterService = DataAdapterServiceUtil.getInstance(context).getService(dataAdapterResource.getDataAdapter());
return Collections.singletonList(dataAdapterService);
}
return contributors;
}
示例2: parseJson
import net.sf.jasperreports.repo.RepositoryUtil; //导入依赖的package包/类
public static JsonNode parseJson(JasperReportsContext jasperReportsContext, String location) throws JRException {
RepositoryUtil repository = RepositoryUtil.getInstance(jasperReportsContext);
InputStream stream = repository.getInputStreamFromLocation(location);
try {
return parseJson(stream);
} finally {
if (stream != null) {
try {
stream.close();
} catch (IOException e) {
if (log.isWarnEnabled()) {
log.warn("Failed to close input stream for location " + location, e);
}
}
}
}
}
示例3: getImageData
import net.sf.jasperreports.repo.RepositoryUtil; //导入依赖的package包/类
@Override
public byte[] getImageData(JasperReportsContext jasperReportsContext)
throws JRException
{
if (imageData == null)
{
imageData = RepositoryUtil.getInstance(jasperReportsContext).getBytesFromLocation(imageLocation);
if(imageData != null)
{
imageTypeValue = JRTypeSniffer.getImageTypeValue(imageData);
}
}
return imageData;
}
示例4: getNonLazyRenderable
import net.sf.jasperreports.repo.RepositoryUtil; //导入依赖的package包/类
/**
*
*/
public Renderable getNonLazyRenderable(String resourceLocation, OnErrorTypeEnum onErrorType) throws JRException
{
byte[] data;
try
{
data = RepositoryUtil.getInstance(jasperReportsContext).getBytesFromLocation(resourceLocation);
}
catch (Exception e)
{
if (log.isDebugEnabled())
{
log.debug("handled image error with type " + onErrorType + " for location " + resourceLocation, e);
}
return handleImageError(e, onErrorType);
}
return SimpleDataRenderer.getInstance(data);
}
示例5: getFromJasper
import net.sf.jasperreports.repo.RepositoryUtil; //导入依赖的package包/类
private JRBaseReport getFromJasper(String path) {
InputStream in = null;
JRBaseReport jd = null;
try {
in = RepositoryUtil.getInstance(dto.getjConfig()).getInputStreamFromLocation(path);
if (in != null) {
Object obj = JRLoader.loadObject(in);
if (obj instanceof JasperReport)
jd = (JasperReport) obj;
}
} catch (Exception e) {
// e.printStackTrace();
} finally {
FileUtils.closeStream(in);
}
return jd;
}
示例6: getFromJRXML
import net.sf.jasperreports.repo.RepositoryUtil; //导入依赖的package包/类
private JRBaseReport getFromJRXML(String path) {
InputStream in = null;
JRBaseReport jd = null;
try {
in = RepositoryUtil.getInstance(dto.getjConfig()).getInputStreamFromLocation(path);
if (in != null) {
InputSource is = new InputSource(new InputStreamReader(in, "UTF-8"));
jd = new JRXmlLoader(dto.getjConfig(), JasperReportsConfiguration.getJRXMLDigester()).loadXML(is);
}
} catch (Exception e) {
// e.printStackTrace();
} finally {
FileUtils.closeStream(in);
}
return jd;
}
示例7: validate
import net.sf.jasperreports.repo.RepositoryUtil; //导入依赖的package包/类
public IStatus validate(Object value) {
IStatus s = Status.OK_STATUS;
if (value != null && !((String) value).isEmpty()) {
File f = new File((String) value);
if (!f.exists() || !f.isFile()) {
if (jrContext != null) {
InputStream is = null;
try {
System.out.println(jrContext);
is = RepositoryUtil.getInstance(jrContext).getInputStreamFromLocation((String) value);
if (is == null)
s = ERROR_STATUS;
} catch (Exception e) {
s = ERROR_STATUS;
} finally {
FileUtils.closeStream(is);
}
} else
s = ERROR_STATUS;
}
}
return s;
}
示例8: getImage
import net.sf.jasperreports.repo.RepositoryUtil; //导入依赖的package包/类
@Override
public Image getImage(JasperReportsContext jasperReportsContext)
{
try
{
return
JRImageLoader.getInstance(jasperReportsContext).loadAwtImageFromBytes(
RepositoryUtil.getInstance(jasperReportsContext).getBytesFromLocation(file)
);
}
catch (JRException e)
{
throw new JRRuntimeException(e);
}
}
示例9: getRenderable
import net.sf.jasperreports.repo.RepositoryUtil; //导入依赖的package包/类
/**
* @deprecated Replaced by {@link ResourceRenderer#getInstance(String, boolean)} and {@link RendererUtil#getNonLazyRenderable(String, OnErrorTypeEnum)}.
*/
public Renderable getRenderable(String imageLocation, OnErrorTypeEnum onErrorType, boolean isLazy) throws JRException
{
if (imageLocation == null)
{
return null;
}
if (isLazy)
{
return new JRImageRenderer(imageLocation);
}
Renderable result;
try
{
byte[] data = RepositoryUtil.getInstance(jasperReportsContext).getBytesFromLocation(imageLocation);
result = new JRImageRenderer(data);
}
catch (Exception e)
{
result = handleImageError(e, onErrorType);
if (log.isDebugEnabled())
{
log.debug("handled image error with type " + onErrorType + " for location " + imageLocation, e);
}
}
return result;
}
示例10: JRCsvDataSource
import net.sf.jasperreports.repo.RepositoryUtil; //导入依赖的package包/类
/**
* Creates a datasource instance that reads CSV data from a given location, using the default encoding.
* @param jasperReportsContext the JasperReportsContext
* @param location a String representing CSV data source
*/
public JRCsvDataSource(JasperReportsContext jasperReportsContext, String location) throws JRException
{
this(RepositoryUtil.getInstance(jasperReportsContext).getInputStreamFromLocation(location));
toClose = true;
}
示例11: JRXmlDataSource
import net.sf.jasperreports.repo.RepositoryUtil; //导入依赖的package包/类
public JRXmlDataSource(
JasperReportsContext jasperReportsContext,
String uri,
String selectExpression,
boolean isNamespaceAware
) throws JRException
{
this(
jasperReportsContext,
RepositoryUtil.getInstance(jasperReportsContext).getInputStreamFromLocation(uri),
selectExpression,
isNamespaceAware
);
this.closeInputStream = true;//FIXME close the stream immediately
}
示例12: ensureData
import net.sf.jasperreports.repo.RepositoryUtil; //导入依赖的package包/类
protected synchronized void ensureData(JasperReportsContext jasperReportsContext) throws JRException
{
if (svgText == null
&& svgData == null && svgDataLocation != null)
{
svgData = RepositoryUtil.getInstance(jasperReportsContext).getBytesFromLocation(svgDataLocation);
}
}
示例13: readSwf
import net.sf.jasperreports.repo.RepositoryUtil; //导入依赖的package包/类
protected byte[] readSwf() throws JRException
{
return RepositoryUtil.getInstance(DefaultJasperReportsContext.getInstance()).getBytesFromLocation("openflashchart/open-flash-chart.swf");
}
示例14: contributeParameters
import net.sf.jasperreports.repo.RepositoryUtil; //导入依赖的package包/类
@Override
public void contributeParameters(Map<String, Object> parameters) throws JRException
{
RemoteXmlDataAdapter remoteXmlDataAdapter = getRemoteXmlDataAdapter();
if (remoteXmlDataAdapter != null)
{
if (remoteXmlDataAdapter.isUseConnection())
{
String fileName = remoteXmlDataAdapter.getFileName();
if (fileName.toLowerCase().startsWith("https://") ||
fileName.toLowerCase().startsWith("http://") ||
fileName.toLowerCase().startsWith("file:")) {
// JRXPathQueryExecuterFactory.XML_URL not available.
// Once this is available, remove XML_URL from this class.
parameters.put(XML_URL, fileName);
}
else
{
InputStream dataStream = RepositoryUtil.getInstance(getJasperReportsContext()).getInputStreamFromLocation(remoteXmlDataAdapter.getFileName());
try
{
Document document = JRXmlUtils.parse(dataStream, remoteXmlDataAdapter.isNamespaceAware());
parameters.put(JRXPathQueryExecuterFactory.PARAMETER_XML_DATA_DOCUMENT, document);
}
finally
{
try
{
dataStream.close();
}
catch (IOException e)
{
log.warn("Failed to close input stream for " + remoteXmlDataAdapter.getFileName());
}
}
}
Locale locale = remoteXmlDataAdapter.getLocale();
if (locale != null) {
parameters.put(JRXPathQueryExecuterFactory.XML_LOCALE, locale);
}
TimeZone timeZone = remoteXmlDataAdapter.getTimeZone();
if (timeZone != null) {
parameters.put(JRXPathQueryExecuterFactory.XML_TIME_ZONE, timeZone);
}
String datePattern = remoteXmlDataAdapter.getDatePattern();
if (datePattern != null && datePattern.trim().length()>0) {
parameters.put(JRXPathQueryExecuterFactory.XML_DATE_PATTERN, datePattern);
}
String numberPattern = remoteXmlDataAdapter.getNumberPattern();
if (numberPattern != null && numberPattern.trim().length()>0) {
parameters.put(JRXPathQueryExecuterFactory.XML_NUMBER_PATTERN, numberPattern);
}
}
}
}
示例15: RepositoryDataLocationService
import net.sf.jasperreports.repo.RepositoryUtil; //导入依赖的package包/类
public RepositoryDataLocationService(ParameterContributorContext context, RepositoryDataLocation dataLocation)
{
this.repository = RepositoryUtil.getInstance(context.getJasperReportsContext());
this.dataLocation = dataLocation;
}