You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Mike Zatko <za...@comcast.net> on 2004/11/22 19:06:43 UTC

[Digester] Handling Null values

I am trying to parse a document which has a Timestamp element which may 
or may not be null. Does anyone know how to setup the addCallMethod to 
handle this situation?

The one i've tried is as follows:

digester.addCallMethod(root + orderClass + 
"/payments/payment/expiration-date", "setExpirationDate", 0, new 
String[] {"java.sql.Timestamp"});

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [Digester] Handling Null values

Posted by Mike Zatko <za...@comcast.net>.
Simon Kitching wrote:

>On Wed, 2004-11-24 at 03:38, Mike Zatko wrote:
>  
>
>>Simon Kitching wrote:
>>
>>    
>>
>>>On Tue, 2004-11-23 at 07:06, Mike Zatko wrote:
>>> 
>>>
>>>      
>>>
>>>>I am trying to parse a document which has a Timestamp element which may 
>>>>or may not be null. Does anyone know how to setup the addCallMethod to 
>>>>handle this situation?
>>>>
>>>>The one i've tried is as follows:
>>>>
>>>>digester.addCallMethod(root + orderClass + 
>>>>"/payments/payment/expiration-date", "setExpirationDate", 0, new 
>>>>String[] {"java.sql.Timestamp"});
>>>>   
>>>>
>>>>        
>>>>
>>>In most cases, if you call a method and the parameter data is not
>>>present in the input, then null is passed to the target method.
>>>
>>>According to the javadoc for the ConvertUtils class in the BeanUtils
>>>library,  String->java.sql.Timestamp is a supported conversion, so
>>>things should just work.
>>>      
>>>
>
>  
>
>>Ok, this is the full run log... it's long. I can see that its using the SqlTimestampConverter which should handle a null value. But, apparently it does not? Any advice appreciated.
>>    
>>
>
>[snip]
>
>  
>
>>468 [main] DEBUG org.apache.commons.digester.Digester  -   Fire begin() for CallMethodRule[methodName=setCreateDate, paramCount=0, paramTypes={java.sql.Timestamp}]
>>468 [main] DEBUG org.apache.commons.digester.Digester.sax  - endElement(,,create-date)
>>468 [main] DEBUG org.apache.commons.digester.Digester  -   match='com.boscovs.translator.dto.fulfillment.Comment/create-date'
>>468 [main] DEBUG org.apache.commons.digester.Digester  -   bodyText=''
>>468 [main] DEBUG org.apache.commons.digester.Digester  -   Fire body() for CallMethodRule[methodName=setCreateDate, paramCount=0, paramTypes={java.sql.Timestamp}]
>>468 [main] DEBUG org.apache.commons.digester.Digester  -   Popping body text '
>>    
>>    '
>>468 [main] DEBUG org.apache.commons.digester.Digester  -   Fire end() for CallMethodRule[methodName=setCreateDate, paramCount=0, paramTypes={java.sql.Timestamp}]
>>468 [main] DEBUG org.apache.commons.beanutils.ConvertUtils  - Convert string '' to class 'java.sql.Timestamp'
>>468 [main] DEBUG org.apache.commons.beanutils.ConvertUtils  -   Using converter org.apache.commons.beanutils.converters.SqlTimestampConverter@14c1103
>>484 [main] ERROR org.apache.commons.digester.Digester  - End event threw exception
>>org.apache.commons.beanutils.ConversionException: Timestamp format must be yyyy-mm-dd hh:mm:ss.fffffffff
>>    
>>
>
>Ok, the problem is that it is the *body* of the xml element that is
>being converted to an SqlTimestamp. 
>
>If it were an *attribute* that was being passed, and the attribute were
>not present then 'null' would be passed to the converter, and presumably
>null would be the return value, which would then be passed to the setter
>method on the target object.
>
>But because it's the *body*, and the element is empty, an *empty string*
>is being passed to the converter, not null, and an empty string cannot
>be converted to a timestamp.
>
>This also would occur if it were an *attribute* being converted to a
>timestamp, and it were defined to be an empty string, eg <item
>time=""/>. However it would be a little more obvious why the failure is
>occurring...
>
>It's an interesting question as to whether Digester should regard the
>body of <element/> as being NULL or an empty string. Maybe this should
>be an option on CallMethodRule and CallParamRule.
>
>Personally, I think the xml input is not well designed; if there is no
>timestamp information, then the xml element providing timestamp info
>should not be present, rather than being present with an empty body.
>However I understand that these things are not always under the control
>of the person *parsing* the xml...
>
>I suggest the following. Of course these are only initial thoughts; no
>guarantee any of these will work...
>
>option 1: Register your own converter to SqlTimestamp using the
>ConvertUtils class in the BeanUtils library, and have this converter
>return null when passed an empty string. It could be a simple wrapper
>around the existing class, or subclass of it, etc.
>
>option 2: Create a custom Rule class to deal with the timestamp input
>element, rather than using CallMethodRule. It should be *much* simpler
>than CallMethodRule, ie just start from scratch rather than
>copying/subclassing CallMethodRule. All you should need to do is
>implement the body() method...
>
>option 3: If you're feeling enthusiastic, you could consider adding a
>feature to CallMethodRule/CallParamRule that allows the user to specify
>whether an empty body should be treated as a null value or an empty
>string. I haven't thought deeply about it, but I would expect this to
>have a reasonable chance of being added to the digester core
>distribution.
>
>
>
>Regards,
>
>Simon
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
>  
>

I will definately attempt your suggestions. Thanks.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [Digester] Handling Null values

Posted by Simon Kitching <si...@ecnetwork.co.nz>.
On Wed, 2004-11-24 at 03:38, Mike Zatko wrote:
> Simon Kitching wrote:
> 
> >On Tue, 2004-11-23 at 07:06, Mike Zatko wrote:
> >  
> >
> >>I am trying to parse a document which has a Timestamp element which may 
> >>or may not be null. Does anyone know how to setup the addCallMethod to 
> >>handle this situation?
> >>
> >>The one i've tried is as follows:
> >>
> >>digester.addCallMethod(root + orderClass + 
> >>"/payments/payment/expiration-date", "setExpirationDate", 0, new 
> >>String[] {"java.sql.Timestamp"});
> >>    
> >>
> >
> >In most cases, if you call a method and the parameter data is not
> >present in the input, then null is passed to the target method.
> >
> >According to the javadoc for the ConvertUtils class in the BeanUtils
> >library,  String->java.sql.Timestamp is a supported conversion, so
> >things should just work.

> Ok, this is the full run log... it's long. I can see that its using the SqlTimestampConverter which should handle a null value. But, apparently it does not? Any advice appreciated.

[snip]

> 468 [main] DEBUG org.apache.commons.digester.Digester  -   Fire begin() for CallMethodRule[methodName=setCreateDate, paramCount=0, paramTypes={java.sql.Timestamp}]
> 468 [main] DEBUG org.apache.commons.digester.Digester.sax  - endElement(,,create-date)
> 468 [main] DEBUG org.apache.commons.digester.Digester  -   match='com.boscovs.translator.dto.fulfillment.Comment/create-date'
> 468 [main] DEBUG org.apache.commons.digester.Digester  -   bodyText=''
> 468 [main] DEBUG org.apache.commons.digester.Digester  -   Fire body() for CallMethodRule[methodName=setCreateDate, paramCount=0, paramTypes={java.sql.Timestamp}]
> 468 [main] DEBUG org.apache.commons.digester.Digester  -   Popping body text '
>     
>     '
> 468 [main] DEBUG org.apache.commons.digester.Digester  -   Fire end() for CallMethodRule[methodName=setCreateDate, paramCount=0, paramTypes={java.sql.Timestamp}]
> 468 [main] DEBUG org.apache.commons.beanutils.ConvertUtils  - Convert string '' to class 'java.sql.Timestamp'
> 468 [main] DEBUG org.apache.commons.beanutils.ConvertUtils  -   Using converter org.apache.commons.beanutils.converters.SqlTimestampConverter@14c1103
> 484 [main] ERROR org.apache.commons.digester.Digester  - End event threw exception
> org.apache.commons.beanutils.ConversionException: Timestamp format must be yyyy-mm-dd hh:mm:ss.fffffffff

Ok, the problem is that it is the *body* of the xml element that is
being converted to an SqlTimestamp. 

If it were an *attribute* that was being passed, and the attribute were
not present then 'null' would be passed to the converter, and presumably
null would be the return value, which would then be passed to the setter
method on the target object.

But because it's the *body*, and the element is empty, an *empty string*
is being passed to the converter, not null, and an empty string cannot
be converted to a timestamp.

This also would occur if it were an *attribute* being converted to a
timestamp, and it were defined to be an empty string, eg <item
time=""/>. However it would be a little more obvious why the failure is
occurring...

It's an interesting question as to whether Digester should regard the
body of <element/> as being NULL or an empty string. Maybe this should
be an option on CallMethodRule and CallParamRule.

Personally, I think the xml input is not well designed; if there is no
timestamp information, then the xml element providing timestamp info
should not be present, rather than being present with an empty body.
However I understand that these things are not always under the control
of the person *parsing* the xml...

I suggest the following. Of course these are only initial thoughts; no
guarantee any of these will work...

option 1: Register your own converter to SqlTimestamp using the
ConvertUtils class in the BeanUtils library, and have this converter
return null when passed an empty string. It could be a simple wrapper
around the existing class, or subclass of it, etc.

option 2: Create a custom Rule class to deal with the timestamp input
element, rather than using CallMethodRule. It should be *much* simpler
than CallMethodRule, ie just start from scratch rather than
copying/subclassing CallMethodRule. All you should need to do is
implement the body() method...

option 3: If you're feeling enthusiastic, you could consider adding a
feature to CallMethodRule/CallParamRule that allows the user to specify
whether an empty body should be treated as a null value or an empty
string. I haven't thought deeply about it, but I would expect this to
have a reasonable chance of being added to the digester core
distribution.



Regards,

Simon


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [Digester] Handling Null values

Posted by Mike Zatko <mz...@boscovs.com>.
Simon Kitching wrote:

>On Tue, 2004-11-23 at 07:06, Mike Zatko wrote:
>  
>
>>I am trying to parse a document which has a Timestamp element which may 
>>or may not be null. Does anyone know how to setup the addCallMethod to 
>>handle this situation?
>>
>>The one i've tried is as follows:
>>
>>digester.addCallMethod(root + orderClass + 
>>"/payments/payment/expiration-date", "setExpirationDate", 0, new 
>>String[] {"java.sql.Timestamp"});
>>    
>>
>
>In most cases, if you call a method and the parameter data is not
>present in the input, then null is passed to the target method.
>
>According to the javadoc for the ConvertUtils class in the BeanUtils
>library,  String->java.sql.Timestamp is a supported conversion, so
>things should just work.
>
>Please provide more details, including describing what occurs when you
>try the code you listed above. Also try enabling debug logging for the
>Digester library, and see if that helps (see
>http://wiki.apache.org/jakarta-commons/Digester/FAQ for info on enabling
>debug logging.
>
>Regards,
>
>Simon
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
>  
>


Ok, this is the full run log... it's long. I can see that its using the SqlTimestampConverter which should handle a null value. But, apparently it does not? Any advice appreciated.




0 [main] DEBUG org.apache.commons.betwixt.io.AbstractBeanWriter  - Writing bean graph (qualified name 'com.boscovs.translator.dto.fulfillment.Comment'
0 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Introspecting...
0 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - com.boscovs.translator.dto.fulfillment.Comment@16cd7d5
0 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Attempting to lookup an XML descriptor for class: class com.boscovs.translator.dto.fulfillment.Comment
0 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Could not find betwixt file Comment.betwixt
15 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Populating:Bean[name=Comment, type=class com.boscovs.translator.dto.fulfillment.Comment
31 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Bean is standard type
47 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - 7 properties to be added
47 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Creating descriptor for property: name=class type=class java.lang.Class
47 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Property expression=MethodExpression [method=public final native java.lang.Class java.lang.Object.getClass()]
47 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Ignoring class property
47 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Creating descriptor for property: name=commentId type=long
47 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Property expression=MethodExpression [method=public long com.boscovs.translator.dto.fulfillment.Comment.getCommentId()]
47 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Primitive type: commentId
47 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Adding property as element: commentId
47 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Created descriptor:
47 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - ElementDescriptor[qname=comment-id,pname=commentId,class=long,singular=long,updater=MethodUpdater [method=public void com.boscovs.translator.dto.fulfillment.Comment.setCommentId(long)],wrap=true]
47 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Creating descriptor for property: name=createDate type=class java.sql.Timestamp
47 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Property expression=MethodExpression [method=public java.sql.Timestamp com.boscovs.translator.dto.fulfillment.Comment.getCreateDate()]
47 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Primitive type: createDate
47 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Adding property as element: createDate
47 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Created descriptor:
47 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - ElementDescriptor[qname=create-date,pname=createDate,class=class java.sql.Timestamp,singular=class java.sql.Timestamp,updater=MethodUpdater [method=public void com.boscovs.translator.dto.fulfillment.Comment.setCreateDate(java.sql.Timestamp)],wrap=true]
47 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Creating descriptor for property: name=emailSystemNumber type=class java.lang.Integer
47 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Property expression=MethodExpression [method=public java.lang.Integer com.boscovs.translator.dto.fulfillment.Comment.getEmailSystemNumber()]
47 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Primitive type: emailSystemNumber
47 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Adding property as element: emailSystemNumber
47 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Created descriptor:
47 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - ElementDescriptor[qname=email-system-number,pname=emailSystemNumber,class=class java.lang.Integer,singular=class java.lang.Integer,updater=MethodUpdater [method=public void com.boscovs.translator.dto.fulfillment.Comment.setEmailSystemNumber(java.lang.Integer)],wrap=true]
47 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Creating descriptor for property: name=operatorId type=class java.lang.String
47 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Property expression=MethodExpression [method=public java.lang.String com.boscovs.translator.dto.fulfillment.Comment.getOperatorId()]
47 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Primitive type: operatorId
47 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Adding property as element: operatorId
47 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Created descriptor:
47 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - ElementDescriptor[qname=operator-id,pname=operatorId,class=class java.lang.String,singular=class java.lang.String,updater=MethodUpdater [method=public void com.boscovs.translator.dto.fulfillment.Comment.setOperatorId(java.lang.String)],wrap=true]
62 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Creating descriptor for property: name=orderId type=class java.lang.String
62 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Property expression=MethodExpression [method=public java.lang.String com.boscovs.translator.dto.fulfillment.Comment.getOrderId()]
62 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Primitive type: orderId
62 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Adding property as element: orderId
62 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Created descriptor:
62 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - ElementDescriptor[qname=order-id,pname=orderId,class=class java.lang.String,singular=class java.lang.String,updater=MethodUpdater [method=public void com.boscovs.translator.dto.fulfillment.Comment.setOrderId(java.lang.String)],wrap=true]
62 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Creating descriptor for property: name=text type=class java.lang.String
62 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Property expression=MethodExpression [method=public java.lang.String com.boscovs.translator.dto.fulfillment.Comment.getText()]
62 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Primitive type: text
62 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Adding property as element: text
62 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Created descriptor:
62 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - ElementDescriptor[qname=text,pname=text,class=class java.lang.String,singular=class java.lang.String,updater=MethodUpdater [method=public void com.boscovs.translator.dto.fulfillment.Comment.setText(java.lang.String)],wrap=true]
62 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - After properties have been added (elements, attributes, contents):
62 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - [ElementDescriptor[qname=comment-id,pname=commentId,class=long,singular=long,updater=MethodUpdater [method=public void com.boscovs.translator.dto.fulfillment.Comment.setCommentId(long)],wrap=true], ElementDescriptor[qname=create-date,pname=createDate,class=class java.sql.Timestamp,singular=class java.sql.Timestamp,updater=MethodUpdater [method=public void com.boscovs.translator.dto.fulfillment.Comment.setCreateDate(java.sql.Timestamp)],wrap=true], ElementDescriptor[qname=email-system-number,pname=emailSystemNumber,class=class java.lang.Integer,singular=class java.lang.Integer,updater=MethodUpdater [method=public void com.boscovs.translator.dto.fulfillment.Comment.setEmailSystemNumber(java.lang.Integer)],wrap=true], ElementDescriptor[qname=operator-id,pname=operatorId,class=class java.lang.String,singular=class java.lang.String,updater=MethodUpdater [method=public void com.boscovs.translator.dto.fulfillment.Comment.setOperatorId(java.lang.String)],wrap=true], ElementDescriptor[qname=order-id,pname=orderId,class=class java.lang.String,singular=class java.lang.String,updater=MethodUpdater [method=public void com.boscovs.translator.dto.fulfillment.Comment.setOrderId(java.lang.String)],wrap=true], ElementDescriptor[qname=text,pname=text,class=class java.lang.String,singular=class java.lang.String,updater=MethodUpdater [method=public void com.boscovs.translator.dto.fulfillment.Comment.setText(java.lang.String)],wrap=true]]
62 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - []
62 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - []
62 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - Populated descriptor:
62 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - ElementDescriptor[qname=comment,pname=null,class=class com.boscovs.translator.dto.fulfillment.Comment,singular=class com.boscovs.translator.dto.fulfillment.Comment,updater=null,wrap=true]
62 [main] DEBUG org.apache.commons.betwixt.XMLIntrospector  - XMLBeanInfo [class=class com.boscovs.translator.dto.fulfillment.Comment, descriptor=ElementDescriptor[qname=comment,pname=null,class=class com.boscovs.translator.dto.fulfillment.Comment,singular=class com.boscovs.translator.dto.fulfillment.Comment,updater=null,wrap=true]]
62 [main] DEBUG org.apache.commons.betwixt.io.AbstractBeanWriter  - Pushing onto object stack: com.boscovs.translator.dto.fulfillment.Comment@16cd7d5
62 [main] DEBUG org.apache.commons.betwixt.io.AbstractBeanWriter  - Writing: com.boscovs.translator.dto.fulfillment.Comment element: ElementDescriptor[qname=comment,pname=null,class=class com.boscovs.translator.dto.fulfillment.Comment,singular=class com.boscovs.translator.dto.fulfillment.Comment,updater=null,wrap=true]
62 [main] DEBUG org.apache.commons.betwixt.io.AbstractBeanWriter  - Element ElementDescriptor[qname=comment,pname=null,class=class com.boscovs.translator.dto.fulfillment.Comment,singular=class com.boscovs.translator.dto.fulfillment.Comment,updater=null,wrap=true] is empty.
62 [main] DEBUG org.apache.commons.betwixt.io.AbstractBeanWriter  - Writing: comment-id element: ElementDescriptor[qname=comment-id,pname=commentId,class=long,singular=long,updater=MethodUpdater [method=public void com.boscovs.translator.dto.fulfillment.Comment.setCommentId(long)],wrap=true]
62 [main] DEBUG org.apache.commons.betwixt.io.AbstractBeanWriter  - Element ElementDescriptor[qname=comment-id,pname=commentId,class=long,singular=long,updater=MethodUpdater [method=public void com.boscovs.translator.dto.fulfillment.Comment.setCommentId(long)],wrap=true] is empty.
156 [main] DEBUG org.apache.commons.betwixt.io.AbstractBeanWriter  - Writing: create-date element: ElementDescriptor[qname=create-date,pname=createDate,class=class java.sql.Timestamp,singular=class java.sql.Timestamp,updater=MethodUpdater [method=public void com.boscovs.translator.dto.fulfillment.Comment.setCreateDate(java.sql.Timestamp)],wrap=true]
156 [main] DEBUG org.apache.commons.betwixt.io.AbstractBeanWriter  - Element ElementDescriptor[qname=create-date,pname=createDate,class=class java.sql.Timestamp,singular=class java.sql.Timestamp,updater=MethodUpdater [method=public void com.boscovs.translator.dto.fulfillment.Comment.setCreateDate(java.sql.Timestamp)],wrap=true] is empty.
156 [main] DEBUG org.apache.commons.betwixt.io.AbstractBeanWriter  - Writing: email-system-number element: ElementDescriptor[qname=email-system-number,pname=emailSystemNumber,class=class java.lang.Integer,singular=class java.lang.Integer,updater=MethodUpdater [method=public void com.boscovs.translator.dto.fulfillment.Comment.setEmailSystemNumber(java.lang.Integer)],wrap=true]
156 [main] DEBUG org.apache.commons.betwixt.io.AbstractBeanWriter  - Element ElementDescriptor[qname=email-system-number,pname=emailSystemNumber,class=class java.lang.Integer,singular=class java.lang.Integer,updater=MethodUpdater [method=public void com.boscovs.translator.dto.fulfillment.Comment.setEmailSystemNumber(java.lang.Integer)],wrap=true] is empty.
156 [main] DEBUG org.apache.commons.betwixt.io.AbstractBeanWriter  - Writing: operator-id element: ElementDescriptor[qname=operator-id,pname=operatorId,class=class java.lang.String,singular=class java.lang.String,updater=MethodUpdater [method=public void com.boscovs.translator.dto.fulfillment.Comment.setOperatorId(java.lang.String)],wrap=true]
156 [main] DEBUG org.apache.commons.betwixt.io.AbstractBeanWriter  - Element ElementDescriptor[qname=operator-id,pname=operatorId,class=class java.lang.String,singular=class java.lang.String,updater=MethodUpdater [method=public void com.boscovs.translator.dto.fulfillment.Comment.setOperatorId(java.lang.String)],wrap=true] is empty.
156 [main] DEBUG org.apache.commons.betwixt.io.AbstractBeanWriter  - Writing: order-id element: ElementDescriptor[qname=order-id,pname=orderId,class=class java.lang.String,singular=class java.lang.String,updater=MethodUpdater [method=public void com.boscovs.translator.dto.fulfillment.Comment.setOrderId(java.lang.String)],wrap=true]
156 [main] DEBUG org.apache.commons.betwixt.io.AbstractBeanWriter  - Element ElementDescriptor[qname=order-id,pname=orderId,class=class java.lang.String,singular=class java.lang.String,updater=MethodUpdater [method=public void com.boscovs.translator.dto.fulfillment.Comment.setOrderId(java.lang.String)],wrap=true] is empty.
156 [main] DEBUG org.apache.commons.betwixt.io.AbstractBeanWriter  - Writing: text element: ElementDescriptor[qname=text,pname=text,class=class java.lang.String,singular=class java.lang.String,updater=MethodUpdater [method=public void com.boscovs.translator.dto.fulfillment.Comment.setText(java.lang.String)],wrap=true]
156 [main] DEBUG org.apache.commons.betwixt.io.AbstractBeanWriter  - Element ElementDescriptor[qname=text,pname=text,class=class java.lang.String,singular=class java.lang.String,updater=MethodUpdater [method=public void com.boscovs.translator.dto.fulfillment.Comment.setText(java.lang.String)],wrap=true] is empty.
156 [main] DEBUG org.apache.commons.betwixt.io.AbstractBeanWriter  - Popped from object stack: com.boscovs.translator.dto.fulfillment.Comment@16cd7d5
156 [main] DEBUG org.apache.commons.betwixt.io.AbstractBeanWriter  - Finished writing bean graph.
156 [main] DEBUG root  - xml:
  <com.boscovs.translator.dto.fulfillment.Comment>
    <comment-id>0</comment-id>
    <create-date/>
    <email-system-number>55</email-system-number>
    <operator-id>mzatko@boscovs.com</operator-id>
    <order-id>B111343</order-id>
    <text>This is text</text>
  </com.boscovs.translator.dto.fulfillment.Comment>

406 [main] DEBUG org.apache.commons.digester.Digester.sax  - setDocumentLocator(org.apache.xerces.parsers.AbstractSAXParser$LocatorProxy@b64435)
406 [main] DEBUG org.apache.commons.digester.Digester.sax  - startDocument()
453 [main] DEBUG org.apache.commons.digester.Digester.sax  - startPrefixMapping(xml,http://www.w3.org/XML/1998/namespace)
453 [main] DEBUG org.apache.commons.digester.Digester.sax  - startPrefixMapping(xmlns,http://www.w3.org/2000/xmlns/)
453 [main] DEBUG org.apache.commons.digester.Digester.sax  - startElement(,,com.boscovs.translator.dto.fulfillment.Comment)
453 [main] DEBUG org.apache.commons.digester.Digester  -   Pushing body text ''
453 [main] DEBUG org.apache.commons.digester.Digester  -   New match='com.boscovs.translator.dto.fulfillment.Comment'
453 [main] DEBUG org.apache.commons.digester.Digester  -   Fire begin() for ObjectCreateRule[className=com.boscovs.translator.dto.fulfillment.Comment, attributeName=null]
453 [main] DEBUG org.apache.commons.digester.Digester  - [ObjectCreateRule]{com.boscovs.translator.dto.fulfillment.Comment}New com.boscovs.translator.dto.fulfillment.Comment
453 [main] DEBUG org.apache.commons.digester.Digester.sax  - characters(
    )
453 [main] DEBUG org.apache.commons.digester.Digester.sax  - startPrefixMapping(xml,http://www.w3.org/XML/1998/namespace)
453 [main] DEBUG org.apache.commons.digester.Digester.sax  - startPrefixMapping(xmlns,http://www.w3.org/2000/xmlns/)
453 [main] DEBUG org.apache.commons.digester.Digester.sax  - startElement(,,comment-id)
453 [main] DEBUG org.apache.commons.digester.Digester  -   Pushing body text '
    '
453 [main] DEBUG org.apache.commons.digester.Digester  -   New match='com.boscovs.translator.dto.fulfillment.Comment/comment-id'
453 [main] DEBUG org.apache.commons.digester.Digester  -   No rules found matching 'com.boscovs.translator.dto.fulfillment.Comment/comment-id'.
468 [main] DEBUG org.apache.commons.digester.Digester.sax  - characters(0)
468 [main] DEBUG org.apache.commons.digester.Digester.sax  - endElement(,,comment-id)
468 [main] DEBUG org.apache.commons.digester.Digester  -   match='com.boscovs.translator.dto.fulfillment.Comment/comment-id'
468 [main] DEBUG org.apache.commons.digester.Digester  -   bodyText='0'
468 [main] DEBUG org.apache.commons.digester.Digester  -   No rules found matching 'com.boscovs.translator.dto.fulfillment.Comment/comment-id'.
468 [main] DEBUG org.apache.commons.digester.Digester  -   Popping body text '
    '
468 [main] DEBUG org.apache.commons.digester.Digester.sax  - endPrefixMapping(xml)
468 [main] DEBUG org.apache.commons.digester.Digester.sax  - endPrefixMapping(xmlns)
468 [main] DEBUG org.apache.commons.digester.Digester.sax  - characters(
    )
468 [main] DEBUG org.apache.commons.digester.Digester.sax  - startPrefixMapping(xml,http://www.w3.org/XML/1998/namespace)
468 [main] DEBUG org.apache.commons.digester.Digester.sax  - startPrefixMapping(xmlns,http://www.w3.org/2000/xmlns/)
468 [main] DEBUG org.apache.commons.digester.Digester.sax  - startElement(,,create-date)
468 [main] DEBUG org.apache.commons.digester.Digester  -   Pushing body text '
    
    '
468 [main] DEBUG org.apache.commons.digester.Digester  -   New match='com.boscovs.translator.dto.fulfillment.Comment/create-date'
468 [main] DEBUG org.apache.commons.digester.Digester  -   Fire begin() for CallMethodRule[methodName=setCreateDate, paramCount=0, paramTypes={java.sql.Timestamp}]
468 [main] DEBUG org.apache.commons.digester.Digester.sax  - endElement(,,create-date)
468 [main] DEBUG org.apache.commons.digester.Digester  -   match='com.boscovs.translator.dto.fulfillment.Comment/create-date'
468 [main] DEBUG org.apache.commons.digester.Digester  -   bodyText=''
468 [main] DEBUG org.apache.commons.digester.Digester  -   Fire body() for CallMethodRule[methodName=setCreateDate, paramCount=0, paramTypes={java.sql.Timestamp}]
468 [main] DEBUG org.apache.commons.digester.Digester  -   Popping body text '
    
    '
468 [main] DEBUG org.apache.commons.digester.Digester  -   Fire end() for CallMethodRule[methodName=setCreateDate, paramCount=0, paramTypes={java.sql.Timestamp}]
468 [main] DEBUG org.apache.commons.beanutils.ConvertUtils  - Convert string '' to class 'java.sql.Timestamp'
468 [main] DEBUG org.apache.commons.beanutils.ConvertUtils  -   Using converter org.apache.commons.beanutils.converters.SqlTimestampConverter@14c1103
484 [main] ERROR org.apache.commons.digester.Digester  - End event threw exception
org.apache.commons.beanutils.ConversionException: Timestamp format must be yyyy-mm-dd hh:mm:ss.fffffffff
	at org.apache.commons.beanutils.converters.SqlTimestampConverter.convert(SqlTimestampConverter.java:162)
	at org.apache.commons.beanutils.ConvertUtils.convert(ConvertUtils.java:379)
	at org.apache.commons.digester.CallMethodRule.end(CallMethodRule.java:457)
	at org.apache.commons.digester.Rule.end(Rule.java:276)
	at org.apache.commons.digester.Digester.endElement(Digester.java:1058)
	at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
	at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
	at org.apache.commons.digester.Digester.parse(Digester.java:1586)
	at test.TestDigesterCommentParser.parseWithDigester(TestDigesterCommentParser.java:57)
	at test.TestDigesterCommentParser.main(TestDigesterCommentParser.java:38)
Caused by: java.lang.IllegalArgumentException: Timestamp format must be yyyy-mm-dd hh:mm:ss.fffffffff
	at java.sql.Timestamp.valueOf(Unknown Source)
	at org.apache.commons.beanutils.converters.SqlTimestampConverter.convert(SqlTimestampConverter.java:157)
	... 16 more
org.apache.commons.beanutils.ConversionException: Timestamp format must be yyyy-mm-dd hh:mm:ss.fffffffff
	at org.apache.commons.digester.Digester.createSAXException(Digester.java:2540)
	at org.apache.commons.digester.Digester.createSAXException(Digester.java:2566)
	at org.apache.commons.digester.Digester.endElement(Digester.java:1061)
	at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
	at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
	at org.apache.commons.digester.Digester.parse(Digester.java:1586)
	at test.TestDigesterCommentParser.parseWithDigester(TestDigesterCommentParser.java:57)
	at test.TestDigesterCommentParser.main(TestDigesterCommentParser.java:38)
Exception in thread "main" 


Re: [Digester] Handling Null values

Posted by Simon Kitching <si...@ecnetwork.co.nz>.
On Tue, 2004-11-23 at 07:06, Mike Zatko wrote:
> I am trying to parse a document which has a Timestamp element which may 
> or may not be null. Does anyone know how to setup the addCallMethod to 
> handle this situation?
> 
> The one i've tried is as follows:
> 
> digester.addCallMethod(root + orderClass + 
> "/payments/payment/expiration-date", "setExpirationDate", 0, new 
> String[] {"java.sql.Timestamp"});

In most cases, if you call a method and the parameter data is not
present in the input, then null is passed to the target method.

According to the javadoc for the ConvertUtils class in the BeanUtils
library,  String->java.sql.Timestamp is a supported conversion, so
things should just work.

Please provide more details, including describing what occurs when you
try the code you listed above. Also try enabling debug logging for the
Digester library, and see if that helps (see
http://wiki.apache.org/jakarta-commons/Digester/FAQ for info on enabling
debug logging.

Regards,

Simon



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org