You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Michael Marrotte <ma...@nicusa.com> on 2002/07/01 04:25:05 UTC
RE: Digester?
I'd like to get in contact with people involved with the Commons project to
see what they think of this.
I found a workaround (to handle the paramcount="0" case) and possibly a bug
with the Commons Digester. I modified
org.apache.commons.digester.xmlrules.DigesterRuleParser.CallMethodRuleFactor
y:
From:
/**
* Factory for creating a CallMethodRule.
*/
/* protected class CallMethodRuleFactory extends
AbstractObjectCreationFactory {
public Object createObject(Attributes attributes) {
int paramCount =
Integer.parseInt(attributes.getValue("paramcount"));
String methodName = attributes.getValue("methodname");
Rule callMethodRule = new CallMethodRule(digester, methodName,
paramCount);
return callMethodRule;
}
}*/
To:
protected class CallMethodRuleFactory extends
AbstractObjectCreationFactory {
public Object createObject(Attributes attributes) {
int paramCount =
Integer.parseInt(attributes.getValue("paramcount"));
String methodName = attributes.getValue("methodname");
return paramCount == 0 ? new CallMethodRule(methodName)
:
new CallMethodRule(methodName, paramCount);
}
}
There's other deprecated methods used within the same package. It looks
like this might be an oversight. If you know how I can contact people from
the Commons/Digester project or get on a Commons mailing list (I had trouble
finding the info) for developers, please let me know.
Any help is greatly appreciated.
--Michael Marrotte
-----Original Message-----
From: Michael Marrotte [mailto:marrotte@nicusa.com]
Sent: Sunday, June 30, 2002 10:32 AM
To: Struts Users Mailing List
Subject: RE: Digester?
And I try setting "paramcount" to zero... Also in the docs:
paramCount
protected int paramCountThe number of parameters to collect from MethodParam
rules. If this value is zero, a single parameter will be collected from the
body of this element.
-----Original Message-----
From: Michael Marrotte [mailto:marrotte@nicusa.com]
Sent: Sunday, June 30, 2002 10:16 AM
To: Struts Users Mailing List
Subject: Digester?
The "commons.digester.CallMethodRule" is constructable with at least a
method name, i.e.
public CallMethodRule(java.lang.String methodName), see:
http://jakarta.apache.org/commons/digester/api/index.html
Furthermore, the docs go on to say:
"By using CallMethodRule(String methodName) a method call can be made to a
method which accepts no arguments."
So, why is this inconsistent with the "commons.digester.xmlrules"
counterpart -- that is, why is "paramcount" required by "call-method-rule"
in "digester-rules.dtd"?
<!ELEMENT call-method-rule EMPTY>
<!ATTLIST call-method-rule
pattern CDATA #IMPLIED
methodname CDATA #REQUIRED
paramcount CDATA #REQUIRED>
Of course this causes Snippet.java (found below, instantiated with
QueryRules.xml, Queries.xml and Queries.java) to throw
"java.lang.NumberFormatException: null". And when I try working around it
by setting "paramcount" to say 1, the rule is ignored.
Why doesn't the "xmlrules" mirror "digester". Any ideas and help is greatly
appreciated.
Thanks in advance,
--Michael Marrotte
// Snippet.java
class MyDigester {
File file = new File("/javatests/Queries.xml");
Digester digester = new Digester();
URL url;
FromXmlRuleSet ruleSet;
public void init() throws Exception{
System.out.println("can read file = " + file.canRead());
url = new URL("file:///javatests/QueryRules.xml");
url.getContent();
ruleSet =
new FromXmlRuleSet(url);
ruleSet.addRuleInstances(digester);
System.out.println("rules = " + digester.getRules().rules());
digester.push(this);
digester.parse(file);
}
// QueryRules.xml
<?xml version="1.0" encoding="UTF-8" ?>
<digester-rules>
<object-create-rule pattern="*/query" classname="Queries"/>
<set-properties-rule pattern="*/query"/>
<call-method-rule pattern="*/query" methodname="addQuery"/>
</digester-rules>
// Queries.xml
<?xml version="1.0" encoding="UTF-8" ?>
<queries>
<query lastName="Marrotte"/>
<query lastName="Luhrs"/>
</queries>
// Queries.java
public class Queries {
private String lastName = "";
public void setLastName(String lastName)
{
this.lastName = lastName;
}
public String getLastName(){
return lastName;
}
public void addQuery(){
System.out.println("Add Query Here");
}
}
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: Digester?
Posted by Michael Marrotte <ma...@nicusa.com>.
I used "cvs diff -u", added as attachment and reopened bug 8244.
But, I'm having trouble subscribing to COMMONS-DEV. I tried sending blank
email to the following:
commons-dev@jakarta.apache.org
commons-dev@apache.org
And got a failure notice each time. What am I doing wrong?
Any help is greatly appreciated.
--Michael Marrotte
-----Original Message-----
From: Craig R. McClanahan [mailto:craigmcc@apache.org]
Sent: Monday, July 01, 2002 1:03 PM
To: Struts Users Mailing List
Cc: marrotte@nicusa.com
Subject: RE: Digester?
Digester, and all the other commons packages, are developed on the
COMMONS-DEV mailing list. There's also bugzilla categories to report any
problems that you have.
It's also important to be specific about *which* version of digester you
are talking about, because it's gone through several releases. If all
you've got is a JAR file that you got with some Struts releaase, the
quickest way to find out is extract the META-INF/MANIFEST.MF file (text)
from commons-digester.jar and see what it says.
It's also pretty difficult to tell exactly what you are proposing to
change -- the most useful way to describe this is to do a "cvs diff -u"
command that will show exactly which lines are to be changed. This kind
of a patch can also be applied automatically if it is accepted -- not only
less work, but less chance for a transcription error.
Craig
On Sun, 30 Jun 2002, Michael Marrotte wrote:
> Date: Sun, 30 Jun 2002 22:25:05 -0400
> From: Michael Marrotte <ma...@nicusa.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: Struts Users Mailing List <st...@jakarta.apache.org>
> Cc: marrotte@nicusa.com
> Subject: RE: Digester?
>
> I'd like to get in contact with people involved with the Commons project
to
> see what they think of this.
>
> I found a workaround (to handle the paramcount="0" case) and possibly a
bug
> with the Commons Digester. I modified
>
org.apache.commons.digester.xmlrules.DigesterRuleParser.CallMethodRuleFactor
> y:
>
> From:
>
> /**
> * Factory for creating a CallMethodRule.
> */
> /* protected class CallMethodRuleFactory extends
> AbstractObjectCreationFactory {
> public Object createObject(Attributes attributes) {
> int paramCount =
> Integer.parseInt(attributes.getValue("paramcount"));
> String methodName = attributes.getValue("methodname");
> Rule callMethodRule = new CallMethodRule(digester, methodName,
> paramCount);
> return callMethodRule;
> }
> }*/
>
> To:
> protected class CallMethodRuleFactory extends
> AbstractObjectCreationFactory {
> public Object createObject(Attributes attributes) {
> int paramCount =
> Integer.parseInt(attributes.getValue("paramcount"));
> String methodName = attributes.getValue("methodname");
> return paramCount == 0 ? new CallMethodRule(methodName)
> :
> new CallMethodRule(methodName, paramCount);
> }
> }
>
> There's other deprecated methods used within the same package. It looks
> like this might be an oversight. If you know how I can contact people
from
> the Commons/Digester project or get on a Commons mailing list (I had
trouble
> finding the info) for developers, please let me know.
>
> Any help is greatly appreciated.
>
> --Michael Marrotte
>
>
>
> -----Original Message-----
> From: Michael Marrotte [mailto:marrotte@nicusa.com]
> Sent: Sunday, June 30, 2002 10:32 AM
> To: Struts Users Mailing List
> Subject: RE: Digester?
>
>
>
> And I try setting "paramcount" to zero... Also in the docs:
>
> paramCount
> protected int paramCountThe number of parameters to collect from
MethodParam
> rules. If this value is zero, a single parameter will be collected from
the
> body of this element.
>
>
> -----Original Message-----
> From: Michael Marrotte [mailto:marrotte@nicusa.com]
> Sent: Sunday, June 30, 2002 10:16 AM
> To: Struts Users Mailing List
> Subject: Digester?
>
>
> The "commons.digester.CallMethodRule" is constructable with at least a
> method name, i.e.
>
> public CallMethodRule(java.lang.String methodName), see:
>
> http://jakarta.apache.org/commons/digester/api/index.html
>
>
> Furthermore, the docs go on to say:
>
> "By using CallMethodRule(String methodName) a method call can be made to a
> method which accepts no arguments."
>
>
>
> So, why is this inconsistent with the "commons.digester.xmlrules"
> counterpart -- that is, why is "paramcount" required by "call-method-rule"
> in "digester-rules.dtd"?
>
> <!ELEMENT call-method-rule EMPTY>
> <!ATTLIST call-method-rule
> pattern CDATA #IMPLIED
> methodname CDATA #REQUIRED
> paramcount CDATA #REQUIRED>
>
>
> Of course this causes Snippet.java (found below, instantiated with
> QueryRules.xml, Queries.xml and Queries.java) to throw
> "java.lang.NumberFormatException: null". And when I try working around it
> by setting "paramcount" to say 1, the rule is ignored.
>
> Why doesn't the "xmlrules" mirror "digester". Any ideas and help is
greatly
> appreciated.
>
> Thanks in advance,
>
> --Michael Marrotte
>
>
> // Snippet.java
> class MyDigester {
> File file = new File("/javatests/Queries.xml");
> Digester digester = new Digester();
> URL url;
> FromXmlRuleSet ruleSet;
>
> public void init() throws Exception{
> System.out.println("can read file = " + file.canRead());
> url = new URL("file:///javatests/QueryRules.xml");
> url.getContent();
> ruleSet =
> new FromXmlRuleSet(url);
>
> ruleSet.addRuleInstances(digester);
>
> System.out.println("rules = " + digester.getRules().rules());
>
> digester.push(this);
>
> digester.parse(file);
>
> }
>
> // QueryRules.xml
> <?xml version="1.0" encoding="UTF-8" ?>
>
> <digester-rules>
> <object-create-rule pattern="*/query" classname="Queries"/>
> <set-properties-rule pattern="*/query"/>
> <call-method-rule pattern="*/query" methodname="addQuery"/>
> </digester-rules>
>
> // Queries.xml
> <?xml version="1.0" encoding="UTF-8" ?>
> <queries>
> <query lastName="Marrotte"/>
> <query lastName="Luhrs"/>
> </queries>
>
>
> // Queries.java
> public class Queries {
> private String lastName = "";
>
> public void setLastName(String lastName)
> {
> this.lastName = lastName;
> }
> public String getLastName(){
> return lastName;
> }
>
> public void addQuery(){
> System.out.println("Add Query Here");
> }
>
> }
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: Digester?
Posted by "Craig R. McClanahan" <cr...@apache.org>.
Digester, and all the other commons packages, are developed on the
COMMONS-DEV mailing list. There's also bugzilla categories to report any
problems that you have.
It's also important to be specific about *which* version of digester you
are talking about, because it's gone through several releases. If all
you've got is a JAR file that you got with some Struts releaase, the
quickest way to find out is extract the META-INF/MANIFEST.MF file (text)
from commons-digester.jar and see what it says.
It's also pretty difficult to tell exactly what you are proposing to
change -- the most useful way to describe this is to do a "cvs diff -u"
command that will show exactly which lines are to be changed. This kind
of a patch can also be applied automatically if it is accepted -- not only
less work, but less chance for a transcription error.
Craig
On Sun, 30 Jun 2002, Michael Marrotte wrote:
> Date: Sun, 30 Jun 2002 22:25:05 -0400
> From: Michael Marrotte <ma...@nicusa.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: Struts Users Mailing List <st...@jakarta.apache.org>
> Cc: marrotte@nicusa.com
> Subject: RE: Digester?
>
> I'd like to get in contact with people involved with the Commons project to
> see what they think of this.
>
> I found a workaround (to handle the paramcount="0" case) and possibly a bug
> with the Commons Digester. I modified
> org.apache.commons.digester.xmlrules.DigesterRuleParser.CallMethodRuleFactor
> y:
>
> From:
>
> /**
> * Factory for creating a CallMethodRule.
> */
> /* protected class CallMethodRuleFactory extends
> AbstractObjectCreationFactory {
> public Object createObject(Attributes attributes) {
> int paramCount =
> Integer.parseInt(attributes.getValue("paramcount"));
> String methodName = attributes.getValue("methodname");
> Rule callMethodRule = new CallMethodRule(digester, methodName,
> paramCount);
> return callMethodRule;
> }
> }*/
>
> To:
> protected class CallMethodRuleFactory extends
> AbstractObjectCreationFactory {
> public Object createObject(Attributes attributes) {
> int paramCount =
> Integer.parseInt(attributes.getValue("paramcount"));
> String methodName = attributes.getValue("methodname");
> return paramCount == 0 ? new CallMethodRule(methodName)
> :
> new CallMethodRule(methodName, paramCount);
> }
> }
>
> There's other deprecated methods used within the same package. It looks
> like this might be an oversight. If you know how I can contact people from
> the Commons/Digester project or get on a Commons mailing list (I had trouble
> finding the info) for developers, please let me know.
>
> Any help is greatly appreciated.
>
> --Michael Marrotte
>
>
>
> -----Original Message-----
> From: Michael Marrotte [mailto:marrotte@nicusa.com]
> Sent: Sunday, June 30, 2002 10:32 AM
> To: Struts Users Mailing List
> Subject: RE: Digester?
>
>
>
> And I try setting "paramcount" to zero... Also in the docs:
>
> paramCount
> protected int paramCountThe number of parameters to collect from MethodParam
> rules. If this value is zero, a single parameter will be collected from the
> body of this element.
>
>
> -----Original Message-----
> From: Michael Marrotte [mailto:marrotte@nicusa.com]
> Sent: Sunday, June 30, 2002 10:16 AM
> To: Struts Users Mailing List
> Subject: Digester?
>
>
> The "commons.digester.CallMethodRule" is constructable with at least a
> method name, i.e.
>
> public CallMethodRule(java.lang.String methodName), see:
>
> http://jakarta.apache.org/commons/digester/api/index.html
>
>
> Furthermore, the docs go on to say:
>
> "By using CallMethodRule(String methodName) a method call can be made to a
> method which accepts no arguments."
>
>
>
> So, why is this inconsistent with the "commons.digester.xmlrules"
> counterpart -- that is, why is "paramcount" required by "call-method-rule"
> in "digester-rules.dtd"?
>
> <!ELEMENT call-method-rule EMPTY>
> <!ATTLIST call-method-rule
> pattern CDATA #IMPLIED
> methodname CDATA #REQUIRED
> paramcount CDATA #REQUIRED>
>
>
> Of course this causes Snippet.java (found below, instantiated with
> QueryRules.xml, Queries.xml and Queries.java) to throw
> "java.lang.NumberFormatException: null". And when I try working around it
> by setting "paramcount" to say 1, the rule is ignored.
>
> Why doesn't the "xmlrules" mirror "digester". Any ideas and help is greatly
> appreciated.
>
> Thanks in advance,
>
> --Michael Marrotte
>
>
> // Snippet.java
> class MyDigester {
> File file = new File("/javatests/Queries.xml");
> Digester digester = new Digester();
> URL url;
> FromXmlRuleSet ruleSet;
>
> public void init() throws Exception{
> System.out.println("can read file = " + file.canRead());
> url = new URL("file:///javatests/QueryRules.xml");
> url.getContent();
> ruleSet =
> new FromXmlRuleSet(url);
>
> ruleSet.addRuleInstances(digester);
>
> System.out.println("rules = " + digester.getRules().rules());
>
> digester.push(this);
>
> digester.parse(file);
>
> }
>
> // QueryRules.xml
> <?xml version="1.0" encoding="UTF-8" ?>
>
> <digester-rules>
> <object-create-rule pattern="*/query" classname="Queries"/>
> <set-properties-rule pattern="*/query"/>
> <call-method-rule pattern="*/query" methodname="addQuery"/>
> </digester-rules>
>
> // Queries.xml
> <?xml version="1.0" encoding="UTF-8" ?>
> <queries>
> <query lastName="Marrotte"/>
> <query lastName="Luhrs"/>
> </queries>
>
>
> // Queries.java
> public class Queries {
> private String lastName = "";
>
> public void setLastName(String lastName)
> {
> this.lastName = lastName;
> }
> public String getLastName(){
> return lastName;
> }
>
> public void addQuery(){
> System.out.println("Add Query Here");
> }
>
> }
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>