001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache license, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the license for the specific language governing permissions and
015 * limitations under the license.
016 */
017package org.apache.logging.log4j.message;
018
019/**
020 * Creates {@link FormattedMessage} instances for {@link MessageFactory2} methods (and {@link MessageFactory} by
021 * extension.)
022 * <p>
023 * This uses is the simplest possible implementation of {@link Message}, the where you give the message to the
024 * constructor argument as a String.
025 * </p>
026 * <p>
027 * Creates {@link StringFormattedMessage} instances for {@link #newMessage(String, Object...)}.
028 * </p>
029 * <p>
030 * This class is immutable.
031 * </p>
032 * 
033 * <h4>Note to implementors</h4>
034 * <p>
035 * This class implements all {@link MessageFactory2} methods.
036 * </p>
037 * 
038 * @since 2.5
039 */
040public final class SimpleMessageFactory extends AbstractMessageFactory {
041
042    /**
043     * Instance of StringFormatterMessageFactory.
044     */
045    public static final SimpleMessageFactory INSTANCE = new SimpleMessageFactory();
046    private static final long serialVersionUID = 4418995198790088516L;
047
048    /**
049     * Creates {@link StringFormattedMessage} instances.
050     *
051     * @param message
052     *            The message pattern.
053     * @param params
054     *            The parameters to the message are ignored.
055     * @return The Message.
056     *
057     * @see MessageFactory#newMessage(String, Object...)
058     */
059    @Override
060    public Message newMessage(final String message, final Object... params) {
061        return new SimpleMessage(message);
062    }
063
064    /**
065     * @since 2.6.1
066     */
067    @Override
068    public Message newMessage(final String message, final Object p0) {
069        return new SimpleMessage(message);
070    }
071
072    /**
073     * @since 2.6.1
074     */
075    @Override
076    public Message newMessage(final String message, final Object p0, final Object p1) {
077        return new SimpleMessage(message);
078    }
079
080    /**
081     * @since 2.6.1
082     */
083    @Override
084    public Message newMessage(final String message, final Object p0, final Object p1, final Object p2) {
085        return new SimpleMessage(message);
086    }
087
088    /**
089     * @since 2.6.1
090     */
091    @Override
092    public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3) {
093        return new SimpleMessage(message);
094    }
095
096    /**
097     * @since 2.6.1
098     */
099    @Override
100    public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4) {
101        return new SimpleMessage(message);
102    }
103
104    /**
105     * @since 2.6.1
106     */
107    @Override
108    public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5) {
109        return new SimpleMessage(message);
110    }
111
112    /**
113     * @since 2.6.1
114     */
115    @Override
116    public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
117            final Object p6) {
118        return new SimpleMessage(message);
119    }
120
121    /**
122     * @since 2.6.1
123     */
124    @Override
125    public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
126            final Object p6, final Object p7) {
127        return new SimpleMessage(message);
128    }
129
130    /**
131     * @since 2.6.1
132     */
133    @Override
134    public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
135            final Object p6, final Object p7, final Object p8) {
136        return new SimpleMessage(message);
137    }
138
139    /**
140     * @since 2.6.1
141     */
142    @Override
143    public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5,
144            final Object p6, final Object p7, final Object p8, final Object p9) {
145        return new SimpleMessage(message);
146    }
147}