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 * Enables the use of <code>{}</code> parameter markers in message strings. 024 * </p> 025 * <p> 026 * Creates {@link ParameterizedMessage} instances for {@link #newMessage(String, Object...)}. 027 * </p> 028 * <p> 029 * This class is immutable. 030 * </p> 031 * 032 * <h4>Note to implementors</h4> 033 * <p> 034 * This class implements all {@link MessageFactory2} methods. 035 * </p> 036 */ 037public final class ParameterizedMessageFactory extends AbstractMessageFactory { 038 /** 039 * Instance of ParameterizedMessageFactory. 040 */ 041 public static final ParameterizedMessageFactory INSTANCE = new ParameterizedMessageFactory(); 042 043 private static final long serialVersionUID = -8970940216592525651L; 044 045 /** 046 * Constructs a message factory. 047 */ 048 public ParameterizedMessageFactory() { 049 } 050 051 /** 052 * Creates {@link ParameterizedMessage} instances. 053 * 054 * @param message The message pattern. 055 * @param params The message parameters. 056 * @return The Message. 057 * 058 * @see MessageFactory#newMessage(String, Object...) 059 */ 060 @Override 061 public Message newMessage(final String message, final Object... params) { 062 return new ParameterizedMessage(message, params); 063 } 064 065 /** 066 * @since 2.6.1 067 */ 068 @Override 069 public Message newMessage(final String message, final Object p0) { 070 return new ParameterizedMessage(message, p0); 071 } 072 073 /** 074 * @since 2.6.1 075 */ 076 @Override 077 public Message newMessage(final String message, final Object p0, final Object p1) { 078 return new ParameterizedMessage(message, p0, p1); 079 } 080 081 /** 082 * @since 2.6.1 083 */ 084 @Override 085 public Message newMessage(final String message, final Object p0, final Object p1, final Object p2) { 086 return new ParameterizedMessage(message, p0, p1, p2); 087 } 088 089 /** 090 * @since 2.6.1 091 */ 092 @Override 093 public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3) { 094 return new ParameterizedMessage(message, p0, p1, p2, p3); 095 } 096 097 /** 098 * @since 2.6.1 099 */ 100 @Override 101 public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4) { 102 return new ParameterizedMessage(message, p0, p1, p2, p3, p4); 103 } 104 105 /** 106 * @since 2.6.1 107 */ 108 @Override 109 public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5) { 110 return new ParameterizedMessage(message, p0, p1, p2, p3, p4, p5); 111 } 112 113 /** 114 * @since 2.6.1 115 */ 116 @Override 117 public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5, 118 final Object p6) { 119 return new ParameterizedMessage(message, p0, p1, p2, p3, p4, p5, p6); 120 } 121 122 /** 123 * @since 2.6.1 124 */ 125 @Override 126 public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5, 127 final Object p6, final Object p7) { 128 return new ParameterizedMessage(message, p0, p1, p2, p3, p4, p5, p6, p7); 129 } 130 131 /** 132 * @since 2.6.1 133 */ 134 @Override 135 public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5, 136 final Object p6, final Object p7, final Object p8) { 137 return new ParameterizedMessage(message, p0, p1, p2, p3, p4, p5, p6, p7, p8); 138 } 139 140 /** 141 * @since 2.6.1 142 */ 143 @Override 144 public Message newMessage(final String message, final Object p0, final Object p1, final Object p2, final Object p3, final Object p4, final Object p5, 145 final Object p6, final Object p7, final Object p8, final Object p9) { 146 return new ParameterizedMessage(message, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9); 147 } 148}