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 * 
023 * <h4>Note to implementors</h4>
024 * <p>
025 * This class implements all {@link MessageFactory2} methods.
026 * </p>
027 */
028public class FormattedMessageFactory extends AbstractMessageFactory {
029
030    private static final long serialVersionUID = 1L;
031
032    /**
033     * Constructs a message factory with default flow strings.
034     */
035    public FormattedMessageFactory() {
036        super();
037    }
038
039    /**
040     * Creates {@link StringFormattedMessage} instances.
041     *
042     * @param message The message format.
043     * @param params Message parameters.
044     * @return The Message object.
045     *
046     * @see MessageFactory#newMessage(String, Object...)
047     */
048    @Override
049    public Message newMessage(final String message, final Object... params) {
050        return new FormattedMessage(message, params);
051    }
052
053    /**
054     * @since 2.6.1
055     */
056    @Override
057    public Message newMessage(final String message, final Object p0) {
058        return new FormattedMessage(message, p0);
059    }
060
061    /**
062     * @since 2.6.1
063     */
064    @Override
065    public Message newMessage(final String message, final Object p0, final Object p1) {
066        return new FormattedMessage(message, p0, p1);
067    }
068
069    /**
070     * @since 2.6.1
071     */
072    @Override
073    public Message newMessage(final String message, final Object p0, final Object p1, final Object p2) {
074        return new FormattedMessage(message, p0, p1, p2);
075    }
076
077    /**
078     * @since 2.6.1
079     */
080    @Override
081    public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3) {
082        return new FormattedMessage(message, p0, p1, p2, p3);
083    }
084
085    /**
086     * @since 2.6.1
087     */
088    @Override
089    public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4) {
090        return new FormattedMessage(message, p0, p1, p2, p3, p4);
091    }
092
093    /**
094     * @since 2.6.1
095     */
096    @Override
097    public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5) {
098        return new FormattedMessage(message, p0, p1, p2, p3, p4, p5);
099    }
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}