logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject cvs commit: logging-log4j/src/java/org/apache/joran Interpreter.java
Date Sat, 10 Apr 2004 13:49:00 GMT
ceki        2004/04/10 06:49:00

  Modified:    src/java/org/apache/joran/action NestComponentIA.java
                        ImplicitAction.java
               src/java/org/apache/joran Interpreter.java
  Removed:     examples/src/joran/newRule newRuleCalculator.xml
  Log:
  
  ImplicitActions now have access to more information when deciding whether 
  they are applicable or not.
  
  Revision  Changes    Path
  1.10      +5 -1      logging-log4j/src/java/org/apache/joran/action/NestComponentIA.java
  
  Index: NestComponentIA.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/joran/action/NestComponentIA.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- NestComponentIA.java	9 Apr 2004 14:03:48 -0000	1.9
  +++ NestComponentIA.java	10 Apr 2004 13:49:00 -0000	1.10
  @@ -18,6 +18,7 @@
   
   import org.apache.joran.ErrorItem;
   import org.apache.joran.ExecutionContext;
  +import org.apache.joran.Pattern;
   import org.apache.joran.helper.Option;
   
   import org.apache.log4j.Logger;
  @@ -38,7 +39,10 @@
     int containmentType;
     PropertySetter parentBean;
     
  -  public boolean isApplicable(ExecutionContext ec, String nestedElementTagName) {
  +  public boolean isApplicable(Pattern pattern, Attributes attributes, ExecutionContext
ec) {
  +    
  +    String nestedElementTagName = pattern.peekLast();
  +    
       inError = false;
       Object o = ec.peekObject();
       parentBean = new PropertySetter(o);
  
  
  
  1.4       +23 -8     logging-log4j/src/java/org/apache/joran/action/ImplicitAction.java
  
  Index: ImplicitAction.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/joran/action/ImplicitAction.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ImplicitAction.java	30 Mar 2004 17:13:21 -0000	1.3
  +++ ImplicitAction.java	10 Apr 2004 13:49:00 -0000	1.4
  @@ -1,12 +1,12 @@
   /*
    * Copyright 1999,2004 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.
  @@ -17,17 +17,32 @@
   package org.apache.joran.action;
   
   import org.apache.joran.ExecutionContext;
  +import org.apache.joran.Pattern;
  +
  +import org.xml.sax.Attributes;
  +
   
   /**
    * ImplcitActions are like normal (explicit) actions except that are applied
  - * by the parser when no other pattern applies. Since there can be many implcit 
  - * actions, each action is asked whether it applies in the given context. The 
  + * by the parser when no other pattern applies. Since there can be many implcit
  + * actions, each action is asked whether it applies in the given context. The
    * first impplcit action to respond postively will be applied. See also the
    * {@link #isApplicable} method.
  - * 
  + *
    * @author Ceki Gülcü
    */
   public abstract class ImplicitAction extends Action {
  -
  -  public abstract boolean isApplicable(ExecutionContext ec, String nestedElementTagName);
  +  
  +  /**
  +   * Check whether this implicit action is apprioriate in the current context.
  +   * 
  +   * 
  +   * @param currentPattern This pattern contains the tag name of the current 
  +   * element being parsed at the top of the stack.
  +   * @param attributes The attributes of the current element to process.
  +   * @param ec
  +   * @return Whether the implicit action is applicable in the current context
  +   */
  +  public abstract boolean isApplicable(
  +    Pattern currentPattern, Attributes attributes, ExecutionContext ec);
   }
  
  
  
  1.8       +5 -5      logging-log4j/src/java/org/apache/joran/Interpreter.java
  
  Index: Interpreter.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/joran/Interpreter.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Interpreter.java	9 Apr 2004 16:03:19 -0000	1.7
  +++ Interpreter.java	10 Apr 2004 13:49:00 -0000	1.8
  @@ -108,7 +108,7 @@
   
       pattern.push(tagName);
   
  -    List applicableActionList = getapplicableActionList(pattern);
  +    List applicableActionList = getapplicableActionList(pattern, atts);
   
       if (applicableActionList != null) {
         actionListStack.add(applicableActionList);
  @@ -162,13 +162,13 @@
      * action is found, it is returned. Thus, the returned list will have at most
      * one element.
      */
  -  List lookupImplicitAction(ExecutionContext ec, Pattern pattern) {
  +  List lookupImplicitAction(Pattern pattern, Attributes attributes, ExecutionContext ec)
{
       int len = implicitActions.size();
   
       for (int i = 0; i < len; i++) {
         ImplicitAction ia = (ImplicitAction) implicitActions.get(i);
   
  -      if (ia.isApplicable(ec, pattern.peekLast())) {
  +      if (ia.isApplicable(pattern, attributes, ec)) {
           List actionList = new ArrayList(1);
           actionList.add(ia);
   
  @@ -182,12 +182,12 @@
     /**
      * Return the list of applicable patterns for this
     */
  -  List getapplicableActionList(Pattern pattern) {
  +  List getapplicableActionList(Pattern pattern, Attributes attributes) {
       List applicableActionList = ruleStore.matchActions(pattern);
   
       //logger.debug("set of applicable patterns: " + applicableActionList);
       if (applicableActionList == null) {
  -      applicableActionList = lookupImplicitAction(ec, pattern);
  +      applicableActionList = lookupImplicitAction(pattern, attributes, ec);
       }
   
       return applicableActionList;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message