本文整理汇总了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;
}
示例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);
}
}
示例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));
}
};
}
示例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();
}
};
}
示例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());
}
};
}
示例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);
}