001// *************************************************************************************************************************** 002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * 003// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * 004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * 005// * with the License. You may obtain a copy of the License at * 006// * * 007// * http://www.apache.org/licenses/LICENSE-2.0 * 008// * * 009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * 010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * 011// * specific language governing permissions and limitations under the License. * 012// *************************************************************************************************************************** 013package org.apache.juneau.serializer; 014 015import java.lang.reflect.*; 016import java.util.*; 017 018import org.apache.juneau.*; 019import org.apache.juneau.http.*; 020import org.apache.juneau.httppart.*; 021 022/** 023 * Runtime arguments common to all serializer sessions. 024 * 025 * <p> 026 * This object specifies information such as session locale or URI context. 027 */ 028public final class SerializerSessionArgs extends BeanSessionArgs { 029 030 /** 031 * Default serializer session args. 032 */ 033 public static final SerializerSessionArgs DEFAULT = new SerializerSessionArgs(); 034 035 Method javaMethod; 036 UriContext uriContext; 037 Boolean useWhitespace; 038 039 /** 040 * Constructor 041 */ 042 public SerializerSessionArgs() {} 043 044 /** 045 * Constructor. 046 * 047 * @param properties 048 * Session-level properties. 049 * <br>These override context-level properties. 050 * <br>Can be <jk>null</jk>. 051 * @param javaMethod 052 * The java method that called this serializer, usually the method in a REST servlet. 053 * <br>Can be <jk>null</jk>. 054 * @param locale 055 * The session locale. 056 * <br>If <jk>null</jk>, then the locale defined on the context is used. 057 * @param timeZone 058 * The session timezone. 059 * <br>If <jk>null</jk>, then the timezone defined on the context is used. 060 * @param mediaType 061 * The session media type (e.g. <js>"application/json"</js>). 062 * <br>Can be <jk>null</jk>. 063 * @param schema 064 * The part schema for the serialized part. 065 * <br>Can be <jk>null</jk>. 066 * @param debug 067 * Enable debug mode for this session. 068 * <br>Can be <jk>null</jk> to use the debug setting on the bean context.. 069 * @param uriContext 070 * The URI context. 071 * <br>Identifies the current request URI used for resolution of URIs to absolute or root-relative form. 072 * @param useWhitespace 073 * Override the use-whitespace flag on the serializer. 074 */ 075 public SerializerSessionArgs(ObjectMap properties, Method javaMethod, Locale locale, TimeZone timeZone, MediaType mediaType, HttpPartSchema schema, Boolean debug, UriContext uriContext, Boolean useWhitespace) { 076 super(properties, locale, timeZone, mediaType, schema, debug); 077 this.javaMethod = javaMethod; 078 this.uriContext = uriContext; 079 this.useWhitespace = useWhitespace; 080 } 081 082 /** 083 * The java method that called this serializer, usually the method in a REST servlet. 084 * 085 * @param javaMethod 086 * The java method that called this serializer, usually the method in a REST servlet. 087 * <br>Can be <jk>null</jk>. 088 * @return This object (for method chaining). 089 */ 090 public SerializerSessionArgs javaMethod(Method javaMethod) { 091 this.javaMethod = javaMethod; 092 return this; 093 } 094 095 /** 096 * The URI context. 097 * 098 * @param uriContext 099 * The URI context. 100 * <br>Identifies the current request URI used for resolution of URIs to absolute or root-relative form. 101 * @return This object (for method chaining). 102 */ 103 public SerializerSessionArgs uriContext(UriContext uriContext) { 104 this.uriContext = uriContext; 105 return this; 106 } 107 108 /** 109 * Use-whitespace flag 110 * 111 * @param useWhitespace 112 * The use-whitespace flag. 113 * <br>Overrides the use-whitespace flag on the serializer. 114 * @return This object (for method chaining). 115 */ 116 public SerializerSessionArgs useWhitespace(Boolean useWhitespace) { 117 this.useWhitespace = useWhitespace; 118 return this; 119 } 120 121 @Override /* BeanSessionArgs */ 122 public SerializerSessionArgs locale(Locale locale) { 123 super.locale(locale); 124 return this; 125 } 126 127 @Override /* BeanSessionArgs */ 128 public SerializerSessionArgs timeZone(TimeZone timeZone) { 129 super.timeZone(timeZone); 130 return this; 131 } 132 133 @Override /* BeanSessionArgs */ 134 public SerializerSessionArgs mediaType(MediaType mediaType) { 135 super.mediaType(mediaType); 136 return this; 137 } 138 139 @Override /* BeanSessionArgs */ 140 public SerializerSessionArgs debug(Boolean debug) { 141 super.debug(debug); 142 return this; 143 } 144 145 @Override /* SessionArgs */ 146 public SerializerSessionArgs properties(ObjectMap properties) { 147 super.properties(properties); 148 return this; 149 } 150 151 /** 152 * @deprecated Use {@link #SerializerSessionArgs(ObjectMap, Method, Locale, TimeZone, MediaType, HttpPartSchema, Boolean, UriContext, Boolean)} 153 */ 154 @SuppressWarnings("javadoc") 155 @Deprecated 156 public SerializerSessionArgs(ObjectMap properties, Method javaMethod, Locale locale, TimeZone timeZone, MediaType mediaType, UriContext uriContext) { 157 this(properties, javaMethod, locale, timeZone, mediaType, null, null, uriContext, false); 158 } 159}