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.*; 020 021/** 022 * Runtime arguments common to all serializer sessions. 023 * 024 * <p> 025 * This object specifies information such as session locale or URI context. 026 */ 027public final class SerializerSessionArgs extends BeanSessionArgs { 028 029 Method javaMethod; 030 UriContext uriContext; 031 032 /** 033 * Constructor 034 */ 035 public SerializerSessionArgs() {} 036 037 /** 038 * Constructor. 039 * 040 * @param properties 041 * Session-level properties. 042 * <br>These override context-level properties. 043 * <br>Can be <jk>null</jk>. 044 * @param javaMethod 045 * The java method that called this serializer, usually the method in a REST servlet. 046 * <br>Can be <jk>null</jk>. 047 * @param locale 048 * The session locale. 049 * <br>If <jk>null</jk>, then the locale defined on the context is used. 050 * @param timeZone 051 * The session timezone. 052 * <br>If <jk>null</jk>, then the timezone defined on the context is used. 053 * @param mediaType 054 * The session media type (e.g. <js>"application/json"</js>). 055 * <br>Can be <jk>null</jk>. 056 * @param uriContext 057 * The URI context. 058 * <br>Identifies the current request URI used for resolution of URIs to absolute or root-relative form. 059 */ 060 public SerializerSessionArgs(ObjectMap properties, Method javaMethod, Locale locale, TimeZone timeZone, MediaType mediaType, UriContext uriContext) { 061 super(properties, locale, timeZone, mediaType); 062 this.javaMethod = javaMethod; 063 this.uriContext = uriContext; 064 } 065 066 /** 067 * The java method that called this serializer, usually the method in a REST servlet. 068 * 069 * @param javaMethod 070 * The java method that called this serializer, usually the method in a REST servlet. 071 * <br>Can be <jk>null</jk>. 072 * @return This object (for method chaining). 073 */ 074 public SerializerSessionArgs javaMethod(Method javaMethod) { 075 this.javaMethod = javaMethod; 076 return this; 077 } 078 079 /** 080 * The URI context. 081 * 082 * @param uriContext 083 * The URI context. 084 * <br>Identifies the current request URI used for resolution of URIs to absolute or root-relative form. 085 * @return This object (for method chaining). 086 */ 087 public SerializerSessionArgs uriContext(UriContext uriContext) { 088 this.uriContext = uriContext; 089 return this; 090 } 091 092 @Override /* BeanSessionArgs */ 093 public SerializerSessionArgs locale(Locale locale) { 094 super.locale(locale); 095 return this; 096 } 097 098 @Override /* BeanSessionArgs */ 099 public SerializerSessionArgs timeZone(TimeZone timeZone) { 100 super.timeZone(timeZone); 101 return this; 102 } 103 104 @Override /* BeanSessionArgs */ 105 public SerializerSessionArgs mediaType(MediaType mediaType) { 106 super.mediaType(mediaType); 107 return this; 108 } 109 110 @Override /* SessionArgs */ 111 public SerializerSessionArgs properties(ObjectMap properties) { 112 super.properties(properties); 113 return this; 114 } 115}