public UNode toDoc ( ) { // Root "results" node. UNode resultsNode = UNode . createMapNode ( "results" ) ; // "aggregate" node. UNode aggNode = resultsNode . addMapNode ( "aggregate" ) ; aggNode . addValueNode ( "metric" , m_metricParam , true ) ; if ( m_queryParam != null ) { aggNode . addValueNode ( "query" , m_queryParam , true ) ; } if ( m_groupingParam != null ) { aggNode . addValueNode ( "group" , m_groupingParam , true ) ; } // Add "totalobjects" if used. if ( m_totalObjects >= 0 ) { resultsNode . addValueNode ( "totalobjects" , Long . toString ( m_totalObjects ) ) ; } // Add global or summary value if present. if ( m_globalValue != null ) { if ( m_groupSetList == null ) { resultsNode . addChildNode ( UNode . createValueNode ( "value" , m_globalValue ) ) ; } else { resultsNode . addChildNode ( UNode . createValueNode ( "summary" , m_globalValue ) ) ; } } // If needed, the "groupsets" node becomes the new parent. UNode parentNode = resultsNode ; boolean bGroupSetsNode = false ; if ( m_groupSetList != null && m_groupSetList . size ( ) > 1 ) { bGroupSetsNode = true ; UNode groupSetsNode = parentNode . addArrayNode ( "groupsets" ) ; parentNode = groupSetsNode ; } // Add groupsets, if any, to the parent node. if ( m_groupSetList != null ) { for ( AggGroupSet groupSet : m_groupSetList ) { groupSet . addDoc ( parentNode , bGroupSetsNode ) ; } } return resultsNode ; }
Serialize this AggregateResult object into a UNode tree and return the root node . The root node is results .