protected byte [ ] getData ( ) { if ( tc . isEntryEnabled ( ) ) Tr . entry ( tc , "getData" , this ) ; byte [ ] data = _data ; if ( data != null ) { // There is data cached in memory. Simply use this directly. if ( tc . isDebugEnabled ( ) ) Tr . debug ( tc , "Cached data located" ) ; } else { if ( _storageMode == MultiScopeRecoveryLog . FILE_BACKED ) { // There is no data cached in memory - it must be retrieved from disk. if ( tc . isDebugEnabled ( ) ) Tr . debug ( tc , "No cached data located. Attempting data retreival" ) ; // If there is no data cached in memory and we are operating in file // backed mode then retireve the data from disk. if ( _filePosition != UNWRITTEN ) { if ( tc . isDebugEnabled ( ) ) Tr . debug ( tc , "Retrieving " + _dataSize + " bytes of data @ position " + _filePosition ) ; _logRecord . position ( _filePosition ) ; data = new byte [ _dataSize ] ; _logRecord . get ( data ) ; } else { // The data should have been stored on disk but the file position was not set. Return null // to the caller and allow them to handle this failure. if ( tc . isDebugEnabled ( ) ) Tr . debug ( tc , "Unable to retrieve data as file position is not set" ) ; } } else { // The data should have been cached in memory but was not found Return null to the caller and // allow them to handle this failure. if ( tc . isDebugEnabled ( ) ) Tr . debug ( tc , "No cached data located" ) ; } } if ( tc . isEntryEnabled ( ) ) Tr . exit ( tc , "getData" , new Object [ ] { new Integer ( data . length ) , RLSUtils . toHexString ( data , RLSUtils . MAX_DISPLAY_BYTES ) } ) ; return data ; }
Returns the data encapsulated by this DataItem instance . If this DataItem is memory back the in memory copy of the data is always returned . If the DataItem is file backed and it has been written to disk the data is retrieved from disk and then returned .