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; 014 015import java.util.*; 016 017import org.apache.juneau.http.*; 018 019/** 020 * Runtime arguments common to all bean, serializer, and parser sessions. 021 */ 022public class BeanSessionArgs extends SessionArgs { 023 024 /** 025 * Default empty session arguments. 026 */ 027 public static final BeanSessionArgs DEFAULT = new BeanSessionArgs(ObjectMap.EMPTY_MAP, null, null, null); 028 029 Locale locale; 030 TimeZone timeZone; 031 MediaType mediaType; 032 033 /** 034 * Constructor 035 */ 036 public BeanSessionArgs() {} 037 038 /** 039 * Constructor. 040 * 041 * @param properties 042 * Session-level properties. 043 * <br>These override context-level properties. 044 * <br>Can be <jk>null</jk>. 045 * @param locale 046 * The session locale. 047 * <br>If <jk>null</jk>, then the locale defined on the context is used. 048 * @param timeZone 049 * The session timezone. 050 * <br>If <jk>null</jk>, then the timezone defined on the context is used. 051 * @param mediaType 052 * The session media type (e.g. <js>"application/json"</js>). 053 * <br>Can be <jk>null</jk>. 054 */ 055 public BeanSessionArgs(ObjectMap properties, Locale locale, TimeZone timeZone, MediaType mediaType) { 056 super(properties); 057 this.locale = locale; 058 this.timeZone = timeZone; 059 this.mediaType = mediaType; 060 } 061 062 /** 063 * The session locale. 064 * 065 * @param locale 066 * The session locale. 067 * <br>If <jk>null</jk>, then the locale defined on the context is used. 068 * @return This object (for method chaining). 069 */ 070 public BeanSessionArgs locale(Locale locale) { 071 this.locale = locale; 072 return this; 073 } 074 075 /** 076 * The session timezone. 077 * 078 * @param timeZone 079 * The session timezone. 080 * <br>If <jk>null</jk>, then the timezone defined on the context is used. 081 * @return This object (for method chaining). 082 */ 083 public BeanSessionArgs timeZone(TimeZone timeZone) { 084 this.timeZone = timeZone; 085 return this; 086 } 087 088 /** 089 * The session media type. 090 * 091 * @param mediaType 092 * The session media type (e.g. <js>"application/json"</js>). 093 * <br>Can be <jk>null</jk>. 094 * @return This object (for method chaining). 095 */ 096 public BeanSessionArgs mediaType(MediaType mediaType) { 097 this.mediaType = mediaType; 098 return this; 099 } 100 101 @Override /* SessionArgs */ 102 public BeanSessionArgs properties(ObjectMap properties) { 103 super.properties(properties); 104 return this; 105 } 106}