[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jakarta-commons-user
Subject:    Re: [digester] Help needed
From:       José_Antonio_Pérez_Testa <japtesta () indra ! es>
Date:       2004-11-29 8:42:19
Message-ID: 41AAE0EB.5010100 () indra ! es
[Download RAW message or body]

Hi Ray,
My advice is to create 2 utility classes one to manage the process of 
the ArrayList and the Map.

class MyArrayList extends ArrayList {
private String name;
public void setName(String name){this.name=name;}
public String getName() {return name}
}

class MyHashMap extends HashMap {

public void putIt (MyArrayList obj) {
    super.put(obj.getName(), obj);
}
}
and .... (see below) ( the name and parameters of the rules could be 
innaccurate ;) )
Ray Madigan wrote:

> I have not been using the digester for a long time, but up until now I have
> been able to figure out everything on my own.  I have a situation that I
> don't know if it can be done the way I want to do it,  So I thought I would
> ask.
> 
> The xml I want to digest looks like
> 
> <tran>
> <processMap>
> <process name="A">
> <top>"AB"</top>
> <top>"AC"</top>
> <top>"AD"</top>
> </process>
> <process name="C">
> <top>"AB"</top>
> <top>"CC"</top>
> <top>"AD"</top>
> </process>
> <process name="F">
> <top>"CB"</top>
> <top>"AC"</top>
> <top>"FD"</top>
> </process>
> </processMap>
> </tran>
> 
> The class I want to fill in is like
> 
> public class processMap {
> private HashMap map;
> 
> public processMap ( ) {
> }
> 
> public void setProcessMap ( HashMap map ) {
> this.map = map;
> }
> 
> public HashMap getProcessMap ( ) {
> return map;
> }
> }
> 
> The digester rules are like
> 
> // Create the HashMap and push it on the stack
> 
> 
addObjectCreate ( "tran/processMap", MyHashMap.class );

> // Create the ArrayList and push it on the stack
> 
> 
addObjectCreate ( "tran/processMap/process", MyArrayList );
addSetProperties ("tran/processMap/process");
addSetNext("tran/processMap/process","putIt");

> //
> //  Don't know how to get to the process attribute name
> //  Don't know how to call HashMap.put with the key as the
> //  process attribute name value ant the value as the ArrayList
> //  that is currently at the top of the stack
> 
> //  Add the top values to the array list
> addCallMethod ( "tran/processMap/process/top", add, 1 );
> addCallParam ( "tran/processMap/process/top", 0 );
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 
-------------------------------------------------------------------------------------------------------------------
 Este correo electrónico y, en su caso, cualquier fichero anexo al mismo, contiene \
información de carácter confidencial exclusivamente dirigida a su destinatario o \
destinatarios. Queda prohibida su divulgación, copia o distribución a terceros sin la \
previa autorización escrita de Indra. En el caso de haber recibido este correo \
electrónico por error, se ruega notificar inmediatamente esta circunstancia mediante \
reenvío a la dirección electrónica del remitente.

The information in this e-mail and in any attachments is confidential and solely for \
the attention and use of the named addressee(s). You are hereby notified that any \
dissemination, distribution or copy of this communication is prohibited without the \
prior written consent of Indra. If you have received this communication in error, \
please, notify the sender by reply e-mail

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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic