fr.ifremer.isisfish.logging
Class LogLevelUtil

java.lang.Object
  extended by fr.ifremer.isisfish.logging.LogLevelUtil

public class LogLevelUtil
extends java.lang.Object

This classes contains some usefull methods to perform actions on set of LogLevel. To make performant filtering operations on a lots of LogRecord, we use as representation for set of LogLevel an integer as the sum of the LogLevel.mask() values.

The 0 value correspond to all levels and is a violating the rule (but how to make a search with no level ?)

to test if a set of LogLevel contains a given LogLevel use contains(int, int)

to add a level in a set of LogLevel use addToSet(int, int)

to remove a level in a set of LogLevel use removeFromSet(int, int)

to obtain all levels contained in a set of LogLevel use getLogLevels(int)

Author:
chemit
See Also:
LogLevel

Constructor Summary
LogLevelUtil()
           
 
Method Summary
static int addToSet(int ordinal, int setOflevels)
          add a LogLevel to a set
static boolean contains(int ordinal, int levels)
          Using a performant algorithm to know if a LogLevel is contained in a list of levels using his severity.
static int createSet(int firstOrdinal, int... ordinals)
          Compute the sum of levels toInit() value for all given levels (given with their ordinal value).
static int createSet(LogLevel firstLevel, LogLevel... levels)
           
static LogLevel[] getLogLevels(int levels)
           
static int removeFromSet(int ordinal, int setOfLevels)
          remove a LogLevel from a set
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LogLevelUtil

public LogLevelUtil()
Method Detail

contains

public static boolean contains(int ordinal,
                               int levels)
Using a performant algorithm to know if a LogLevel is contained in a list of levels using his severity.

Parameters:
ordinal - the ordinal of the level
levels - the sums of levels
Returns:
true if this level is in levels given.

getLogLevels

public static LogLevel[] getLogLevels(int levels)

createSet

public static int createSet(int firstOrdinal,
                            int... ordinals)
Compute the sum of levels toInit() value for all given levels (given with their ordinal value).

This value will be used for a performant filter process.

Parameters:
firstOrdinal - the first level of levels to use
ordinals - the level of levels to use
Returns:
the sum of the mask() value of each level found, 0 if

createSet

public static int createSet(LogLevel firstLevel,
                            LogLevel... levels)

addToSet

public static int addToSet(int ordinal,
                           int setOflevels)
add a LogLevel to a set

Parameters:
ordinal - the ordinal of the level to add
setOflevels - the sum of mask() of some LogLevel
Returns:
the new sum (if LogLevel was already in the sum the levels levels)

removeFromSet

public static int removeFromSet(int ordinal,
                                int setOfLevels)
remove a LogLevel from a set

Parameters:
ordinal - the ordinal of the level to remove
setOfLevels - the sum of mask() of some LogLevel
Returns:
the new sum (if LogLevel was not in the sum the levels levels)


Copyright © 1999-2010 CodeLutin. All Rights Reserved.