public void write(ByteBuffer fileBuffer, boolean maintainPosition) throws InternalLogException, LogIncompatibleException
    {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "write", new Object[] { fileBuffer, new Boolean(maintainPosition), this });

        if (!_compatible)
        {
            if (tc.isEntryEnabled())
                Tr.exit(tc, "write", "LogIncompatibleException");
            throw new LogIncompatibleException();
        }

        if (_status == STATUS_INVALID)
        {
            if (tc.isEntryEnabled())
                Tr.exit(tc, "write", "LogHeaderInvalid - throwing InternalLogException");
            throw new InternalLogException(null);
        }

        try
        {
            int startPosition = 0;

            // If required, record the current position so that it can
            // be restored after updating the header.
            if (maintainPosition)
            {
                startPosition = fileBuffer.position();
            }

            // Move the file's position back to the start of the
            // file so that we write the header in the correct 
            // location.
            fileBuffer.position(0);

            // Write the length of the header.
            fileBuffer.putInt(headerSize() +
                              _serverNameBytes.length +
                              _serviceNameBytes.length +
                              _logNameBytes.length);

            // Write the "MAGIC" number at the top of the header. This is to help
            // identify the file as a WebSphere recovery log file.
            fileBuffer.put(LogFileHeader.MAGIC_NUMBER);

            // Write the version number of the RLS implementation.
            fileBuffer.putInt(Configuration.RLS_VERSION);

            // Status field
            fileBuffer.putInt(_status);

            // Date of file creation/update
            fileBuffer.putLong(_date);

            // Sequence Number of first entry
            fileBuffer.putLong(_firstRecordSequenceNumber);

            // Server Name
            fileBuffer.putInt(_serverNameBytes.length);
            fileBuffer.put(_serverNameBytes);

            // Service Name
            fileBuffer.putInt(_serviceNameBytes.length);
            fileBuffer.put(_serviceNameBytes);

            // Service version
            fileBuffer.putInt(_serviceVersion);

            // Log Name
            fileBuffer.putInt(_logNameBytes.length);
            fileBuffer.put(_logNameBytes);

            // calculate length of the variable data
            int varLength = 0;
            if (_variableFieldData != null && _useVariableFieldHeader)
            {
                varLength += VARIABLE_FIELD_HEADER.length; // not included until we have variable data otherwise header may grow before a keypoint
                varLength += RLSUtils.INT_SIZE; // the length of the variable data
                varLength += _variableFieldData.length;
            }

            // Length of Service Data
            if (_serviceData != null)
            {
                varLength += _serviceData.length;
            }

            // write variable data length
            fileBuffer.putInt(varLength);

            if (_variableFieldData != null && _useVariableFieldHeader)
            {
                fileBuffer.put(VARIABLE_FIELD_HEADER);

                // write RLS variable field
                fileBuffer.putInt(_variableFieldData.length);
                fileBuffer.put(_variableFieldData);
            }

            // write service data
            if (_serviceData != null)
            {
                fileBuffer.put(_serviceData);
            }

            // Date Of Creation (re-written to provide validation of previous information)
            fileBuffer.putLong(_date);

            // Sequence Number of first entry (re-written to provide validation of previous information)
            if (tc.isDebugEnabled())
                Tr.debug(tc, "Writing FRSN " + _firstRecordSequenceNumber + " at position " + fileBuffer.position() + " in log file " + _logName);
            fileBuffer.putLong(_firstRecordSequenceNumber);

            // Reset the file position if required
            if (maintainPosition)
            {
                fileBuffer.position(startPosition);
            }
        } catch (BufferUnderflowException exc)
        {
            FFDCFilter.processException(exc, "com.ibm.ws.recoverylog.spi.LogFileHeader.write", "449", this);
            if (tc.isEntryEnabled())
                Tr.exit(tc, "write", "InternalLogException");
            throw new InternalLogException(exc);
        } catch (Throwable exc)
        {
            FFDCFilter.processException(exc, "com.ibm.ws.recoverylog.spi.LogFileHeader.write", "455", this);
            if (tc.isEntryEnabled())
                Tr.exit(tc, "write", "InternalLogException");
            throw new InternalLogException(exc);
        }

        if (tc.isEntryEnabled())
            Tr.exit(tc, "write");
    }
public void write ( ByteBuffer fileBuffer , boolean maintainPosition ) throws InternalLogException , LogIncompatibleException { if ( tc . isEntryEnabled ( ) ) Tr . entry ( tc , "write" , new Object [ ] { fileBuffer , new Boolean ( maintainPosition ) , this } ) ; if ( ! _compatible ) { if ( tc . isEntryEnabled ( ) ) Tr . exit ( tc , "write" , "LogIncompatibleException" ) ; throw new LogIncompatibleException ( ) ; } if ( _status == STATUS_INVALID ) { if ( tc . isEntryEnabled ( ) ) Tr . exit ( tc , "write" , "LogHeaderInvalid - throwing InternalLogException" ) ; throw new InternalLogException ( null ) ; } try { int startPosition = 0 ; if ( maintainPosition ) { startPosition = fileBuffer . position ( ) ; } fileBuffer . position ( 0 ) ; fileBuffer . putInt ( headerSize ( ) + _serverNameBytes . length + _serviceNameBytes . length + _logNameBytes . length ) ; fileBuffer . put ( LogFileHeader . MAGIC_NUMBER ) ; fileBuffer . putInt ( Configuration . RLS_VERSION ) ; fileBuffer . putInt ( _status ) ; fileBuffer . putLong ( _date ) ; fileBuffer . putLong ( _firstRecordSequenceNumber ) ; fileBuffer . putInt ( _serverNameBytes . length ) ; fileBuffer . put ( _serverNameBytes ) ; fileBuffer . putInt ( _serviceNameBytes . length ) ; fileBuffer . put ( _serviceNameBytes ) ; fileBuffer . putInt ( _serviceVersion ) ; fileBuffer . putInt ( _logNameBytes . length ) ; fileBuffer . put ( _logNameBytes ) ; int varLength = 0 ; if ( _variableFieldData != null && _useVariableFieldHeader ) { varLength += VARIABLE_FIELD_HEADER . length ; varLength += RLSUtils . INT_SIZE ; varLength += _variableFieldData . length ; } if ( _serviceData != null ) { varLength += _serviceData . length ; } fileBuffer . putInt ( varLength ) ; if ( _variableFieldData != null && _useVariableFieldHeader ) { fileBuffer . put ( VARIABLE_FIELD_HEADER ) ; fileBuffer . putInt ( _variableFieldData . length ) ; fileBuffer . put ( _variableFieldData ) ; } if ( _serviceData != null ) { fileBuffer . put ( _serviceData ) ; } fileBuffer . putLong ( _date ) ; if ( tc . isDebugEnabled ( ) ) Tr . debug ( tc , "Writing FRSN " + _firstRecordSequenceNumber + " at position " + fileBuffer . position ( ) + " in log file " + _logName ) ; fileBuffer . putLong ( _firstRecordSequenceNumber ) ; if ( maintainPosition ) { fileBuffer . position ( startPosition ) ; } } catch ( BufferUnderflowException exc ) { FFDCFilter . processException ( exc , "com.ibm.ws.recoverylog.spi.LogFileHeader.write" , "449" , this ) ; if ( tc . isEntryEnabled ( ) ) Tr . exit ( tc , "write" , "InternalLogException" ) ; throw new InternalLogException ( exc ) ; } catch ( Throwable exc ) { FFDCFilter . processException ( exc , "com.ibm.ws.recoverylog.spi.LogFileHeader.write" , "455" , this ) ; if ( tc . isEntryEnabled ( ) ) Tr . exit ( tc , "write" , "InternalLogException" ) ; throw new InternalLogException ( exc ) ; } if ( tc . isEntryEnabled ( ) ) Tr . exit ( tc , "write" ) ; }
<p>
Write the full header information contained in the target header to the data
output stream. This method is used by the LogFileHandle class to format the
header so it can be written to the corresponding log file.
</p>

<p>
The LogFileHeader.read method can be used to recover this information
when the file is reloaded.
</p>

@param dataOutput The buffer into which the header information should be
formatted.

@exception LogIncompatibleException The target object represents an incompatible header.
@exception InternalLogException An unexpected error has occured.