⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 streamresult.java

📁 struts 2 核心包 的源码 有错误是难免的
💻 JAVA
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   StreamResult.java

package org.apache.struts2.dispatcher;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.util.ValueStack;
import java.io.InputStream;
import java.io.OutputStream;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

// Referenced classes of package org.apache.struts2.dispatcher:
//			StrutsResultSupport

public class StreamResult extends StrutsResultSupport
{

	private static final long serialVersionUID = 0xeb9f29374d83f076L;
	protected static final Log log = LogFactory.getLog(org/apache/struts2/dispatcher/StreamResult);
	public static final String DEFAULT_PARAM = "inputName";
	protected String contentType;
	protected String contentLength;
	protected String contentDisposition;
	protected String inputName;
	protected InputStream inputStream;
	protected int bufferSize;

	public StreamResult()
	{
		contentType = "text/plain";
		contentDisposition = "inline";
		inputName = "inputStream";
		bufferSize = 1024;
	}

	public StreamResult(InputStream in)
	{
		contentType = "text/plain";
		contentDisposition = "inline";
		inputName = "inputStream";
		bufferSize = 1024;
		inputStream = in;
	}

	public int getBufferSize()
	{
		return bufferSize;
	}

	public void setBufferSize(int bufferSize)
	{
		this.bufferSize = bufferSize;
	}

	public String getContentType()
	{
		return contentType;
	}

	public void setContentType(String contentType)
	{
		this.contentType = contentType;
	}

	public String getContentLength()
	{
		return contentLength;
	}

	public void setContentLength(String contentLength)
	{
		this.contentLength = contentLength;
	}

	public String getContentDisposition()
	{
		return contentDisposition;
	}

	public void setContentDisposition(String contentDisposition)
	{
		this.contentDisposition = contentDisposition;
	}

	public String getInputName()
	{
		return inputName;
	}

	public void setInputName(String inputName)
	{
		this.inputName = inputName;
	}

	protected void doExecute(String finalLocation, ActionInvocation invocation)
		throws Exception
	{
		OutputStream oOutput = null;
		if (inputStream == null)
			inputStream = (InputStream)invocation.getStack().findValue(conditionalParse(inputName, invocation));
		if (inputStream == null)
		{
			String msg = (new StringBuilder()).append("Can not find a java.io.InputStream with the name [").append(inputName).append("] in the invocation stack. ").append("Check the <param name=\"inputName\"> tag specified for this action.").toString();
			log.error(msg);
			throw new IllegalArgumentException(msg);
		}
		HttpServletResponse oResponse = (HttpServletResponse)invocation.getInvocationContext().get("com.opensymphony.xwork2.dispatcher.HttpServletResponse");
		oResponse.setContentType(conditionalParse(contentType, invocation));
		if (contentLength != null)
		{
			String _contentLength = conditionalParse(contentLength, invocation);
			int _contentLengthAsInt = -1;
			try
			{
				_contentLengthAsInt = Integer.parseInt(_contentLength);
				if (_contentLengthAsInt >= 0)
					oResponse.setContentLength(_contentLengthAsInt);
			}
			catch (NumberFormatException e)
			{
				log.warn((new StringBuilder()).append("failed to recongnize ").append(_contentLength).append(" as a number, contentLength header will not be set").toString(), e);
			}
		}
		if (contentDisposition != null)
			oResponse.addHeader("Content-disposition", conditionalParse(contentDisposition, invocation));
		oOutput = oResponse.getOutputStream();
		if (log.isDebugEnabled())
			log.debug((new StringBuilder()).append("Streaming result [").append(inputName).append("] type=[").append(contentType).append("] length=[").append(contentLength).append("] content-disposition=[").append(contentDisposition).append("]").toString());
		log.debug("Streaming to output buffer +++ START +++");
		byte oBuff[] = new byte[bufferSize];
		int iSize;
		while (-1 != (iSize = inputStream.read(oBuff))) 
			oOutput.write(oBuff, 0, iSize);
		log.debug("Streaming to output buffer +++ END +++");
		oOutput.flush();
		if (inputStream != null)
			inputStream.close();
		if (oOutput != null)
			oOutput.close();
		break MISSING_BLOCK_LABEL_438;
		Exception exception;
		exception;
		if (inputStream != null)
			inputStream.close();
		if (oOutput != null)
			oOutput.close();
		throw exception;
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -