当前位置: 首页>>代码示例>>Java>>正文


Java AbstractResourceStream类代码示例

本文整理汇总了Java中org.apache.wicket.util.resource.AbstractResourceStream的典型用法代码示例。如果您正苦于以下问题:Java AbstractResourceStream类的具体用法?Java AbstractResourceStream怎么用?Java AbstractResourceStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AbstractResourceStream类属于org.apache.wicket.util.resource包,在下文中一共展示了AbstractResourceStream类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getResourceStream

import org.apache.wicket.util.resource.AbstractResourceStream; //导入依赖的package包/类
@Override
public IResourceStream getResourceStream() {
	final InputStream byteStream = initStream();

	if (byteStream == null) {
		return null;
	}
	
	IResourceStream resourceStream = new AbstractResourceStream(){

		private static final long serialVersionUID = 1L;
		@Override
		public String getContentType() {
			return contentType;
		}

		@Override
		public InputStream getInputStream() throws ResourceStreamNotFoundException {
		    return byteStream;
           }

		@Override
		public void close() throws IOException {
			byteStream.close();
		}
		
	};
	return resourceStream;
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:30,代码来源:AjaxDownloadBehaviorFromStream.java

示例2: close

import org.apache.wicket.util.resource.AbstractResourceStream; //导入依赖的package包/类
private void close(AbstractResourceStream stream) {
	try {
		stream.close();
	} catch (IOException e) {
		LOGGER.error("Couldn't close ResourceStream", e);
	}
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:8,代码来源:AbstractFileStoreWebResource.java

示例3: getResourceStream

import org.apache.wicket.util.resource.AbstractResourceStream; //导入依赖的package包/类
/**
 * Hook method providing the actual resource stream.
 * 
 * @return the stream.
 */
protected IResourceStream getResourceStream()
{

    return new AbstractResourceStream() {
        private static final long serialVersionUID1 = 1L;
        InputStream inStream;
        @Override
        public InputStream getInputStream()
            throws ResourceStreamNotFoundException
        {
            try {
                inStream = new FileInputStream(fileName);
            }
            catch (IOException e) {
                throw new ResourceStreamNotFoundException(e);
            }
            return inStream;
        }
        @Override
        public void close() throws IOException {
            inStream.close();
            inStream = null;
            FileUtils.forceDelete(new File(fileName));
        }
    };
}
 
开发者ID:webanno,项目名称:webanno,代码行数:32,代码来源:AJAXDownload.java

示例4: getResourceStream

import org.apache.wicket.util.resource.AbstractResourceStream; //导入依赖的package包/类
@Override
public IResourceStream getResourceStream() {
	final InputStream byteStream = initStream();

	if (byteStream == null) {
		return null;
	}

	return new AbstractResourceStream() {
		private static final long serialVersionUID = 1L;

		@Override
		public String getContentType() {
			return contentType;
		}

		@Override
		public InputStream getInputStream() {
		    return byteStream;
           }

		@Override
		public void close() throws IOException {
			byteStream.close();
		}
	};
}
 
开发者ID:Evolveum,项目名称:midpoint,代码行数:28,代码来源:AjaxDownloadBehaviorFromStream.java

示例5: makeDownloadBehavior

import org.apache.wicket.util.resource.AbstractResourceStream; //导入依赖的package包/类
private Behavior makeDownloadBehavior(final String aKey1, final String aKey2)
{
    return new AjaxEventBehavior("click")
    {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onEvent(AjaxRequestTarget aTarget)
        {
            AJAXDownload download = new AJAXDownload() {
                private static final long serialVersionUID = 1L;
                
                @Override
                protected IResourceStream getResourceStream()
                {
                    return new AbstractResourceStream() {
                        private static final long serialVersionUID = 1L;

                        @Override
                        public InputStream getInputStream()
                            throws ResourceStreamNotFoundException
                        {
                            try {
                                AgreementResult result = AgreementTable.this.getModelObject()
                                        .getStudy(aKey1, aKey2);
                                
                                switch (settings.getObject().exportFormat) {
                                case CSV:
                                    return AgreementUtils.generateCsvReport(result);
                                case DEBUG:
                                    return generateDebugReport(result);
                                default:
                                    throw new IllegalStateException("Unknown export format ["
                                            + settings.getObject().exportFormat + "]");
                                }
                            }
                            catch (Exception e) {
                                // FIXME Is there some better error handling here?
                                LOG.error("Unable to generate agreement report", e);
                                throw new ResourceStreamNotFoundException(e);
                            }
                        }

                        @Override
                        public void close()
                            throws IOException
                        {
                            // Nothing to do
                        }
                    };
                }
            };
            getComponent().add(download);
            download.initiate(aTarget,
                    "agreement" + settings.getObject().exportFormat.getExtension());
        }
    };      
}
 
开发者ID:webanno,项目名称:webanno,代码行数:59,代码来源:AgreementTable.java

示例6: downloadHtopTable

import org.apache.wicket.util.resource.AbstractResourceStream; //导入依赖的package包/类
private void downloadHtopTable(Item<UIUserForList> item, final UIUserForList user) {
    Link<Void> downloadHotpTableLink = new Link<Void>("download-hotp-table") {
        @Override
        public void onClick() {
            ByteArrayOutputStream os = new ByteArrayOutputStream();
            try {
                hotpProvider.outputSequenceForDownload(user.getUsername(), os);
            } catch (IOException e) {
                throw new IllegalStateException(e);
            }
            final byte[] bytes = os.toByteArray();
            IResourceStream resourceStream = new AbstractResourceStream() {
                @Override
                public Time lastModifiedTime() {
                    return Time.now();
                }

                @Override
                public Bytes length() {
                    return Bytes.bytes(bytes.length);
                }

                @Override
                public InputStream getInputStream() throws ResourceStreamNotFoundException {
                    return new ByteArrayInputStream(bytes);
                }

                @Override
                public String getContentType() {
                    return "application/vnd.ms-excel";
                }

                @Override
                public void close() throws IOException {
                }
            };
            getRequestCycle().replaceAllRequestHandlers(new ResourceStreamRequestHandler(resourceStream,
                    hotpProvider.getSequenceForDownloadFileName(user.getUsername())));
        }
    };
    downloadHotpTableLink.setVisible(hotpProvider.outputsSequenceForDownload());
    item.add(downloadHotpTableLink);
}
 
开发者ID:payneteasy,项目名称:superfly,代码行数:44,代码来源:ListUsersPage.java


注:本文中的org.apache.wicket.util.resource.AbstractResourceStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。