LimitPlanNode limitPlanNodeFromXml ( VoltXMLElement limitXml , VoltXMLElement offsetXml ) { if ( limitXml == null && offsetXml == null ) { return null ; } String node ; long limitParameterId = - 1 ; long offsetParameterId = - 1 ; long limit = - 1 ; long offset = 0 ; if ( limitXml != null ) { // Parse limit if ( ( node = limitXml . attributes . get ( "limit_paramid" ) ) != null ) { limitParameterId = Long . parseLong ( node ) ; } else { assert ( limitXml . children . size ( ) == 1 ) ; VoltXMLElement valueNode = limitXml . children . get ( 0 ) ; String isParam = valueNode . attributes . get ( "isparam" ) ; if ( ( isParam != null ) && ( isParam . equalsIgnoreCase ( "true" ) ) ) { limitParameterId = Long . parseLong ( valueNode . attributes . get ( "id" ) ) ; } else { node = limitXml . attributes . get ( "limit" ) ; assert ( node != null ) ; limit = Long . parseLong ( node ) ; } } } if ( offsetXml != null ) { // Parse offset if ( ( node = offsetXml . attributes . get ( "offset_paramid" ) ) != null ) { offsetParameterId = Long . parseLong ( node ) ; } else { if ( offsetXml . children . size ( ) == 1 ) { VoltXMLElement valueNode = offsetXml . children . get ( 0 ) ; String isParam = valueNode . attributes . get ( "isparam" ) ; if ( ( isParam != null ) && ( isParam . equalsIgnoreCase ( "true" ) ) ) { offsetParameterId = Long . parseLong ( valueNode . attributes . get ( "id" ) ) ; } else { node = offsetXml . attributes . get ( "offset" ) ; assert ( node != null ) ; offset = Long . parseLong ( node ) ; } } } } // limit and offset can't have both value and parameter if ( limit != - 1 ) assert limitParameterId == - 1 : "Parsed value and param. limit." ; if ( offset != 0 ) assert offsetParameterId == - 1 : "Parsed value and param. offset." ; LimitPlanNode limitPlanNode = new LimitPlanNode ( ) ; limitPlanNode . setLimit ( ( int ) limit ) ; limitPlanNode . setOffset ( ( int ) offset ) ; limitPlanNode . setLimitParameterIndex ( parameterCountIndexById ( limitParameterId ) ) ; limitPlanNode . setOffsetParameterIndex ( parameterCountIndexById ( offsetParameterId ) ) ; return limitPlanNode ; }
Produce a LimitPlanNode from the given XML