greenstone.org greenstone wiki greenstone trac planet greenstone

Changeset 15669

Show
Ignore:
Timestamp:
2008-05-23 12:35:40 (6 months ago)
Author:
ak19
Message:

Corrected logic error in setting NodeData?.hasChildren member in constructor

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • other-projects/trunk/gs3-webservices-democlient/src/GS3DemoClient/org/greenstone/gs3client/data/NodeData.java

    r15222 r15669  
    6565         * or <documentNode nodeID = "x" /> */ 
    6666        public NodeData(Element nodeTag) { 
    67                 this.nodeTag = nodeTag; // store this node's tag information. Useful 
    68                                         // for when we are setting the children of this NodeData 
    69                 this.hasChildren = this.nodeTag.hasChildNodes(); 
    70                  
    71                 // We'd definitely have the nodeID attribute, but to be on the safe  
    72                 // side, check it's there first: 
    73                 this.nodeID = nodeTag.hasAttribute(GSXML.NODE_ID_ATT) ? 
    74                         nodeTag.getAttribute(GSXML.NODE_ID_ATT) : ""; 
     67            this.nodeTag = nodeTag; // store this node's tag information. Useful 
     68                         // for when we are setting the children of this NodeData 
     69 
     70            // We'd definitely have the nodeID attribute, but to be on the safe  
     71            // side, check it's there first: 
     72            this.nodeID = nodeTag.hasAttribute(GSXML.NODE_ID_ATT) ? 
     73                nodeTag.getAttribute(GSXML.NODE_ID_ATT) : ""; 
     74             
     75            // To determine whether this DocumentNodeData has children, we need  
     76            // to know whether the DocumentNodeElement it represents has child  
     77            // DocNodeElements. This kind of information is embedded inside a  
     78            // nodeStructure element which will often contain a repeat of the   
     79            // nodeTag-documentNodeElement itself. Therefore, we get the nodeTag's  
     80            // first descendent element that is a documentNodeElement and check  
     81            // whether it too has the same nodeID. If so, then we check whether   
     82            // that documentNodeElement has child nodes - which in that case will  
     83            // all be documentNodeElements.  
     84            Element innerDocNode = ParseUtil.getFirstDescElementCalled( 
     85                                   nodeTag, GSXML.DOC_NODE_ELEM); 
     86            if(innerDocNode == null 
     87               || !innerDocNode.getAttribute(GSXML.NODE_ID_ATT).equals(this.nodeID))  
     88                { 
     89                    innerDocNode = this.nodeTag; 
     90                } 
     91            this.hasChildren = innerDocNode.hasChildNodes(); 
    7592        }        
    7693