mirror of
https://github.com/apache/poi.git
synced 2026-02-27 20:40:08 +08:00
https://svn.apache.org/repos/asf/poi/trunk ........ r615190 | nick | 2008-01-25 12:52:39 +0100 (Fri, 25 Jan 2008) | 1 line Correctly handle the last paragraph via a fix to TableCell - patch from bug #44292 ........ r615255 | nick | 2008-01-25 17:15:49 +0100 (Fri, 25 Jan 2008) | 1 line Don't swap AreaPtg references from relative to absolute, by correctly processing the fields. Patch from bug #44293 ........ r615259 | nick | 2008-01-25 17:33:59 +0100 (Fri, 25 Jan 2008) | 1 line Add a test to show the bug #42618 appears to be incorrect ........ r615310 | yegor | 2008-01-25 20:27:56 +0100 (Fri, 25 Jan 2008) | 1 line commented failing test42618() ........ r615315 | yegor | 2008-01-25 20:37:22 +0100 (Fri, 25 Jan 2008) | 1 line fix bug #44296: HSLF Not Extracting Slide Background Image ........ r615610 | yegor | 2008-01-27 15:55:32 +0100 (Sun, 27 Jan 2008) | 1 line fix bug #44297: IntPtg must operate with unsigned short. Reading signed short results in incorrect formula calculation. ........ r615769 | yegor | 2008-01-28 09:53:19 +0100 (Mon, 28 Jan 2008) | 1 line start a new POI 3.1 section in the change log ........ r615859 | nick | 2008-01-28 13:18:12 +0100 (Mon, 28 Jan 2008) | 1 line Mostly fix bug 42618 (really this time...) - can now open the file properly, but getCellFormula() is still playing up (bug #44306 opened for this) ........ r617156 | nick | 2008-01-31 17:41:53 +0100 (Thu, 31 Jan 2008) | 1 line Lots of documentation updates, to make it clearer how the code actually works ........ r617167 | nick | 2008-01-31 18:30:16 +0100 (Thu, 31 Jan 2008) | 1 line Convert HSSFEventFactory to using the new HSSFRecordStream, which returns fully-formed HSSFRecords. HSSFRecordStream allows for pull-style eventusermodel processing ........ r617483 | nick | 2008-02-01 13:13:08 +0100 (Fri, 01 Feb 2008) | 1 line Tweak the javadoc so it's clearer on the overview what the getFormat method does ........ r617487 | nick | 2008-02-01 13:29:38 +0100 (Fri, 01 Feb 2008) | 1 line Improvements to how SystemOutLogger and CommonsLogger log messages with exceptions, and avoid an infinite loop with certain log messages with exceptions - triggered by bug #44326 ........ r617491 | nick | 2008-02-01 14:02:06 +0100 (Fri, 01 Feb 2008) | 1 line Patch from bug #44336 - correctly escape sheet names in formula references, including tests for this, and fixes to old tests that were expecting the un-escaped sheet names ........ r617516 | nick | 2008-02-01 16:20:55 +0100 (Fri, 01 Feb 2008) | 1 line Make a start on the hyperlink record support - not finished yet though, so not enabled ........ r617523 | nick | 2008-02-01 16:41:32 +0100 (Fri, 01 Feb 2008) | 1 line Get the Hyperlink record code so that it doesn't break any existing tests, and add in (no usermodel support yet though) ........ r617555 | nick | 2008-02-01 17:52:58 +0100 (Fri, 01 Feb 2008) | 1 line More Hyperlink support. Doesn't end up in HSSFCell just yet, as the records are in the wrong bit of the file, so don't get associated with the sheet. All tests still passing though ........ r617834 | yegor | 2008-02-02 18:06:14 +0100 (Sat, 02 Feb 2008) | 1 line usermodel support for excel hyperlinks ........ r618230 | nick | 2008-02-04 11:48:29 +0100 (Mon, 04 Feb 2008) | 1 line Implement CountA, CountIf, Index, Rows and Columns functions. Patch from Josh Micich in bug #44345 ........ r618235 | nick | 2008-02-04 12:14:49 +0100 (Mon, 04 Feb 2008) | 1 line Test file with hyperlinks on many sheets, of different types ........ git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@618325 13f79535-47bb-0310-9956-ffa450edef68
711 lines
24 KiB
Java
711 lines
24 KiB
Java
|
|
/* ====================================================================
|
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
|
contributor license agreements. See the NOTICE file distributed with
|
|
this work for additional information regarding copyright ownership.
|
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
|
(the "License"); you may not use this file except in compliance with
|
|
the License. You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
==================================================================== */
|
|
|
|
|
|
package org.apache.poi.util;
|
|
|
|
import java.util.*;
|
|
|
|
/**
|
|
* A logger interface that strives to make it as easy as possible for
|
|
* developers to write log calls, while simultaneously making those
|
|
* calls as cheap as possible by performing lazy evaluation of the log
|
|
* message.<p>
|
|
*
|
|
* @author Marc Johnson (mjohnson at apache dot org)
|
|
* @author Glen Stampoultzis (glens at apache.org)
|
|
* @author Nicola Ken Barozzi (nicolaken at apache.org)
|
|
*/
|
|
|
|
public abstract class POILogger
|
|
{
|
|
|
|
public static final int DEBUG = 1;
|
|
public static final int INFO = 3;
|
|
public static final int WARN = 5;
|
|
public static final int ERROR = 7;
|
|
public static final int FATAL = 9;
|
|
|
|
/**
|
|
* package scope so it cannot be instantiated outside of the util
|
|
* package. You need a POILogger? Go to the POILogFactory for one
|
|
*
|
|
*/
|
|
POILogger()
|
|
{}
|
|
|
|
abstract public void initialize(final String cat);
|
|
|
|
/**
|
|
* Log a message
|
|
*
|
|
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL
|
|
* @param obj1 The object to log. This is converted to a string.
|
|
*/
|
|
abstract public void log(final int level, final Object obj1);
|
|
|
|
/**
|
|
* Log a message
|
|
*
|
|
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL
|
|
* @param obj1 The object to log. This is converted to a string.
|
|
* @param exception An exception to be logged
|
|
*/
|
|
abstract public void log(final int level, final Object obj1,
|
|
final Throwable exception);
|
|
|
|
|
|
/**
|
|
* Check if a logger is enabled to log at the specified level
|
|
*
|
|
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL
|
|
*/
|
|
abstract public boolean check(final int level);
|
|
|
|
/**
|
|
* Log a message. Lazily appends Object parameters together.
|
|
*
|
|
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL
|
|
* @param obj1 first object to place in the message
|
|
* @param obj2 second object to place in the message
|
|
*/
|
|
|
|
/**
|
|
* Log a message. Lazily appends Object parameters together.
|
|
*
|
|
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL
|
|
* @param obj1 first object to place in the message
|
|
* @param obj2 second object to place in the message
|
|
*/
|
|
|
|
public void log(final int level, final Object obj1, final Object obj2)
|
|
{
|
|
if (check(level))
|
|
{
|
|
log(level, new StringBuffer(32).append(obj1).append(obj2));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Log a message. Lazily appends Object parameters together.
|
|
*
|
|
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL
|
|
* @param obj1 first Object to place in the message
|
|
* @param obj2 second Object to place in the message
|
|
* @param obj3 third Object to place in the message
|
|
*/
|
|
|
|
public void log(final int level, final Object obj1, final Object obj2,
|
|
final Object obj3)
|
|
{
|
|
|
|
|
|
if (check(level))
|
|
{
|
|
log(level,
|
|
new StringBuffer(48).append(obj1).append(obj2)
|
|
.append(obj3));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Log a message. Lazily appends Object parameters together.
|
|
*
|
|
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL
|
|
* @param obj1 first Object to place in the message
|
|
* @param obj2 second Object to place in the message
|
|
* @param obj3 third Object to place in the message
|
|
* @param obj4 fourth Object to place in the message
|
|
*/
|
|
|
|
public void log(final int level, final Object obj1, final Object obj2,
|
|
final Object obj3, final Object obj4)
|
|
{
|
|
|
|
|
|
if (check(level))
|
|
{
|
|
log(level,
|
|
new StringBuffer(64).append(obj1).append(obj2)
|
|
.append(obj3).append(obj4));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Log a message. Lazily appends Object parameters together.
|
|
*
|
|
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL
|
|
* @param obj1 first Object to place in the message
|
|
* @param obj2 second Object to place in the message
|
|
* @param obj3 third Object to place in the message
|
|
* @param obj4 fourth Object to place in the message
|
|
* @param obj5 fifth Object to place in the message
|
|
*/
|
|
|
|
public void log(final int level, final Object obj1, final Object obj2,
|
|
final Object obj3, final Object obj4, final Object obj5)
|
|
{
|
|
|
|
|
|
if (check(level))
|
|
{
|
|
log(level,
|
|
new StringBuffer(80).append(obj1).append(obj2)
|
|
.append(obj3).append(obj4).append(obj5));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Log a message. Lazily appends Object parameters together.
|
|
*
|
|
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL
|
|
* @param obj1 first Object to place in the message
|
|
* @param obj2 second Object to place in the message
|
|
* @param obj3 third Object to place in the message
|
|
* @param obj4 fourth Object to place in the message
|
|
* @param obj5 fifth Object to place in the message
|
|
* @param obj6 sixth Object to place in the message
|
|
*/
|
|
|
|
public void log(final int level, final Object obj1, final Object obj2,
|
|
final Object obj3, final Object obj4, final Object obj5,
|
|
final Object obj6)
|
|
{
|
|
|
|
|
|
if (check(level))
|
|
{
|
|
log(level ,
|
|
new StringBuffer(96).append(obj1).append(obj2)
|
|
.append(obj3).append(obj4).append(obj5).append(obj6));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Log a message. Lazily appends Object parameters together.
|
|
*
|
|
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL
|
|
* @param obj1 first Object to place in the message
|
|
* @param obj2 second Object to place in the message
|
|
* @param obj3 third Object to place in the message
|
|
* @param obj4 fourth Object to place in the message
|
|
* @param obj5 fifth Object to place in the message
|
|
* @param obj6 sixth Object to place in the message
|
|
* @param obj7 seventh Object to place in the message
|
|
*/
|
|
|
|
public void log(final int level, final Object obj1, final Object obj2,
|
|
final Object obj3, final Object obj4, final Object obj5,
|
|
final Object obj6, final Object obj7)
|
|
{
|
|
|
|
|
|
if (check(level))
|
|
{
|
|
log(level,
|
|
new StringBuffer(112).append(obj1).append(obj2)
|
|
.append(obj3).append(obj4).append(obj5).append(obj6)
|
|
.append(obj7));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Log a message. Lazily appends Object parameters together.
|
|
*
|
|
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL
|
|
* @param obj1 first Object to place in the message
|
|
* @param obj2 second Object to place in the message
|
|
* @param obj3 third Object to place in the message
|
|
* @param obj4 fourth Object to place in the message
|
|
* @param obj5 fifth Object to place in the message
|
|
* @param obj6 sixth Object to place in the message
|
|
* @param obj7 seventh Object to place in the message
|
|
* @param obj8 eighth Object to place in the message
|
|
*/
|
|
|
|
public void log(final int level, final Object obj1, final Object obj2,
|
|
final Object obj3, final Object obj4, final Object obj5,
|
|
final Object obj6, final Object obj7, final Object obj8)
|
|
{
|
|
|
|
|
|
if (check(level))
|
|
{
|
|
log(level,
|
|
new StringBuffer(128).append(obj1).append(obj2)
|
|
.append(obj3).append(obj4).append(obj5).append(obj6)
|
|
.append(obj7).append(obj8));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Log an exception, without a message
|
|
*
|
|
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL
|
|
* @param exception An exception to be logged
|
|
*/
|
|
|
|
public void log(final int level, final Throwable exception)
|
|
{
|
|
log(level, null, exception);
|
|
}
|
|
|
|
/**
|
|
* Log a message. Lazily appends Object parameters together.
|
|
*
|
|
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL
|
|
* @param obj1 first Object to place in the message
|
|
* @param obj2 second Object to place in the message
|
|
* @param exception An exception to be logged
|
|
*/
|
|
|
|
public void log(final int level, final Object obj1, final Object obj2,
|
|
final Throwable exception)
|
|
{
|
|
|
|
|
|
if (check(level))
|
|
{
|
|
log(level, new StringBuffer(32).append(obj1).append(obj2),
|
|
exception);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Log a message. Lazily appends Object parameters together.
|
|
*
|
|
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL
|
|
* @param obj1 first Object to place in the message
|
|
* @param obj2 second Object to place in the message
|
|
* @param obj3 third object to place in the message
|
|
* @param exception An error message to be logged
|
|
*/
|
|
|
|
public void log(final int level, final Object obj1, final Object obj2,
|
|
final Object obj3, final Throwable exception)
|
|
{
|
|
|
|
|
|
if (check(level))
|
|
{
|
|
log(level, new StringBuffer(48).append(obj1).append(obj2)
|
|
.append(obj3), exception);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Log a message. Lazily appends Object parameters together.
|
|
*
|
|
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL
|
|
* @param obj1 first Object to place in the message
|
|
* @param obj2 second Object to place in the message
|
|
* @param obj3 third object to place in the message
|
|
* @param obj4 fourth object to place in the message
|
|
* @param exception An exception to be logged
|
|
*/
|
|
|
|
public void log(final int level, final Object obj1, final Object obj2,
|
|
final Object obj3, final Object obj4,
|
|
final Throwable exception)
|
|
{
|
|
|
|
|
|
if (check(level))
|
|
{
|
|
log(level, new StringBuffer(64).append(obj1).append(obj2)
|
|
.append(obj3).append(obj4), exception);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Log a message. Lazily appends Object parameters together.
|
|
*
|
|
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL
|
|
* @param obj1 first Object to place in the message
|
|
* @param obj2 second Object to place in the message
|
|
* @param obj3 third object to place in the message
|
|
* @param obj4 fourth object to place in the message
|
|
* @param obj5 fifth object to place in the message
|
|
* @param exception An exception to be logged
|
|
*/
|
|
|
|
public void log(final int level, final Object obj1, final Object obj2,
|
|
final Object obj3, final Object obj4, final Object obj5,
|
|
final Throwable exception)
|
|
{
|
|
|
|
|
|
if (check(level))
|
|
{
|
|
log(level, new StringBuffer(80).append(obj1).append(obj2)
|
|
.append(obj3).append(obj4).append(obj5), exception);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Log a message. Lazily appends Object parameters together.
|
|
*
|
|
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL
|
|
* @param obj1 first Object to place in the message
|
|
* @param obj2 second Object to place in the message
|
|
* @param obj3 third object to place in the message
|
|
* @param obj4 fourth object to place in the message
|
|
* @param obj5 fifth object to place in the message
|
|
* @param obj6 sixth object to place in the message
|
|
* @param exception An exception to be logged
|
|
*/
|
|
|
|
public void log(final int level, final Object obj1, final Object obj2,
|
|
final Object obj3, final Object obj4, final Object obj5,
|
|
final Object obj6, final Throwable exception)
|
|
{
|
|
|
|
|
|
if (check(level))
|
|
{
|
|
log(level , new StringBuffer(96).append(obj1)
|
|
.append(obj2).append(obj3).append(obj4).append(obj5)
|
|
.append(obj6), exception);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Log a message. Lazily appends Object parameters together.
|
|
*
|
|
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL
|
|
* @param obj1 first Object to place in the message
|
|
* @param obj2 second Object to place in the message
|
|
* @param obj3 third object to place in the message
|
|
* @param obj4 fourth object to place in the message
|
|
* @param obj5 fifth object to place in the message
|
|
* @param obj6 sixth object to place in the message
|
|
* @param obj7 seventh object to place in the message
|
|
* @param exception An exception to be logged
|
|
*/
|
|
|
|
public void log(final int level, final Object obj1, final Object obj2,
|
|
final Object obj3, final Object obj4, final Object obj5,
|
|
final Object obj6, final Object obj7,
|
|
final Throwable exception)
|
|
{
|
|
|
|
|
|
if (check(level))
|
|
{
|
|
log(level, new StringBuffer(112).append(obj1).append(obj2)
|
|
.append(obj3).append(obj4).append(obj5).append(obj6)
|
|
.append(obj7), exception);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Log a message. Lazily appends Object parameters together.
|
|
*
|
|
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL
|
|
* @param obj1 first Object to place in the message
|
|
* @param obj2 second Object to place in the message
|
|
* @param obj3 third object to place in the message
|
|
* @param obj4 fourth object to place in the message
|
|
* @param obj5 fifth object to place in the message
|
|
* @param obj6 sixth object to place in the message
|
|
* @param obj7 seventh object to place in the message
|
|
* @param obj8 eighth object to place in the message
|
|
* @param exception An exception to be logged
|
|
*/
|
|
|
|
public void log(final int level, final Object obj1, final Object obj2,
|
|
final Object obj3, final Object obj4, final Object obj5,
|
|
final Object obj6, final Object obj7, final Object obj8,
|
|
final Throwable exception)
|
|
{
|
|
|
|
|
|
if (check(level))
|
|
{
|
|
log(level, new StringBuffer(128).append(obj1).append(obj2)
|
|
.append(obj3).append(obj4).append(obj5).append(obj6)
|
|
.append(obj7).append(obj8), exception);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Logs a formated message. The message itself may contain %
|
|
* characters as place holders. This routine will attempt to match
|
|
* the placeholder by looking at the type of parameter passed to
|
|
* obj1.<p>
|
|
*
|
|
* If the parameter is an array, it traverses the array first and
|
|
* matches parameters sequentially against the array items.
|
|
* Otherwise the parameters after <code>message</code> are matched
|
|
* in order.<p>
|
|
*
|
|
* If the place holder matches against a number it is printed as a
|
|
* whole number. This can be overridden by specifying a precision
|
|
* in the form %n.m where n is the padding for the whole part and
|
|
* m is the number of decimal places to display. n can be excluded
|
|
* if desired. n and m may not be more than 9.<p>
|
|
*
|
|
* If the last parameter (after flattening) is a Throwable it is
|
|
* logged specially.
|
|
*
|
|
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL
|
|
* @param message The message to log.
|
|
* @param obj1 The first object to match against.
|
|
*/
|
|
|
|
public void logFormatted(final int level, final String message,
|
|
final Object obj1)
|
|
{
|
|
commonLogFormatted(level, message, new Object[]
|
|
{
|
|
obj1
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Logs a formated message. The message itself may contain %
|
|
* characters as place holders. This routine will attempt to match
|
|
* the placeholder by looking at the type of parameter passed to
|
|
* obj1.<p>
|
|
*
|
|
* If the parameter is an array, it traverses the array first and
|
|
* matches parameters sequentially against the array items.
|
|
* Otherwise the parameters after <code>message</code> are matched
|
|
* in order.<p>
|
|
*
|
|
* If the place holder matches against a number it is printed as a
|
|
* whole number. This can be overridden by specifying a precision
|
|
* in the form %n.m where n is the padding for the whole part and
|
|
* m is the number of decimal places to display. n can be excluded
|
|
* if desired. n and m may not be more than 9.<p>
|
|
*
|
|
* If the last parameter (after flattening) is a Throwable it is
|
|
* logged specially.
|
|
*
|
|
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL
|
|
* @param message The message to log.
|
|
* @param obj1 The first object to match against.
|
|
* @param obj2 The second object to match against.
|
|
*/
|
|
|
|
public void logFormatted(final int level, final String message,
|
|
final Object obj1, final Object obj2)
|
|
{
|
|
commonLogFormatted(level, message, new Object[]
|
|
{
|
|
obj1, obj2
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Logs a formated message. The message itself may contain %
|
|
* characters as place holders. This routine will attempt to match
|
|
* the placeholder by looking at the type of parameter passed to
|
|
* obj1.<p>
|
|
*
|
|
* If the parameter is an array, it traverses the array first and
|
|
* matches parameters sequentially against the array items.
|
|
* Otherwise the parameters after <code>message</code> are matched
|
|
* in order.<p>
|
|
*
|
|
* If the place holder matches against a number it is printed as a
|
|
* whole number. This can be overridden by specifying a precision
|
|
* in the form %n.m where n is the padding for the whole part and
|
|
* m is the number of decimal places to display. n can be excluded
|
|
* if desired. n and m may not be more than 9.<p>
|
|
*
|
|
* If the last parameter (after flattening) is a Throwable it is
|
|
* logged specially.
|
|
*
|
|
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL
|
|
* @param message The message to log.
|
|
* @param obj1 The first object to match against.
|
|
* @param obj2 The second object to match against.
|
|
* @param obj3 The third object to match against.
|
|
*/
|
|
|
|
public void logFormatted(final int level, final String message,
|
|
final Object obj1, final Object obj2,
|
|
final Object obj3)
|
|
{
|
|
commonLogFormatted(level, message, new Object[]
|
|
{
|
|
obj1, obj2, obj3
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Logs a formated message. The message itself may contain %
|
|
* characters as place holders. This routine will attempt to match
|
|
* the placeholder by looking at the type of parameter passed to
|
|
* obj1.<p>
|
|
*
|
|
* If the parameter is an array, it traverses the array first and
|
|
* matches parameters sequentially against the array items.
|
|
* Otherwise the parameters after <code>message</code> are matched
|
|
* in order.<p>
|
|
*
|
|
* If the place holder matches against a number it is printed as a
|
|
* whole number. This can be overridden by specifying a precision
|
|
* in the form %n.m where n is the padding for the whole part and
|
|
* m is the number of decimal places to display. n can be excluded
|
|
* if desired. n and m may not be more than 9.<p>
|
|
*
|
|
* If the last parameter (after flattening) is a Throwable it is
|
|
* logged specially.
|
|
*
|
|
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL
|
|
* @param message The message to log.
|
|
* @param obj1 The first object to match against.
|
|
* @param obj2 The second object to match against.
|
|
* @param obj3 The third object to match against.
|
|
* @param obj4 The forth object to match against.
|
|
*/
|
|
|
|
public void logFormatted(final int level, final String message,
|
|
final Object obj1, final Object obj2,
|
|
final Object obj3, final Object obj4)
|
|
{
|
|
commonLogFormatted(level, message, new Object[]
|
|
{
|
|
obj1, obj2, obj3, obj4
|
|
});
|
|
}
|
|
|
|
private void commonLogFormatted(final int level, final String message,
|
|
final Object [] unflatParams)
|
|
{
|
|
|
|
|
|
if (check(level))
|
|
{
|
|
Object[] params = flattenArrays(unflatParams);
|
|
|
|
if (params[ params.length - 1 ] instanceof Throwable)
|
|
{
|
|
log(level, StringUtil.format(message, params),
|
|
( Throwable ) params[ params.length - 1 ]);
|
|
}
|
|
else
|
|
{
|
|
log(level, StringUtil.format(message, params));
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Flattens any contained objects. Only tranverses one level deep.
|
|
*/
|
|
|
|
private Object [] flattenArrays(final Object [] objects)
|
|
{
|
|
List results = new ArrayList();
|
|
|
|
for (int i = 0; i < objects.length; i++)
|
|
{
|
|
results.addAll(objectToObjectArray(objects[ i ]));
|
|
}
|
|
return ( Object [] ) results.toArray(new Object[ results.size() ]);
|
|
}
|
|
|
|
private List objectToObjectArray(Object object)
|
|
{
|
|
List results = new ArrayList();
|
|
|
|
if (object instanceof byte [])
|
|
{
|
|
byte[] array = ( byte [] ) object;
|
|
|
|
for (int j = 0; j < array.length; j++)
|
|
{
|
|
results.add(new Byte(array[ j ]));
|
|
}
|
|
}
|
|
if (object instanceof char [])
|
|
{
|
|
char[] array = ( char [] ) object;
|
|
|
|
for (int j = 0; j < array.length; j++)
|
|
{
|
|
results.add(new Character(array[ j ]));
|
|
}
|
|
}
|
|
else if (object instanceof short [])
|
|
{
|
|
short[] array = ( short [] ) object;
|
|
|
|
for (int j = 0; j < array.length; j++)
|
|
{
|
|
results.add(new Short(array[ j ]));
|
|
}
|
|
}
|
|
else if (object instanceof int [])
|
|
{
|
|
int[] array = ( int [] ) object;
|
|
|
|
for (int j = 0; j < array.length; j++)
|
|
{
|
|
results.add(new Integer(array[ j ]));
|
|
}
|
|
}
|
|
else if (object instanceof long [])
|
|
{
|
|
long[] array = ( long [] ) object;
|
|
|
|
for (int j = 0; j < array.length; j++)
|
|
{
|
|
results.add(new Long(array[ j ]));
|
|
}
|
|
}
|
|
else if (object instanceof float [])
|
|
{
|
|
float[] array = ( float [] ) object;
|
|
|
|
for (int j = 0; j < array.length; j++)
|
|
{
|
|
results.add(new Float(array[ j ]));
|
|
}
|
|
}
|
|
else if (object instanceof double [])
|
|
{
|
|
double[] array = ( double [] ) object;
|
|
|
|
for (int j = 0; j < array.length; j++)
|
|
{
|
|
results.add(new Double(array[ j ]));
|
|
}
|
|
}
|
|
else if (object instanceof Object [])
|
|
{
|
|
Object[] array = ( Object [] ) object;
|
|
|
|
for (int j = 0; j < array.length; j++)
|
|
{
|
|
results.add(array[ j ]);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
results.add(object);
|
|
}
|
|
return results;
|
|
}
|
|
|
|
} // end package scope abstract class POILogger
|
|
|