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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
------------------------------------------------------------------------------------------------------------------- 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
