org.crosswire.jsword.book.sword.state
Class RawFileBackendState

java.lang.Object
  extended by org.crosswire.jsword.book.sword.state.AbstractOpenFileState
      extended by org.crosswire.jsword.book.sword.state.RawBackendState
          extended by org.crosswire.jsword.book.sword.state.RawFileBackendState
All Implemented Interfaces:
Closeable, OpenFileState

public class RawFileBackendState
extends RawBackendState

Stores the random access files required for processing the passage request The caller is required to close to correctly free resources and avoid File pointer leaks

Author:
DM Smith
See Also:
The GNU Lesser General Public License for details.

Field Summary
private  File incfile
           
static String INCFILE
           
private  int incfileValue
           
private static org.slf4j.Logger log
          The log stream
 
Fields inherited from class org.crosswire.jsword.book.sword.state.RawBackendState
ntIdxFile, ntIdxRaf, ntTextFile, ntTextRaf, otIdxFile, otIdxRaf, otTextFile, otTextRaf
 
Constructor Summary
RawFileBackendState(SwordBookMetaData bookMetaData)
          This is default package access for forcing the use of the OpenFileStateManager to manage the creation.
 
Method Summary
private  boolean existsAndCanReadAndWrite(File file)
          Returns true if the file exists, can be read and can be written to.
 File getIncfile()
           
 int getIncfileValue()
           
private  void initIncFile()
           
 boolean isWritable()
           
private  int readIncfile()
           
 void setIncfile(File incfile)
           
 void setIncfileValue(int incValue)
           
 
Methods inherited from class org.crosswire.jsword.book.sword.state.RawBackendState
getBookMetaData, getIdxFile, getIdxRaf, getNtTextRaf, getOtTextRaf, getTextFile, getTextRaf, releaseResources
 
Methods inherited from class org.crosswire.jsword.book.sword.state.AbstractOpenFileState
close, getLastAccess, setLastAccess
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INCFILE

public static final String INCFILE
See Also:
Constant Field Values

incfile

private File incfile

incfileValue

private int incfileValue

log

private static final org.slf4j.Logger log
The log stream

Constructor Detail

RawFileBackendState

RawFileBackendState(SwordBookMetaData bookMetaData)
              throws BookException
This is default package access for forcing the use of the OpenFileStateManager to manage the creation. Not doing so may result in new instances of OpenFileState being created for no reason, and as a result, if they are released to the OpenFileStateManager by mistake this would result in leakage

Parameters:
bookMetaData - the appropriate metadata for the book
Throws:
BookException
Method Detail

isWritable

public boolean isWritable()
Overrides:
isWritable in class RawBackendState

existsAndCanReadAndWrite

private boolean existsAndCanReadAndWrite(File file)
Returns true if the file exists, can be read and can be written to.

Parameters:
file - the file
Returns:
true, if successful

readIncfile

private int readIncfile()
                 throws IOException
Throws:
IOException

initIncFile

private void initIncFile()

getIncfileValue

public int getIncfileValue()
Returns:
the incfileValue

setIncfileValue

public void setIncfileValue(int incValue)

getIncfile

public File getIncfile()
Returns:
the incfile

setIncfile

public void setIncfile(File incfile)
Parameters:
incfile - the incfile to set

Copyright ยจ 2003-2015