Salve vorrei porvi un problema in createBodyObjects() ho delle cose da stampare...
solo per come ho adesso il codice prima mi stampa quelle del primo for e poi quelle del secondo for...
Le 2 cose sono concatenate, ossia prima dovrebbe stampare il primo oggetto del for e poi tutte quelle del secondo for... invece così prima stampa tutte le cose del primo for e poi tutte le cose del secondo for separate...
un suggerimento?
codice:
 private void findBodyNodes(Node startingNode) {
        
        NodeList childNodes = startingNode.getChildNodes();
        
        for(int i = 0; i < childNodes.getLength(); i++) {
            
            Node actualNode = childNodes.item(i);
            if(isBodyNode(actualNode)) bodyNodes.addElement(actualNode);
            if(isrNode(actualNode)) rNodes.addElement(actualNode);
            if(actualNode.hasChildNodes()) findBodyNodes(actualNode);
        }
        
    }
     
    private boolean isBodyNode(Node node) {
        
        return node.getNodeName().equals("w:p");
    }
    
    private boolean isrNode(Node node) {
        
        return node.getNodeName().equals("w:r");
    }

    private void createBodyObjects() {
     
    for ( int i = 0; i < bodyNodes.size(); i++)
         {
            Node bodyNode = 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");
 			       }
 			
	bodyObjects.addElement(body);
 	}
 				
 	

   for ( int j = 0; j < rNodes.size(); j++)
         {
            Node rNode = rNodes.elementAt(j);	
	Body body = new Body();
             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();
	      }
               
                bodyObjects.addElement(body);       
         }
	
}         

    private void printBody(PrintWriter pw) {
    for ( int i = 0; i < bodyObjects.size(); i++)
     { Body body = bodyObjects.elementAt(i);
            System.out.println(body);
            pw.println(body);
            }
    }
       
    class Body {
        
        String stile;
        String jc;
        String grassetto;
        String italico;
        String testo;
        
        public String toString() {
            
            StringBuffer buffer = new StringBuffer();   
            buffer.append("Stile body: " + stile + "\n");
            if (jc != null)
            buffer.append(" Jc body: " + jc + "\n");
            if (grassetto != null)
            buffer.append(" Grassetto body " + grassetto + "\n");
            if (italico != null)
            buffer.append(" Italico body " + italico + "\n");
            if (testo != null)
            buffer.append(" Testo body: " + testo + "\n");
            return buffer.toString();
        }
    }
}