You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-dev@logging.apache.org by ca...@apache.org on 2005/06/27 09:03:34 UTC

cvs commit: logging-log4cxx/include/log4cxx/filter andfilter.h denyallfilter.h expressionfilter.h locationinfofilter.h mapfilter.h propertyfilter.h reflectionfilter.h

carnold     2005/06/27 00:03:34

  Modified:    include/log4cxx/filter andfilter.h denyallfilter.h
                        expressionfilter.h locationinfofilter.h mapfilter.h
                        propertyfilter.h
  Removed:     include/log4cxx/filter reflectionfilter.h
  Log:
  LOG4CXX-52: log4j RFA: Convert log4cxx/filter/*.h to C++ from Java
  
  Revision  Changes    Path
  1.2       +53 -58    logging-log4cxx/include/log4cxx/filter/andfilter.h
  
  Index: andfilter.h
  ===================================================================
  RCS file: /home/cvs/logging-log4cxx/include/log4cxx/filter/andfilter.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- andfilter.h	1 Jun 2005 19:23:14 -0000	1.1
  +++ andfilter.h	27 Jun 2005 07:03:34 -0000	1.2
  @@ -1,12 +1,12 @@
   /*
  - * Copyright 1999,2004 The Apache Software Foundation.
  - * 
  + * Copyright 1999,2005 The Apache Software Foundation.
  + *
    * Licensed 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.
  @@ -14,25 +14,29 @@
    * limitations under the License.
    */
   
  -package org.apache.log4j.filter;
  +#ifndef _LOG4CXX_FILTER_ANDFILTER_H
  +#define _LOG4CXX_FILTER_ANDFILTER_H
   
  -import org.apache.log4j.spi.Filter;
  -import org.apache.log4j.spi.LoggingEvent;
  +#include <log4cxx/spi/filter.h>
   
  +namespace log4cxx
  +{
  +    namespace filter
  +    {
   
   /**
    * A filter that 'and's the results of any number of contained filters together.
  - * 
  + *
    * For the filter to process events, all contained filters must return Filter.ACCEPT.
  - * 
  + *
    * If the contained filters do not return Filter.ACCEPT, Filter.NEUTRAL is returned.
  - * 
  + *
    * If acceptOnMatch is set to true, Filter.ACCEPT is returned.
    * If acceptOnMatch is set to false, Filter.DENY is returned.
  - * 
  + *
    * Here is an example config that will accept only events that contain BOTH
    * a DEBUG level AND 'test' in the message:
  - * 
  + *
    *<appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
    * <filter class="org.apache.log4j.filter.AndFilter">
    *  <filter class="org.apache.log4j.filter.LevelMatchFilter">
  @@ -48,64 +52,55 @@
    * <filter class="org.apache.log4j.filter.DenyAllFilter"/>
    *<layout class="org.apache.log4j.SimpleLayout"/>
    *</appender>
  - * 
  - * To accept all events EXCEPT those events that contain a 
  - * DEBUG level and 'test' in the message: 
  + *
  + * To accept all events EXCEPT those events that contain a
  + * DEBUG level and 'test' in the message:
    * change the AndFilter's acceptOnMatch param to false and remove the DenyAllFilter
  - * 
  - * NOTE: If you are defining a filter that is only relying on logging event content 
  + *
  + * NOTE: If you are defining a filter that is only relying on logging event content
    * (no external or filter-managed state), you could opt instead
    * to use an ExpressionFilter with one of the following expressions:
  - * 
  + *
    * LEVEL == DEBUG && MSG ~= 'test'
    * or
    * ! ( LEVEL == DEBUG && MSG ~= 'test' )
  - *  
  + *
    * @author Scott Deboy sdeboy@apache.org
    */
  -public class AndFilter extends Filter {
  -  Filter headFilter = null;
  -  Filter tailFilter = null;
  -  boolean acceptOnMatch = true;
  -  
  -  public void activateOptions() {
  -  }
  -
  -  public void addFilter(Filter filter) {
  -    System.out.println("add"+filter);
  -    if (headFilter == null) {
  -      headFilter = filter;
  -      tailFilter = filter;
  -    } else {
  -      tailFilter.setNext(filter);
  -    }
  -  }
  -  
  -  public void setAcceptOnMatch(boolean acceptOnMatch) {
  -    this.acceptOnMatch = acceptOnMatch;
  -  }
  +        class LOG4CXX_EXPORT AndFilter:public log4cxx::spi::Filter
  +        {
  +          private:
  +            log4cxx::spi::FilterPtr headFilter;
  +            log4cxx::spi::FilterPtr tailFilter;
  +            bool acceptOnMatch;
  +                 AndFilter(const AndFilter &);
  +                  AndFilter & operator=(const AndFilter &);
  +
  +
  +          public:
  +                  DECLARE_LOG4CXX_OBJECT(AndFilter)
  +                  BEGIN_LOG4CXX_CAST_MAP()
  +                  LOG4CXX_CAST_ENTRY(log4cxx::spi::Filter)
  +                  END_LOG4CXX_CAST_MAP()
  +
  +                  AndFilter();
  +
  +            void addFilter(const log4cxx::spi::FilterPtr & filter);
  +
  +            void setAcceptOnMatch(bool acceptOnMatch);
  +
     /**
  -   * If this event does not already contain location information, 
  +   * If this event does not already contain location information,
      * evaluate the event against the expression.
  -   * 
  -   * If the expression evaluates to true, generate a LocationInfo instance 
  +   *
  +   * If the expression evaluates to true, generate a LocationInfo instance
      * by creating an exception and set this LocationInfo on the event.
  -   * 
  +   *
      * Returns {@link Filter#NEUTRAL}
      */
  -  public int decide(LoggingEvent event) {
  -    boolean accepted = true;
  -    Filter f = headFilter;
  -    while (f != null) {
  -      accepted = accepted && (Filter.ACCEPT == f.decide(event));
  -      f = f.getNext();
  -    }
  -    if (accepted) {
  -      if(acceptOnMatch) {
  -        return Filter.ACCEPT;
  -      }
  -       return Filter.DENY;
  +            FilterDecision decide(const spi::LoggingEventPtr & event) const;
  +        };
  +
       }
  -    return Filter.NEUTRAL;
  -  }
   }
  +#endif
  
  
  
  1.2       +2 -2      logging-log4cxx/include/log4cxx/filter/denyallfilter.h
  
  Index: denyallfilter.h
  ===================================================================
  RCS file: /home/cvs/logging-log4cxx/include/log4cxx/filter/denyallfilter.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- denyallfilter.h	1 Jun 2005 19:23:14 -0000	1.1
  +++ denyallfilter.h	27 Jun 2005 07:03:34 -0000	1.2
  @@ -30,8 +30,6 @@
                   filtering behaviour to a "deny all unless instructed otherwise"
                   behaviour.
                   */
  -                class DenyAllFilter;
  -                typedef helpers::ObjectPtrT<DenyAllFilter> DenyAllFilterPtr;
   
                   class LOG4CXX_EXPORT DenyAllFilter : public spi::Filter
                   {
  @@ -55,6 +53,8 @@
                           FilterDecision decide(const spi::LoggingEventPtr& event) const
                                   { return spi::Filter::DENY; }
                   }; // class DenyAllFilter
  +
  +                typedef helpers::ObjectPtrT<DenyAllFilter> DenyAllFilterPtr;
           }  // namespace filter
   } // namespace log4cxx
   
  
  
  
  1.2       +62 -55    logging-log4cxx/include/log4cxx/filter/expressionfilter.h
  
  Index: expressionfilter.h
  ===================================================================
  RCS file: /home/cvs/logging-log4cxx/include/log4cxx/filter/expressionfilter.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- expressionfilter.h	1 Jun 2005 19:23:14 -0000	1.1
  +++ expressionfilter.h	27 Jun 2005 07:03:34 -0000	1.2
  @@ -1,12 +1,12 @@
   /*
  - * Copyright 1999,2004 The Apache Software Foundation.
  - * 
  + * Copyright 1999,2005 The Apache Software Foundation.
  + *
    * Licensed 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.
  @@ -14,26 +14,36 @@
    * limitations under the License.
    */
   
  -package org.apache.log4j.filter;
  +#ifndef _LOG4CXX_FILTER_EXPRESSIONFILTER_H
  +#define _LOG4CXX_FILTER_EXPRESSIONFILTER_H
  +
  +#include <log4cxx/spi/filter.h>
  +
  +namespace log4cxx
  +{
  +    namespace rule
  +    {
  +        class Rule;
  +        typedef helpers::ObjectPtrT < Rule > RulePtr;
  +    }
  +
   
  -import org.apache.log4j.rule.ExpressionRule;
  -import org.apache.log4j.rule.Rule;
  -import org.apache.log4j.spi.Filter;
  -import org.apache.log4j.spi.LoggingEvent;
  +    namespace filter
  +    {
   
   
   /**
  - *A filter supporting complex expressions - supports both infix and postfix 
  - * expressions (infix expressions must first be converted to postfix prior 
  + *A filter supporting complex expressions - supports both infix and postfix
  + * expressions (infix expressions must first be converted to postfix prior
    * to processing).
    *
  - * <p>See <code>org.apache.log4j.chainsaw.LoggingEventFieldResolver.java</code> 
  + * <p>See <code>org.apache.log4j.chainsaw.LoggingEventFieldResolver.java</code>
    * for the correct names for logging event fields used when building expressions.
    *
    * <p>See <org.apache.log4j.chainsaw.rule</code> package for a list of available
    * rules which can be applied using the expression syntax.
    *
  - * <p>See <code>org.apache.log4j.chainsaw.RuleFactory</code> for the symbols 
  + * <p>See <code>org.apache.log4j.chainsaw.RuleFactory</code> for the symbols
    * used to activate the corresponding rules.
    *
    *NOTE:  Grouping using parentheses is supported - all tokens must be separated by spaces, and
  @@ -42,10 +52,10 @@
    *Example:
    *
    *In order to build a filter that displays all messages with infomsg-45 or infomsg-44 in the message,
  - *as well as all messages with a level of WARN or higher, build an expression using 
  - *the LikeRule (supports ORO-based regular expressions) and the InequalityRule. 
  + *as well as all messages with a level of WARN or higher, build an expression using
  + *the LikeRule (supports ORO-based regular expressions) and the InequalityRule.
    * <b> ( MSG LIKE infomsg-4[4,5] ) && ( LEVEL >= WARN ) </b>
  - *  
  + *
    *Three options are required:
    *  <b>Expression</b> - the expression to match
    *  <b>ConvertInFixToPostFix</b> - convert from infix to posfix (default true)
  @@ -64,48 +74,45 @@
    *
    * @author Scott Deboy sdeboy@apache.org
    */
  -public class ExpressionFilter extends Filter {
  -  boolean acceptOnMatch = true;
  -  boolean convertInFixToPostFix = true;
  -  String expression;
  -  Rule expressionRule;
  -
  -  public void activateOptions() {
  -    expressionRule =
  -      ExpressionRule.getRule(expression, !convertInFixToPostFix);
  -  }
  -
  -  public void setExpression(String expression) {
  -    this.expression = expression;
  -  }
  -
  -  public String getExpression() {
  -    return expression;
  -  }
  -
  -  public void setConvertInFixToPostFix(boolean convertInFixToPostFix) {
  -    this.convertInFixToPostFix = convertInFixToPostFix;
  -  }
  -
  -  public boolean getConvertInFixToPostFix() {
  -    return convertInFixToPostFix;
  -  }
  -
  -  public void setAcceptOnMatch(boolean acceptOnMatch) {
  -    this.acceptOnMatch = acceptOnMatch;
  -  }
  -
  -  public boolean getAcceptOnMatch() {
  -    return acceptOnMatch;
  -  }
  +        class LOG4CXX_EXPORT ExpressionFilter:public log4cxx::spi::Filter
  +        {
  +          private:
  +            bool acceptOnMatch;
  +            bool convertInFixToPostFix;
  +            LogString expression;
  +                      log4cxx::rule::RulePtr expressionRule;
  +                      ExpressionFilter(const ExpressionFilter &);
  +                  ExpressionFilter & operator=(const ExpressionFilter &);
  +
  +          public:
  +                  DECLARE_LOG4CXX_OBJECT(ExpressionFilter)
  +                  BEGIN_LOG4CXX_CAST_MAP()
  +                  LOG4CXX_CAST_ENTRY(log4cxx::spi::Filter)
  +                  END_LOG4CXX_CAST_MAP()
  +
  +
  +                  ExpressionFilter();
  +
  +            void activateOptions(log4cxx::helpers::Pool & p);
  +
  +            void setExpression(const LogString & expression);
  +
  +            LogString getExpression() const;
  +
  +            void setConvertInFixToPostFix(bool convertInFixToPostFix);
  +
  +            bool getConvertInFixToPostFix() const;
  +
  +            void setAcceptOnMatch(bool acceptOnMatch);
  +
  +            bool getAcceptOnMatch() const;
   
     /**
        Returns {@link Filter#NEUTRAL} is there is no string match.
      */
  -  public int decide(LoggingEvent event) {
  -    if (expressionRule.evaluate(event)) {
  -      return (acceptOnMatch?Filter.ACCEPT:Filter.DENY);
  +            FilterDecision decide(const spi::LoggingEventPtr & event) const;
  +        };
       }
  -    return Filter.NEUTRAL;
  -  }
   }
  +
  +#endif
  
  
  
  1.3       +56 -55    logging-log4cxx/include/log4cxx/filter/locationinfofilter.h
  
  Index: locationinfofilter.h
  ===================================================================
  RCS file: /home/cvs/logging-log4cxx/include/log4cxx/filter/locationinfofilter.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- locationinfofilter.h	13 Jun 2005 22:00:04 -0000	1.2
  +++ locationinfofilter.h	27 Jun 2005 07:03:34 -0000	1.3
  @@ -1,85 +1,86 @@
   /*
  - * Copyright 1999,2004 The Apache Software Foundation.
  - * 
  + * Copyright 1999,2005 The Apache Software Foundation.
  + *
    * Licensed 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.
    */
  +#ifndef _LOG4CXX_FILTER_LOCATIONINFOFILTER_H
  +#define _LOG4CXX_FILTER_LOCATIONINFOFILTER_H
   
  -package org.apache.log4j.filter;
  -
  -import org.apache.log4j.rule.ExpressionRule;
  -import org.apache.log4j.rule.Rule;
  -import org.apache.log4j.spi.Filter;
  -import org.apache.log4j.spi.LoggingEvent;
  -import org.apache.log4j.spi.location.LocationInfo;
  +#include <log4cxx/spi/filter.h>
   
  +namespace log4cxx
  +{
  +    namespace rule
  +    {
  +        class ExpressionRule;
  +        class Rule;
  +        typedef helpers::ObjectPtrT < Rule > RulePtr;
  +        typedef helpers::ObjectPtrT < ExpressionRule > ExpressionRulePtr;
  +    }
   
  +    namespace filter
  +    {
   /**
  - * Location information is usually specified at the appender level - all events associated 
  + * Location information is usually specified at the appender level - all events associated
    * with an appender either create and parse stack traces or they do not.  This is
    * an expensive operation and in some cases not needed for all events associated with
    * an appender.
  - * 
  + *
    * This filter creates event-level location information only if the provided expression evaluates to true.
  - * 
  + *
    * For information on expression syntax, see org.apache.log4j.rule.ExpressionRule
  - * 
  + *
    * @author Scott Deboy sdeboy@apache.org
    */
  -public class LocationInfoFilter extends Filter {
  -  boolean convertInFixToPostFix = true;
  -  String expression;
  -  Rule expressionRule;
  -  //HACK: Category is the last of the internal layers - pass this in as the class name
  -  //in order for parsing to work correctly
  -  private String className = "org.apache.log4j.Category";
  -
  -  public void activateOptions() {
  -    expressionRule =
  -      ExpressionRule.getRule(expression, !convertInFixToPostFix);
  -  }
  -
  -  public void setExpression(String expression) {
  -    this.expression = expression;
  -  }
  -
  -  public String getExpression() {
  -    return expression;
  -  }
  -
  -  public void setConvertInFixToPostFix(boolean convertInFixToPostFix) {
  -    this.convertInFixToPostFix = convertInFixToPostFix;
  -  }
  -
  -  public boolean getConvertInFixToPostFix() {
  -    return convertInFixToPostFix;
  -  }
  +        class LOG4CXX_EXPORT LocationInfoFilter:public log4cxx::spi::Filter
  +        {
  +            bool convertInFixToPostFix;
  +            LogString expression;
  +                      log4cxx::rule::RulePtr expressionRule;
  +            //HACK: Category is the last of the internal layers - pass this in as the class name
  +            //in order for parsing to work correctly
  +            LogString className;
  +
  +          public:
  +                      DECLARE_LOG4CXX_OBJECT(LocationInfoFilter)
  +                      BEGIN_LOG4CXX_CAST_MAP()
  +                      LOG4CXX_CAST_ENTRY(log4cxx::spi::Filter)
  +                      END_LOG4CXX_CAST_MAP()
  +
  +                      LocationInfoFilter();
  +
  +            void activateOptions(log4cxx::helpers::Pool &);
  +
  +            void setExpression(const LogString & expression);
  +
  +            LogString getExpression() const;
  +
  +            void setConvertInFixToPostFix(bool convertInFixToPostFix);
  +
  +            bool getConvertInFixToPostFix() const;
   
     /**
  -   * If this event does not already contain location information, 
  +   * If this event does not already contain location information,
      * evaluate the event against the expression.
  -   * 
  -   * If the expression evaluates to true, generate a LocationInfo instance 
  +   *
  +   * If the expression evaluates to true, generate a LocationInfo instance
      * by creating an exception and set this LocationInfo on the event.
  -   * 
  +   *
      * Returns {@link Filter#NEUTRAL}
      */
  -  public int decide(LoggingEvent event) {
  -    if (!event.locationInformationExists()) {
  -      if (expressionRule.evaluate(event)) {
  -         Throwable t = new Exception();
  -         event.setLocationInformation(new LocationInfo(t, className));
  -      }
  +            FilterDecision decide(const spi::LoggingEventPtr & event) const;
  +
  +        };
       }
  -    return Filter.NEUTRAL;
  -  }
   }
  +#endif
  
  
  
  1.3       +29 -47    logging-log4cxx/include/log4cxx/filter/mapfilter.h
  
  Index: mapfilter.h
  ===================================================================
  RCS file: /home/cvs/logging-log4cxx/include/log4cxx/filter/mapfilter.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- mapfilter.h	13 Jun 2005 22:00:04 -0000	1.2
  +++ mapfilter.h	27 Jun 2005 07:03:34 -0000	1.3
  @@ -1,61 +1,43 @@
   /*
  - * Copyright 1999,2004 The Apache Software Foundation.
  - * 
  + * Copyright 1999,2005 The Apache Software Foundation.
  + *
    * Licensed 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.
    */
  +#ifndef _LOG4CXX_FILTER_MAPFILTER_H
  +#define _LOG4CXX_FILTER_MAPFILTER_H
   
  -package org.apache.log4j.filter;
  +#include <log4cxx/spi/filter.h>
   
  -import java.util.Hashtable;
  -import java.util.Iterator;
  -import java.util.Map;
  -import org.apache.log4j.spi.Filter;
  -import org.apache.log4j.spi.LoggingEvent;
  -
  -public class MapFilter extends Filter {
  -
  -   /**
  -    * NOTE: This filter modifies logging events by adding properties to the event.
  -    * 
  -    * The object passed in as the event message must implement java.util.Map.
  -   * 
  -   * This filter converts the event message (a Map) into properties on the event.
  -   * 
  -   * If the map holds an entry with a key of "message", the value of the entry is used
  -   * as the rendered message.
  -   * 
  -    * @since 1.3
  -    */
  -   public int decide(LoggingEvent event) {
  -      Map properties = event.getProperties();
  -      Hashtable eventProps = null;
  -      if (properties == null) {
  -         eventProps = new Hashtable();
  -      } else {
  -         eventProps = new Hashtable(properties);
  -      }
  -   
  -      if (event.getMessage() instanceof Map) {
  -         for (Iterator iter = ((Map)event.getMessage()).entrySet().iterator();iter.hasNext();) {
  -        Map.Entry entry = (Map.Entry)iter.next();
  -            if ("message".equalsIgnoreCase(entry.getKey().toString())) {
  -               event.setRenderedMessage(entry.getValue().toString());
  -            } else {
  -               eventProps.put(entry.getKey(), entry.getValue());
  -            }
  -         }
  -         event.setProperties(eventProps);
  -      }
  -      return Filter.NEUTRAL;
  -   }
  +namespace log4cxx
  +{
  +    namespace filter
  +    {
  +
  +
  +        class LOG4CXX_EXPORT MapFilter:public log4cxx::spi::Filter
  +        {
  +          public:
  +            DECLARE_LOG4CXX_OBJECT(MapFilter)
  +            BEGIN_LOG4CXX_CAST_MAP()
  +            LOG4CXX_CAST_ENTRY(log4cxx::spi::Filter)
  +            END_LOG4CXX_CAST_MAP()
  +
  +            MapFilter();
  +
  +
  +            FilterDecision decide(const spi::LoggingEventPtr & event) const;
  +
  +        };
  +    }
   }
  +#endif
  
  
  
  1.3       +42 -50    logging-log4cxx/include/log4cxx/filter/propertyfilter.h
  
  Index: propertyfilter.h
  ===================================================================
  RCS file: /home/cvs/logging-log4cxx/include/log4cxx/filter/propertyfilter.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- propertyfilter.h	13 Jun 2005 22:00:04 -0000	1.2
  +++ propertyfilter.h	27 Jun 2005 07:03:34 -0000	1.3
  @@ -1,12 +1,12 @@
   /*
  - * Copyright 1999,2004 The Apache Software Foundation.
  - * 
  + * Copyright 1999,2005 The Apache Software Foundation.
  + *
    * Licensed 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.
  @@ -14,62 +14,54 @@
    * limitations under the License.
    */
   
  -package org.apache.log4j.filter;
   
  -import java.util.Hashtable;
  -import java.util.Iterator;
  -import java.util.Map;
  -import java.util.StringTokenizer;
  +#ifndef _LOG4CXX_FILTER_PROPERTYFILTER_H
  +#define _LOG4CXX_FILTER_PROPERTYFILTER_H
   
  -import org.apache.log4j.spi.Filter;
  -import org.apache.log4j.spi.LoggingEvent;
  +#include <log4cxx/spi/filter.h>
  +#include <map>
  +
  +namespace log4cxx
  +{
  +    namespace filter
  +    {
   
   /**
    * NOTE: This filter modifies logging events by adding properties to the event.
  - * 
  - * The 'properties' param is converted to event properties, which are 
  + *
  + * The 'properties' param is converted to event properties, which are
    * set on every event processed by the filter.
  - * 
  - * Individual properties are only set if they do not already exist on the 
  + *
  + * Individual properties are only set if they do not already exist on the
    * logging event (will not override existing properties).
  - * 
  - * This class relies on the convention that property name/value pairs are 
  + *
  + * This class relies on the convention that property name/value pairs are
    * equals-symbol delimited, and each name/value pair is comma-delimited
  - * 
  + *
    * Example properties param:
    * somename=somevalue,anothername=anothervalue,thirdname=third value
  - * 
  + *
    * @since 1.3
    */
  -public class PropertyFilter extends Filter {
  -   private Hashtable properties;
  -   public void setProperties(String props) {
  -      properties = parseProperties(props);
  -   }
  -   
  -   public int decide(LoggingEvent event) {
  -      Map eventProps = event.getProperties();
  -      if (eventProps == null) {
  -         event.setProperties(new Hashtable(properties));
  -      } else {
  -          //only add properties that don't already exist
  -          for (Iterator iter = properties.keySet().iterator();iter.hasNext();) {
  -              Object key = iter.next();
  -              if (!(eventProps.containsKey(key))) {
  -                  eventProps.put(key, properties.get(key));
  -              }
  -          }
  -      }
  -      return Filter.NEUTRAL;
  -   }
  -   
  -   private Hashtable parseProperties(String props) {
  -      Hashtable hashTable = new Hashtable();
  -      StringTokenizer pairs = new StringTokenizer(props, ",");
  -      while (pairs.hasMoreTokens()) {
  -         StringTokenizer entry = new StringTokenizer(pairs.nextToken(), "=");
  -         hashTable.put(entry.nextElement().toString().trim(), entry.nextElement().toString().trim());
  -      }
  -      return hashTable;
  -   }
  +        class LOG4CXX_EXPORT PropertyFilter:public log4cxx::spi::Filter
  +        {
  +            std::map < LogString, LogString > properties;
  +            PropertyFilter(const PropertyFilter &);
  +                  PropertyFilter & operator=(const PropertyFilter &);
  +
  +          public:
  +                  DECLARE_LOG4CXX_OBJECT(PropertyFilter)
  +                  BEGIN_LOG4CXX_CAST_MAP()
  +                  LOG4CXX_CAST_ENTRY(log4cxx::spi::Filter)
  +                  END_LOG4CXX_CAST_MAP()
  +
  +                  PropertyFilter();
  +            void setProperties(const LogString & props);
  +
  +            FilterDecision decide(const spi::LoggingEventPtr & event) const;
  +
  +        };
  +
  +    }
   }
  +#endif