View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements. See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache license, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License. You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the license for the specific language governing permissions and
15   * limitations under the license.
16   */
17  package org.apache.logging.log4j.message;
18  
19  /**
20   * Creates {@link FormattedMessage} instances for {@link MessageFactory2} methods (and {@link MessageFactory} by
21   * extension.)
22   * 
23   * <h4>Note to implementors</h4>
24   * <p>
25   * This class implements all {@link MessageFactory2} methods.
26   * </p>
27   */
28  public class FormattedMessageFactory extends AbstractMessageFactory {
29  
30      private static final long serialVersionUID = 1L;
31  
32      /**
33       * Constructs a message factory with default flow strings.
34       */
35      public FormattedMessageFactory() {
36          super();
37      }
38  
39      /**
40       * Creates {@link StringFormattedMessage} instances.
41       *
42       * @param message The message format.
43       * @param params Message parameters.
44       * @return The Message object.
45       *
46       * @see MessageFactory#newMessage(String, Object...)
47       */
48      @Override
49      public Message newMessage(final String message, final Object... params) {
50          return new FormattedMessage(message, params);
51      }
52  
53      /**
54       * @since 2.6.1
55       */
56      @Override
57      public Message newMessage(final String message, final Object p0) {
58          return new FormattedMessage(message, p0);
59      }
60  
61      /**
62       * @since 2.6.1
63       */
64      @Override
65      public Message newMessage(final String message, final Object p0, final Object p1) {
66          return new FormattedMessage(message, p0, p1);
67      }
68  
69      /**
70       * @since 2.6.1
71       */
72      @Override
73      public Message newMessage(final String message, final Object p0, final Object p1, final Object p2) {
74          return new FormattedMessage(message, p0, p1, p2);
75      }
76  
77      /**
78       * @since 2.6.1
79       */
80      @Override
81      public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3) {
82          return new FormattedMessage(message, p0, p1, p2, p3);
83      }
84  
85      /**
86       * @since 2.6.1
87       */
88      @Override
89      public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4) {
90          return new FormattedMessage(message, p0, p1, p2, p3, p4);
91      }
92  
93      /**
94       * @since 2.6.1
95       */
96      @Override
97      public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5) {
98          return new FormattedMessage(message, p0, p1, p2, p3, p4, p5);
99      }
100 
101     /**
102      * @since 2.6.1
103      */
104     @Override
105     public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
106             final Object p6) {
107         return new FormattedMessage(message, p0, p1, p2, p3, p4, p5, p6);
108     }
109 
110     /**
111      * @since 2.6.1
112      */
113     @Override
114     public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
115             final Object p6, final Object p7) {
116         return new FormattedMessage(message, p0, p1, p2, p3, p4, p5, p6, p7);
117     }
118 
119     /**
120      * @since 2.6.1
121      */
122     @Override
123     public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
124             final Object p6, final Object p7, final Object p8) {
125         return new FormattedMessage(message, p0, p1, p2, p3, p4, p5, p6, p7, p8);
126     }
127 
128     /**
129      * @since 2.6.1
130      */
131     @Override
132     public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
133             final Object p6, final Object p7, final Object p8, final Object p9) {
134         return new FormattedMessage(message, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
135     }
136 }