Io ho queste 2 funzioni createBodyObjects() e createRObjects().
Io vorrei che mi memorizzasse in body prima 1 volta i valori di createBodyObjects() e poi entrasse in createRObjects() fino a che w:r non è uguale a null e mi memorizzasse i valori.
Poi dovrebbe ripassare a createBodyObjects() e incrementare i e memorizzare i valori, e poi rientrare nella seconda fino a che w:r non è uguale a null....
Dovrebbe fare questo fino a che i < bodyNodes.size(); (bodyNodes.size();=869 nel mio caso...)
Serve la ricorsione???
Qualcuno può aiutarmi a mettere in JAVA quello che ho detto?
Perchè ora come ora fa così entra in createBodyObjects() prende i valori, va in createRObjects() solo 1 volta prende il primo valore di w:r e torna createBodyObjects() e fai il giro prendendo sempre e solo il primo valore di w:r...
codice:
private void createBodyObjects() {
for ( int i = 0; i < bodyNodes.size(); i++) {
Node bodyNode = (Node)bodyNodes.elementAt(i);
Body body = new Body();
Node paragraphNode = getChildNode(bodyNode, "w:pPr");
if ( paragraphNode != null ) {
Node stileNode = getChildNode(paragraphNode, "w:pStyle");
if ( stileNode != null )
body.stile = getAttributeValue(stileNode, "w:val");
Node jcNode = getChildNode(paragraphNode, "w:jc");
if ( jcNode != null )
body.jc = getAttributeValue(jcNode, "w:val");
}
createRObjects(body, bodyNode);
bodyObjects.addElement(body);
}
}
private void createRObjects(Body body, Node bodyNode) {
Node rNode = getChildNode(bodyNode, "w:r");
if ( rNode != null ) {
Node rPrNode = getChildNode(rNode, "w:rPr");
if ( rPrNode != null ) {
Node grassettoNode = getChildNode(rPrNode, "w:b");
if ( grassettoNode != null )
body.grassetto = getAttributeValue(grassettoNode, "w:val");
Node italicoNode = getChildNode(rPrNode, "w:i");
if ( italicoNode != null )
body.italico = getAttributeValue(italicoNode, "w:val");
}
Node testoNode = getChildNode(rNode, "w:t");
if ( testoNode != null ) {
Node testoNode1 = getChildNode(testoNode, "#text");
if ( testoNode1 != null )
body.testo = testoNode1.getNodeValue();
}
}
}