1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.struts2.json;
22
23 import javax.servlet.http.HttpServletResponse;
24
25 import org.apache.commons.lang.xwork.StringUtils;
26
27 public class SerializationParams {
28 private static final String DEFAULT_CONTENT_TYPE = "application/json";
29
30 private final HttpServletResponse response;
31 private final String encoding;
32 private final boolean wrapWithComments;
33 private final String serializedJSON;
34 private final boolean smd;
35 private final boolean gzip;
36 private final boolean noCache;
37 private final int statusCode;
38 private final int errorCode;
39 private final boolean prefix;
40 private String contentType = DEFAULT_CONTENT_TYPE;
41 private String wrapPrefix;
42 private String wrapSuffix;
43
44 public SerializationParams(HttpServletResponse response, String encoding, boolean wrapWithComments,
45 String serializedJSON, boolean smd, boolean gzip, boolean noCache, int statusCode, int errorCode,
46 boolean prefix, String contentType, String wrapPrefix, String wrapSuffix) {
47 this.response = response;
48 this.encoding = encoding;
49 this.wrapWithComments = wrapWithComments;
50 this.serializedJSON = serializedJSON;
51 this.smd = smd;
52 this.gzip = gzip;
53 this.noCache = noCache;
54 this.statusCode = statusCode;
55 this.errorCode = errorCode;
56 this.prefix = prefix;
57 this.contentType = StringUtils.defaultString(contentType, DEFAULT_CONTENT_TYPE);
58 this.wrapPrefix = wrapPrefix;
59 this.wrapSuffix = wrapSuffix;
60 }
61
62 public SerializationParams(HttpServletResponse response, String defaultEncoding,
63 boolean wrapWithComments, String json, boolean b, boolean b1, boolean noCache, int i, int i1,
64 boolean prefix, String contentType) {
65 this(response, defaultEncoding, wrapWithComments, json, b, b1, noCache, i, i1, prefix, contentType,
66 null, null);
67 }
68
69 public String getWrapSuffix() {
70 return wrapSuffix;
71 }
72
73 public String getWrapPrefix() {
74 return wrapPrefix;
75 }
76
77 public HttpServletResponse getResponse() {
78 return response;
79 }
80
81 public String getEncoding() {
82 return encoding;
83 }
84
85 public boolean isWrapWithComments() {
86 return wrapWithComments;
87 }
88
89 public String getSerializedJSON() {
90 return serializedJSON;
91 }
92
93 public boolean isSmd() {
94 return smd;
95 }
96
97 public boolean isGzip() {
98 return gzip;
99 }
100
101 public boolean isNoCache() {
102 return noCache;
103 }
104
105 public int getStatusCode() {
106 return statusCode;
107 }
108
109 public int getErrorCode() {
110 return errorCode;
111 }
112
113 public boolean isPrefix() {
114 return prefix;
115 }
116
117 public String getContentType() {
118 return contentType;
119 }
120 }