Hi everybody,

We're trying to create a custom rule which will be used by Digester. We
follow the steps indicated in
http://jakarta.apache.org/commons/digester/commons-digester-1.8/docs/api/


    Creating a digester from XML:

|FromXmlRuleSet| is a |RuleSet| implementation that initializes its
|Digester| from rules defined in an XML file. The path to the XML file
is passed to constructor.

Alternatively, the convenience class DigesterLoader defines a static
method, |Digester createDigester(String rulesXml) throws
DigesterLoaderException|". When passing the name of the file that
contains your digester rules, this method returns a |Digester| instance
initialized with the rules.

To add your own rules, you need to:

  * Update the DTD
    You should add an element type for your rule. The element should
    have an attribute corresponding to each of the rule's
    initialization parameters.
  * Define an |ObjectCreationFactory|
  * Extend |DigesterRuleParser|
    |DigesterRuleParser| is a |RuleSet| for parsing a rules XML file.
    You should extend this, and override the |addRuleInstances()|
    method to add the rules for parsing your new element. Look in
    DigesterRuleParser.java to see how its done.


but we had a problem with the inner class PatternRule of
DigesterRuleParser. We overrided addRuleInstances(Digester digester)
method but there was a compilation error because PatternRule is a
private class

How can we resolve this problem?

This is the source problem, with the error


import org.apache.commons.digester.AbstractObjectCreationFactory;
import org.apache.commons.digester.Digester;
import org.apache.commons.digester.Rule;
import org.apache.commons.digester.xmlrules.DigesterRuleParser ;
import org.xml.sax.Attributes;

public class SetTopPropertyRuleParser extends DigesterRuleParser {
     public class SetTopPropertyRuleFactory extends
AbstractObjectCreationFactory{

      @Override
      public Object createObject(Attributes attributes) throws Exception {
          String methodName = attributes.getValue("methodname");
          String paramType = attributes.getValue("paramtype");
          if (paramType != null){
              return new SetTopPropertyRule(methodName, paramType);
          }else{
              return new SetTopPropertyRule(methodName);
          }
      }
                }

  public SetTopPropertyRuleParser(Digester targetDigester) {
      super(targetDigester);
  }

  @Override
  public void addRuleInstances(Digester digester) {
      super.addRuleInstances(digester);
      final String ruleClassName = Rule.class.getName();
      digester.addRule("*/set-top-property-rule", new
PatternRule("pattern")); // ERROR PatternRule is a private class
      digester.addSetNext("*/set-top-property-rule","add", ruleClassName);

  }

}





Note: I'm sorry for my english

--

Un saludo,
David




CAMBIO de DIRECCIONES de CORREO-E
Rogamos actualice su agenda de direcciones de correo electrónico. Todas las
direcciones de correo del dominio "@bancoval.es" cambian a "@rbcdexia-is.es"

E-MAIL ADDRESSES are CHANGING
Be advised that all the e-mail addresses from the domain "@bancoval.es"
are changing to "@rbcdexia-is.es".Please update your e-mail addresses.

AVISO LEGAL
Este mensaje de correo electrónico y sus documentos adjuntos están dirigidos
exclusivamente a los destinatarios especificados. Puede contener información
confidencial o legalmente protegida. No hay renuncia a la confidencialidad o
privilegio por cualquier transmisión errónea. Si usted no es el destinatario
indicado, le rogamos que lo elimine y se lo comunique al remitente. No debe,
directa o indirectamente, usar, revelar, distribuir, imprimir o copiar ninguna de las partes de este mensaje. Si siendo destinatario de este mensaje no consintiera el uso de correo electrónico, rogamos nos lo comunique inmediatamente.
RBCDexia Investor Services E,S.A. y sus filiales no serán responsables de las
opiniones o informaciones incluidas en este mensaje salvo cuando el remitente esté autorizado para establecer que dichas opiniones proceden de RBCDexia Investor
Services ,S.A.  y sus filiales.

DISCLAIMER
Addressee/s identified herein. It may contain confidential or legally privileged information. No confidentiality privilege is waived or lost
by any mistransmission. If you are not the intended recipient, please
immediately delete it and notify the sender. You must not, directly or
indirectly, disclose, distribute, print, or copy any part of this message.
If you are the addressee of this message and do not consent to the use of
e-mail, please communicate it to us immediately. RBCDexia Investor Services
S.A. and its subsidiaries are not responsible for the opinions or information
included in this message except when the sender is authorised to state them to
be the views of RBCDexia Investor Services, S.A. and its subsidiaries.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to