kr.co.hit.live.web.mapper.output.impl
Class JsonResponseWriter

java.lang.Object
  extended by kr.co.hit.live.web.mapper.output.impl.AbstractResponseWriter
      extended by kr.co.hit.live.web.mapper.output.impl.JsonResponseWriter
All Implemented Interfaces:
ResponseWriter

public class JsonResponseWriter
extends AbstractResponseWriter

결과를 JSON format으로 출력한다.

Since:
5.0
Author:
최병진

Field Summary
protected static String DEFAULT_CONTENT_TYPE
           
protected static String DEFAULT_ENCODING
           
protected static String DEFAULT_RESULT_NAME
           
protected  String result_name
           
 
Fields inherited from class kr.co.hit.live.web.mapper.output.impl.AbstractResponseWriter
DEFAULT_CLIENT_MESSAGE_KEY, LINE_SEPARATOR
 
Constructor Summary
JsonResponseWriter(Output output)
           
 
Method Summary
protected  String getForwardPath()
          forwardPath로 null을 반환한다.
protected  void writeBody(ValueObjectAssembler voa, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          데이터를 출력하는 메소드이다.
protected  void writeException(Throwable thr, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          다음과 같은 JSON Object 구조를 사용하여 오류를 출력한다.
protected  void writeHead(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          전체 출력 작업 중 맨처음에 호출되는 메소드이다.
protected  void writeMessage(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          다음과 같은 JSON Object 구조를 사용하여 메시지를 출력한다.
protected  void writeTail(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          전체 출력 작업 중 마지막에 호출되는 메소드이다.
 
Methods inherited from class kr.co.hit.live.web.mapper.output.impl.AbstractResponseWriter
getOutput, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ENCODING

protected static final String DEFAULT_ENCODING
See Also:
Constant Field Values

DEFAULT_CONTENT_TYPE

protected static final String DEFAULT_CONTENT_TYPE
See Also:
Constant Field Values

DEFAULT_RESULT_NAME

protected static final String DEFAULT_RESULT_NAME
See Also:
Constant Field Values

result_name

protected String result_name
Constructor Detail

JsonResponseWriter

public JsonResponseWriter(Output output)
Method Detail

writeHead

protected void writeHead(javax.servlet.http.HttpServletRequest req,
                         javax.servlet.http.HttpServletResponse res)
                  throws IOException
Description copied from class: AbstractResponseWriter
전체 출력 작업 중 맨처음에 호출되는 메소드이다. HttpServletResponse의 charset을 설정하거나, XML 출력의 경우 과 같은 XML 시작 태그를 작성하는 용도로 사용된다.

Specified by:
writeHead in class AbstractResponseWriter
Throws:
IOException

writeTail

protected void writeTail(javax.servlet.http.HttpServletRequest req,
                         javax.servlet.http.HttpServletResponse res)
                  throws IOException
Description copied from class: AbstractResponseWriter
전체 출력 작업 중 마지막에 호출되는 메소드이다.

Specified by:
writeTail in class AbstractResponseWriter
Throws:
IOException

writeException

protected void writeException(Throwable thr,
                              javax.servlet.http.HttpServletRequest req,
                              javax.servlet.http.HttpServletResponse res)
                       throws IOException
다음과 같은 JSON Object 구조를 사용하여 오류를 출력한다.
   {"message": {"type":"error", "code":"", "msg":"", "description":""}}
 
위와 다른 구조로 오류를 출력하고자 할 경우에는 이 클래스를 상속받아 하위 클래스에서 재정의한다.

Specified by:
writeException in class AbstractResponseWriter
Throws:
IOException

writeMessage

protected void writeMessage(javax.servlet.http.HttpServletRequest req,
                            javax.servlet.http.HttpServletResponse res)
                     throws IOException
다음과 같은 JSON Object 구조를 사용하여 메시지를 출력한다.
   {"message": {"type":"info", "code":"", "msg":"", "description":""}}
 
위와 다른 구조로 오류를 출력하고자 할 경우에는 이 클래스를 상속받아 하위 클래스에서 재정의한다.

Specified by:
writeMessage in class AbstractResponseWriter
Throws:
IOException

getForwardPath

protected String getForwardPath()
forwardPath로 null을 반환한다.

Specified by:
getForwardPath in class AbstractResponseWriter
Returns:
null

writeBody

protected void writeBody(ValueObjectAssembler voa,
                         javax.servlet.http.HttpServletRequest req,
                         javax.servlet.http.HttpServletResponse res)
                  throws IOException
Description copied from class: AbstractResponseWriter
데이터를 출력하는 메소드이다.

Specified by:
writeBody in class AbstractResponseWriter
Throws:
IOException


Copyright © 2014. All Rights Reserved.