commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robert burrell donkin <robertburrelldon...@blueyonder.co.uk>
Subject Re: [digester help] How to convert a xml file into a list
Date Thu, 28 Nov 2002 19:16:14 GMT
hi

i've tried this but i can't reproduce your error :-/

could you retry with the CVS HEAD versions (or recently nightly builds) 
for beanutils and digester.

- robert

On Thursday, November 28, 2002, at 06:38 AM, IMCaptor wrote:

> Hello All:
>
> I have a xml file like this
>
> <items>
>   <item>fdasfdasfd</item>
>   <item>fvxcvcvxvdasfdasfd</item>
>   <item>fdasfafdasdasfd</item>
> </items>
>
> I want to put the item into a vector,
> so i create the rules like this
>
> <digester-rules>
>   <pattern value="items">
>     <object-create-rule
> classname="java.util.Vector"/>						
>
>     <call-method-rule pattern="item" methodname="add" paramcount="0" />
>   </pattern>
> </digester-rules>
>
> but I always get a error
>
> java.lang.NoSuchMethodException: No such accessible method: add() on
> object: java.util.Vector
>
> why the add(Object o) can't adapt to add(String obj)?
>
> Thank u!
>
>
> Best Regards
> IMCaptor
>
>
>
> -----邮件原件-----
> 发件人: IMCaptor [mailto:wanghb@greatom.com]
> 发送时间: 2002年11月28日 10:20
> 收件人: 'Jakarta Commons Users List'
> 主题: 答复: [digester help] How two construct a Object without a
> defaultConstructor?
>
>
> Hi robert:
>   My class code is like this:
>
> package org.apache.commons.dbcp;
> import java.sql.Connection;
> import java.sql.DriverManager;
> import java.sql.SQLException;
> import java.util.Properties;
>
> public class DriverManagerConnectionFactory implements ConnectionFactory
> {
>
>     public DriverManagerConnectionFactory(String connectUri, Properties
> props) {
>         _connectUri = connectUri;
>         _props = props;
>     }
>
>     public DriverManagerConnectionFactory(String connectUri, String
> uname, String passwd) {
>         _connectUri = connectUri;
>         _uname = uname;
>         _passwd = passwd;
>     }
>
>     public Connection createConnection() {
>         try {
>             if(null == _props) {
>                 if((_uname == null) || (_passwd == null)) {
>                     return DriverManager.getConnection(_connectUri);
>                 } else {
>                     return
> DriverManager.getConnection(_connectUri,_uname,_passwd);
>                 }
>             } else {
>                 return DriverManager.getConnection(_connectUri,_props);
>             }
>         } catch(SQLException e) {
>             throw new DbcpException(e);
>         }
>     }
>
>     protected String _connectUri = null;
>     protected String _uname = null;
>     protected String _passwd = null;
>     protected Properties _props = null;
> }
>
> this class have not the default constructor.
>
> My xml file like this
>
> <connection-factory>
>   <url>jdbc:oracle:thin:@203.212.6.173:1521:OraTom</url>
>   <properties>
>     <property>
>       <key>username</key>
>       <value>fdasfd</value>
>     </property>
>     <property>
>       <key>password</key>
>       <value>fdaf</value>
>     </property>
>   </properties>
> </connection-factory>
>
> how to convert the xml to the object?
>
> Thank u!
>
> Best Regards
> IMCaptor
>
>
>
> -----邮件原件-----
> 发件人: robert burrell donkin [mailto:robertburrelldonkin@blueyonder.co.
> uk]
> 发送时间: 2002年11月28日 3:15
> 收件人: Jakarta Commons Users List
> 主题: Re: [digester help] How two construct a Object without a
> defaultConstructor?
>
>
> hi
>
> it'd probably be easier for me to help if you could give some concrete
> example code and xml. that way, i can talk specifically rather in
> general
> terms.
>
> - robert
>
> On Wednesday, November 27, 2002, at 03:17 AM, IMCaptor wrote:
>
>> Hi Robert:
>>   I don't know how to create the rule like u said:
>> "this rule would construct the object not on the
>> element start but at the element end. maybe you might need to create
>> the
>>
>> child object on the element start in your custom rule so that's
>> available on the stack."
>>
>> Thank u!
>>
>> Best Regards
>> IMCaptor
>>
>>
>>
>> -----邮件原件-----
>> 发件人: robert burrell donkin
> [mailto:robertburrelldonkin@blueyonder.co.
>> uk]
>> 发送时间: 2002年11月26日 2:40
>> 收件人: Jakarta Commons Users List
>> 主题: Re: [digester help] How two construct a Object without a
>> defaultConstructor?
>>
>>
>> let's see if i have this right...
>>
>> you have a child object that you need to create before you can
>> construct
>>
>> the father object. the element for the father object enclosed the
>> element(
>> s) which are used to create the child object.
>>
>> if this is the case, then i'd suggest that you look at creating you
>> own object creation rule. this rule would construct the object not on
>> the element start but at the element end. maybe you might need to
>> create the
>>
>> child object on the element start in your custom rule so that's
>> available on the stack.
>>
>> i'll not speculate further but if you do need any help in creating
>> this custom rule, then just post your questions to the list.
>>
>> - robert
>>
>> On Monday, November 25, 2002, at 02:28 AM, IMCaptor wrote:
>>
>>> Thank u for ur help,
>>> But I have another problem,
>>> Because the Attributes I transfer into the constructor are not only
>>> String, but have complicate class, such as Properties. How do I first
>
>>> construct the child Object, and then transfer the child Object into
>>> the father Constructor.
>>>
>>>
>>> Best Regards
>>> IMCaptor
>>>
>>>
>>>
>>> -----邮件原件-----
>>> 发件人: Simon Kitching [mailto:simon@ecnetwork.co.nz]
>>> 发送时间: 2002年11月25日 4:32
>>> 收件人: Jakarta Commons Users List
>>> 主题: Re: [digest help] How two construct a Object without a
>>> defaultConstructor?
>>>
>>>
>>> Hi "IMCaptor" (what an unusual name you have :-)
>>>
>>> What you need is the FactoryCreateRule.
>>>
>>> Step 1:
>>> Write a class which extends
>>> org.apache.commons.digester.AbstractObjectCreationFactory.
>>>
>>> Implement the createObject method.
>>>
>>> Step 2:
>>> call method addFactoryCreateRule on your digester instance to set up
>>> the appropriate rule.
>>>
>>> See the javadoc for class FactoryCreateRule for more info.
>>>
>>> Regards,
>>>
>>> Simon
>>>
>>> On Mon, 2002-11-25 at 03:04, 王红宝 wrote:
>>>> Hi All:
>>>>   I want to config the connection factory with a xml file, and want
>>>> to
>>>
>>>> parse the file with digest. But the
>>>> org.apache.commons.dbcp.DriverManagerConnectionFactory
>>>> has not default constructor,
>>>> How can I do this?
>>>>
>>>> this java file has two contructor
>>>>
>>>> public DriverManagerConnectionFactory(String connectUri, Properties
>>> props) {
>>>>         _connectUri = connectUri;
>>>>         _props = props;
>>>>     }
>>>>     public DriverManagerConnectionFactory(String connectUri, String
>>> uname, String passwd) {
>>>>         _connectUri = connectUri;
>>>>         _uname = uname;
>>>>         _passwd = passwd;
>>>>     }
>>>>
>>>> and my xml file like this
>>>> <connnection-factory>
>>>>   <connection-uri>jdbc:tset:fasdf</connection-uri>
>>>>   <properties>
>>>>     <property key="fdaf" value="fdasf"><property>
>>>>     ................
>>>>   </properties>
>>>> </connection-factory>
>>>>
>>>> the class DriverManagerConnectionFactory has no public getter and
>>>> setter.
>>>>
>>>>
>>>> Thank u!
>>>>
>>>> IMCaptor
>>>> Best Regards
>>>>
>>
>>
>> --
>> To unsubscribe, e-mail:
> <mailto:commons-user-unsubscribe@jakarta.apache.
>> org>
>> For additional commands, e-mail:
>> <mailto:commons-user-help@jakarta.apache.
>> org>
>>
>
>
> --
> To unsubscribe, e-mail: <mailto:commons-user-unsubscribe@jakarta.apache.
> org>
> For additional commands, e-mail:
> <mailto:commons-user-help@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:
> <mailto:commons-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:commons-user-help@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:   <mailto:commons-user-unsubscribe@jakarta.apache.
> org>
> For additional commands, e-mail: <mailto:commons-user-help@jakarta.apache.
> org>
>


Mime
View raw message