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      }
37  
38      /**
39       * Creates {@link StringFormattedMessage} instances.
40       *
41       * @param message The message format.
42       * @param params Message parameters.
43       * @return The Message object.
44       *
45       * @see MessageFactory#newMessage(String, Object...)
46       */
47      @Override
48      public Message newMessage(final String message, final Object... params) {
49          return new FormattedMessage(message, params);
50      }
51  
52      /**
53       * @since 2.6.1
54       */
55      @Override
56      public Message newMessage(final String message, final Object p0) {
57          return new FormattedMessage(message, p0);
58      }
59  
60      /**
61       * @since 2.6.1
62       */
63      @Override
64      public Message newMessage(final String message, final Object p0, final Object p1) {
65          return new FormattedMessage(message, p0, p1);
66      }
67  
68      /**
69       * @since 2.6.1
70       */
71      @Override
72      public Message newMessage(final String message, final Object p0, final Object p1, final Object p2) {
73          return new FormattedMessage(message, p0, p1, p2);
74      }
75  
76      /**
77       * @since 2.6.1
78       */
79      @Override
80      public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3) {
81          return new FormattedMessage(message, p0, p1, p2, p3);
82      }
83  
84      /**
85       * @since 2.6.1
86       */
87      @Override
88      public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4) {
89          return new FormattedMessage(message, p0, p1, p2, p3, p4);
90      }
91  
92      /**
93       * @since 2.6.1
94       */
95      @Override
96      public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5) {
97          return new FormattedMessage(message, p0, p1, p2, p3, p4, p5);
98      }
99  
100     /**
101      * @since 2.6.1
102      */
103     @Override
104     public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
105             final Object p6) {
106         return new FormattedMessage(message, p0, p1, p2, p3, p4, p5, p6);
107     }
108 
109     /**
110      * @since 2.6.1
111      */
112     @Override
113     public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
114             final Object p6, final Object p7) {
115         return new FormattedMessage(message, p0, p1, p2, p3, p4, p5, p6, p7);
116     }
117 
118     /**
119      * @since 2.6.1
120      */
121     @Override
122     public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
123             final Object p6, final Object p7, final Object p8) {
124         return new FormattedMessage(message, p0, p1, p2, p3, p4, p5, p6, p7, p8);
125     }
126 
127     /**
128      * @since 2.6.1
129      */
130     @Override
131     public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
132             final Object p6, final Object p7, final Object p8, final Object p9) {
133         return new FormattedMessage(message, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
134     }
135 }