You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Pau Minoves <pa...@i2cat.net> on 2010/11/30 11:17:19 UTC

[digester] keeping parsing logic out of the data model

Hi all,

We have some doubts here on how apache digester (2.1) is meant to be
used. I don't think we are on a strange scenario so there is probably
something we are missing.

In our case, we have a (bean) data model that we need to create from a
series of xmls. This data model represents network configuration and
we have xml's that come from different network devices. Each network
device produces different XMLs so we use a set of digester rules to
parse that into the data model.

So digester rules are device specific while our data model (wants to
be) is device agnostic.

The problem we see is that the digester forces us (via rules as
CallMethodRule) to include parsing logic in methods *inside* the data
model and that kind of breaks our hardware abstration layer.

I can illustrate this with an example. In one of the devices, a string
comes stating if an interface is "HALF-DUPLEX" or "FULL-DUPLEX", in
our data model, we have a boolean for that. We have this logic:

void bool isFullDuplex(String hardwareDependentString)
{
   if( hardwareDependentString.equalsIgnoreCase("FULL-DUPLEX")
       return true;
   else
       return false;
}

Using basic digester rules we have to create this method in the data
model while i would like to keep it next to the parser, as it is where
this kind of logic belongs.

Are we missing something? This is something that is happening all the
time to us (XMLs are quite hardware dependent) so we are open to
proposals :)

Any help is very much appreciated. Thanks,
Pau

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


Re: [digester] keeping parsing logic out of the data model

Posted by Pau Minoves <pa...@i2cat.net>.
Hi,

Thanks for the prompt response.

Thats very much what i would like, but then, how do i produce calls to
this class?

The rules i see only allow me to produce calls on the objects on the stack.

Best,
Pau

On Tue, Nov 30, 2010 at 2:56 PM, Adrian Crum <ad...@yahoo.com> wrote:
> You could put the parsing helper code in a separate class:
>
> public class ParserUtil {
>
>  public static boolean isFullDuplex(String hardwareDependentString) {
>    return hardwareDependentString.equalsIgnoreCase("FULL-DUPLEX");
>  }
> }
>
> -Adrian
>
> --- On Tue, 11/30/10, Pau Minoves <pa...@i2cat.net> wrote:
>> Hi all,
>>
>> We have some doubts here on how apache digester (2.1) is
>> meant to be
>> used. I don't think we are on a strange scenario so there
>> is probably
>> something we are missing.
>>
>> In our case, we have a (bean) data model that we need to
>> create from a
>> series of xmls. This data model represents network
>> configuration and
>> we have xml's that come from different network devices.
>> Each network
>> device produces different XMLs so we use a set of digester
>> rules to
>> parse that into the data model.
>>
>> So digester rules are device specific while our data model
>> (wants to
>> be) is device agnostic.
>>
>> The problem we see is that the digester forces us (via
>> rules as
>> CallMethodRule) to include parsing logic in methods
>> *inside* the data
>> model and that kind of breaks our hardware abstration
>> layer.
>>
>> I can illustrate this with an example. In one of the
>> devices, a string
>> comes stating if an interface is "HALF-DUPLEX" or
>> "FULL-DUPLEX", in
>> our data model, we have a boolean for that. We have this
>> logic:
>>
>> void bool isFullDuplex(String hardwareDependentString)
>> {
>>    if(
>> hardwareDependentString.equalsIgnoreCase("FULL-DUPLEX")
>>        return true;
>>    else
>>        return false;
>> }
>>
>> Using basic digester rules we have to create this method in
>> the data
>> model while i would like to keep it next to the parser, as
>> it is where
>> this kind of logic belongs.
>>
>> Are we missing something? This is something that is
>> happening all the
>> time to us (XMLs are quite hardware dependent) so we are
>> open to
>> proposals :)
>>
>> Any help is very much appreciated. Thanks,
>> Pau
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>



-- 
Pau Minoves
Network Technologies Cluster (CTX) - i2CAT Foundation, Barcelona
www.i2cat.net/en/cluster/network-technologies
T: +34 93 553 2518

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


Re: [digester] keeping parsing logic out of the data model

Posted by Adrian Crum <ad...@yahoo.com>.
You could put the parsing helper code in a separate class:

public class ParserUtil {

  public static boolean isFullDuplex(String hardwareDependentString) {
    return hardwareDependentString.equalsIgnoreCase("FULL-DUPLEX");
  }
}

-Adrian

--- On Tue, 11/30/10, Pau Minoves <pa...@i2cat.net> wrote:
> Hi all,
> 
> We have some doubts here on how apache digester (2.1) is
> meant to be
> used. I don't think we are on a strange scenario so there
> is probably
> something we are missing.
> 
> In our case, we have a (bean) data model that we need to
> create from a
> series of xmls. This data model represents network
> configuration and
> we have xml's that come from different network devices.
> Each network
> device produces different XMLs so we use a set of digester
> rules to
> parse that into the data model.
> 
> So digester rules are device specific while our data model
> (wants to
> be) is device agnostic.
> 
> The problem we see is that the digester forces us (via
> rules as
> CallMethodRule) to include parsing logic in methods
> *inside* the data
> model and that kind of breaks our hardware abstration
> layer.
> 
> I can illustrate this with an example. In one of the
> devices, a string
> comes stating if an interface is "HALF-DUPLEX" or
> "FULL-DUPLEX", in
> our data model, we have a boolean for that. We have this
> logic:
> 
> void bool isFullDuplex(String hardwareDependentString)
> {
>    if(
> hardwareDependentString.equalsIgnoreCase("FULL-DUPLEX")
>        return true;
>    else
>        return false;
> }
> 
> Using basic digester rules we have to create this method in
> the data
> model while i would like to keep it next to the parser, as
> it is where
> this kind of logic belongs.
> 
> Are we missing something? This is something that is
> happening all the
> time to us (XMLs are quite hardware dependent) so we are
> open to
> proposals :)
> 
> Any help is very much appreciated. Thanks,
> Pau



      

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