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.parser;
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 parser sessions.
024 */
025public final class ParserSessionArgs extends BeanSessionArgs {
026
027   Method javaMethod;
028   Object outer;
029
030   /**
031    * Default parser session args.
032    */
033   public static final ParserSessionArgs DEFAULT = new ParserSessionArgs();
034
035   /**
036    * Constructor
037    */
038   public ParserSessionArgs() {}
039
040   /**
041    * Constructor.
042    *
043    * @param properties
044    *    Session-level properties.
045    *    <br>These override context-level properties.
046    *    <br>Can be <jk>null</jk>.
047    * @param javaMethod
048    *    The java method that called this serializer, usually the method in a REST servlet.
049    *    <br>Can be <jk>null</jk>.
050    * @param locale
051    *    The session locale.
052    *    <br>If <jk>null</jk>, then the locale defined on the context is used.
053    * @param timeZone
054    *    The session timezone.
055    *    <br>If <jk>null</jk>, then the timezone defined on the context is used.
056    * @param mediaType
057    *    The session media type (e.g. <js>"application/json"</js>).
058    *    <br>Can be <jk>null</jk>.
059    * @param schema
060    *    The part schema for the serialized part.
061    *    <br>Can be <jk>null</jk>.
062    * @param debug
063    *    Enable debug mode for this session.
064    *    <br>Can be <jk>null</jk> to use the debug setting on the bean context..
065    * @param outer
066    *    The outer object for instantiating top-level non-static inner classes.
067    */
068   public ParserSessionArgs(ObjectMap properties, Method javaMethod, Locale locale, TimeZone timeZone, MediaType mediaType, HttpPartSchema schema, Boolean debug, Object outer) {
069      super(properties, locale, timeZone, mediaType, schema, debug);
070      this.javaMethod = javaMethod;
071      this.outer = outer;
072   }
073
074
075   /**
076    * The java method that called this serializer, usually the method in a REST servlet.
077    *
078    * @param javaMethod
079    *    The java method that called this serializer, usually the method in a REST servlet.
080    *    <br>Can be <jk>null</jk>.
081    * @return This object (for method chaining).
082    */
083   public ParserSessionArgs javaMethod(Method javaMethod) {
084      this.javaMethod = javaMethod;
085      return this;
086   }
087
088   /**
089    *    The outer object for instantiating top-level non-static inner classes.
090    *
091    * @param outer
092    *    The outer object for instantiating top-level non-static inner classes.
093    * @return This object (for method chaining).
094    */
095   public ParserSessionArgs outer(Object outer) {
096      this.outer = outer;
097      return this;
098   }
099
100   @Override /* BeanSessionArgs */
101   public ParserSessionArgs locale(Locale locale) {
102      super.locale(locale);
103      return this;
104   }
105
106   @Override /* BeanSessionArgs */
107   public ParserSessionArgs timeZone(TimeZone timeZone) {
108      super.timeZone(timeZone);
109      return this;
110   }
111
112   @Override /* BeanSessionArgs */
113   public ParserSessionArgs mediaType(MediaType mediaType) {
114      super.mediaType(mediaType);
115      return this;
116   }
117
118   @Override /* SessionArgs */
119   public ParserSessionArgs properties(ObjectMap properties) {
120      super.properties(properties);
121      return this;
122   }
123
124   /**
125    * @deprecated Use {@link #ParserSessionArgs(ObjectMap, Method, Locale, TimeZone, MediaType, HttpPartSchema, Boolean, Object)}
126    */
127   @SuppressWarnings("javadoc")
128   @Deprecated
129   public ParserSessionArgs(ObjectMap properties, Method javaMethod, Locale locale, TimeZone timeZone, MediaType mediaType, Object outer) {
130      this(properties, javaMethod, locale, timeZone, mediaType, null, null, outer);
131   }
132}