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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 package org.apache.log4j.pattern;
23 <p>PatternConverter is an abstract class that provides the
24 formatting functionality that derived classes need.
26 <p>Conversion specifiers in a conversion patterns are parsed to
27 individual PatternConverters. Each of which is responsible for
28 converting an object in a converter specific manner.
30 @author <a href="mailto:cakalijp@Maritz.com">James P. Cakalic</a>
31 @author Ceki Gülcü
36 public abstract class PatternConverter {
40 private final String name;
43 * Converter style name.
45 private final String style;
48 * Create a new pattern converter.
49 * @param name name for pattern converter.
50 * @param style CSS style for formatted output.
52 protected PatternConverter(final String name, final String style) {
58 * Formats an object into a string buffer.
59 * @param obj event to format, may not be null.
60 * @param toAppendTo string buffer to which the formatted event will be appended. May not be null.
62 public abstract void format(final Object obj, final StringBuffer toAppendTo);
65 * This method returns the name of the conversion pattern.
67 * The name can be useful to certain Layouts such as HTMLLayout.
69 * @return the name of the conversion pattern
71 public final String getName() {
76 * This method returns the CSS style class that should be applied to
77 * the LoggingEvent passed as parameter, which can be null.
79 * This information is currently used only by HTMLLayout.
81 * @param e null values are accepted
82 * @return the name of the conversion pattern
84 public String getStyleClass(Object e) {