public Void call ( ) throws TTException { emitStartDocument ( ) ; long [ ] versionsToUse ; // if there are no versions specified, take the last one, of not version==0 if ( mVersions . length == 0 ) { if ( mSession . getMostRecentVersion ( ) > 0 ) { versionsToUse = new long [ ] { mSession . getMostRecentVersion ( ) } ; } // revision 0 = bootstrapped page else { versionsToUse = new long [ 0 ] ; } } // if there is any negative number specified, take the entire range of versions, otherwise take the // parameter else { // sort the versions first Arrays . sort ( mVersions ) ; if ( mVersions [ 0 ] < 0 ) { versionsToUse = new long [ ( int ) mSession . getMostRecentVersion ( ) - 1 ] ; for ( int i = 0 ; i < versionsToUse . length ; i ++ ) { versionsToUse [ i ] = i + 1 ; } } // otherwise take the versions as requested as params else { int index = Arrays . binarySearch ( mVersions , 1 ) ; versionsToUse = Arrays . copyOfRange ( mVersions , index , mVersions . length ) ; } } for ( int i = 0 ; i < versionsToUse . length ; i ++ ) { INodeReadTrx rtx = new NodeReadTrx ( mSession . beginBucketRtx ( versionsToUse [ i ] ) ) ; if ( versionsToUse == null || mVersions . length > 1 ) { emitStartManualElement ( i ) ; } rtx . moveTo ( mNodeKey ) ; final AbsAxis descAxis = new DescendantAxis ( rtx , true ) ; // Setup primitives. boolean closeElements = false ; long key = rtx . getNode ( ) . getDataKey ( ) ; // Iterate over all nodes of the subtree including self. while ( descAxis . hasNext ( ) ) { key = descAxis . next ( ) ; ITreeStructData currentStruc = ( ITreeStructData ) rtx . getNode ( ) ; // Emit all pending end elements. if ( closeElements ) { while ( ! mStack . empty ( ) && mStack . peek ( ) != currentStruc . getLeftSiblingKey ( ) ) { rtx . moveTo ( mStack . pop ( ) ) ; emitEndElement ( rtx ) ; rtx . moveTo ( key ) ; } if ( ! mStack . empty ( ) ) { rtx . moveTo ( mStack . pop ( ) ) ; emitEndElement ( rtx ) ; } rtx . moveTo ( key ) ; closeElements = false ; } // Emit node. emitStartElement ( rtx ) ; // Push end element to stack if we are a start element with // children. if ( currentStruc . getKind ( ) == IConstants . ELEMENT && currentStruc . hasFirstChild ( ) ) { mStack . push ( rtx . getNode ( ) . getDataKey ( ) ) ; } // Remember to emit all pending end elements from stack if // required. if ( ! currentStruc . hasFirstChild ( ) && ! currentStruc . hasRightSibling ( ) ) { closeElements = true ; } } // Finally emit all pending end elements. while ( ! mStack . empty ( ) ) { rtx . moveTo ( mStack . pop ( ) ) ; emitEndElement ( rtx ) ; } if ( versionsToUse == null || mVersions . length > 1 ) { emitEndManualElement ( i ) ; } } emitEndDocument ( ) ; return null ; }
Serialize the storage .