com.timeindexing.io
Class IndexHeaderIO

java.lang.Object
  extended bycom.timeindexing.index.DefaultIndexHeader
      extended bycom.timeindexing.io.IndexDecoder
          extended bycom.timeindexing.io.IndexHeaderIO
All Implemented Interfaces:
java.lang.Cloneable, ExtendedIndexHeader, HeaderFileInteractor, IndexHeader, IndexHeaderReader, IndexHeaderWriter, ManagedIndexHeader

public class IndexHeaderIO
extends IndexDecoder
implements HeaderFileInteractor, IndexHeader, java.lang.Cloneable

An Index Header IO object. It represents the file version of an index header in core.


Constructor Summary
IndexHeaderIO(IndexFileInteractor indexInteractor)
          Create a IndexHeaderIO.
 
Method Summary
 long close()
          Operation on close
protected  java.nio.ByteBuffer convertOptions()
          Convert the options to their file format.
 boolean create(java.lang.String filename)
          Create an index header.
 boolean create(java.lang.String filename, java.util.Properties options)
          Create an index header.
 long flush()
          Flush the current values to the header file.
 java.nio.channels.FileLock getWriteLock()
          Get a write-lock on this index.
 boolean isWriteLocked()
          Has the Index been write-locked.
 boolean open(java.lang.String filename)
          Open an index header.
protected  int processDataPath(HeaderOptionProcess what, HeaderOption anOption, java.nio.ByteBuffer optionBuffer)
          A data path name.
protected  int processDataType(HeaderOptionProcess what, HeaderOption anOption, java.nio.ByteBuffer optionBuffer)
          A data type.
protected  int processDescription(HeaderOptionProcess what, HeaderOption anOption, java.nio.ByteBuffer optionBuffer)
          A description.
protected  int processIndexPath(HeaderOptionProcess what, HeaderOption anOption, java.nio.ByteBuffer optionBuffer)
          An index path name.
protected  int processIsInTimeOrder(HeaderOptionProcess what, HeaderOption anOption, java.nio.ByteBuffer optionBuffer)
          Is the index in time order
protected  int processNoDataFileHeader(HeaderOptionProcess what, HeaderOption anOption, java.nio.ByteBuffer optionBuffer)
          Is there a header on the data file
protected  int processReferenceMapping(HeaderOptionProcess what, HeaderOption anOption, java.nio.ByteBuffer optionBuffer)
          The referenced indexes mapping
protected  long reallyClose()
          The final close functionaliy.
 boolean releaseWriteLock()
          Release a FileLock.
protected  void syncWithIndex()
          Sync this header with the Index header, and write it out, if required to.
 long write()
          Write the contents of the header file out It assumes the header file is alreayd open for writing.
protected  long writeToChannel(java.nio.channels.FileChannel channel)
          Write the contents of the header file out It assumes the header file is alreayd open for writing.
 
Methods inherited from class com.timeindexing.io.IndexDecoder
exists, getHeaderLength, getHeaderPathName, isOpen, open, processDataPath, processDataType, processDescription, processIndexPath, processIsInTimeOrder, processNoDataFileHeader, processReferenceMapping, read, readFromChannel
 
Methods inherited from class com.timeindexing.index.DefaultIndexHeader
addDataType, addIndexURI, getAllOptions, getAnnotationStyle, getDataPathName, getDataSize, getDataType, getDescription, getEndTime, getFirstDataTime, getFirstOffset, getFirstTime, getID, getIndexDataType, getIndexPathName, getIndexType, getIndexURI, getItemSize, getLastDataTime, getLastOffset, getLastTime, getLength, getName, getOption, getStartTime, getURI, getValue, getVersionMajor, getVersionMinor, hasAnnotations, hasDataType, hasIndexURI, hasOption, isFixedSizeData, isInTimeOrder, isReadOnly, isTerminated, listOptions, notInTimeOrder, setDataPathName, setDataSize, setDescription, setEndTime, setFirstDataTime, setFirstOffset, setFirstTime, setID, setIndexDataType, setIndexPathName, setIndexType, setInTimeOrder, setItemSize, setLastDataTime, setLastOffset, setLastTime, setLength, setName, setOption, setOptions, setReadOnly, setStartTime, setTerminated, setURI, setVersionMajor, setVersionMinor, syncHeader, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.timeindexing.io.IndexHeaderReader
isOpen, read
 
Methods inherited from interface com.timeindexing.io.IndexHeaderWriter
isOpen
 
Methods inherited from interface com.timeindexing.index.IndexHeader
getDataPathName, getDataSize, getDescription, getEndTime, getFirstDataTime, getFirstTime, getID, getIndexDataType, getIndexPathName, getIndexType, getLastDataTime, getLastTime, getLength, getName, getStartTime, getURI, isFixedSizeData, isInTimeOrder, isReadOnly, isTerminated
 
Methods inherited from interface com.timeindexing.index.ManagedIndexHeader
addIndexURI, getAllOptions, getIndexURI, getOption, hasIndexURI, hasOption, listOptions, notInTimeOrder, setDataPathName, setDataSize, setDescription, setEndTime, setFirstDataTime, setFirstOffset, setFirstTime, setID, setIndexDataType, setIndexPathName, setIndexType, setItemSize, setLastDataTime, setLastOffset, setLastTime, setLength, setName, setOption, setOptions, setReadOnly, setStartTime, setTerminated, setURI, syncHeader
 
Methods inherited from interface com.timeindexing.index.ExtendedIndexHeader
addDataType, getAnnotationStyle, getDataSize, getDataType, getFirstOffset, getItemSize, getLastOffset, hasAnnotations, hasDataType
 

Constructor Detail

IndexHeaderIO

public IndexHeaderIO(IndexFileInteractor indexInteractor)
Create a IndexHeaderIO.

Method Detail

open

public boolean open(java.lang.String filename)
             throws java.io.IOException
Open an index header.

Specified by:
open in interface IndexHeaderReader
Overrides:
open in class IndexDecoder
Throws:
java.io.IOException

create

public boolean create(java.lang.String filename)
               throws java.io.IOException
Create an index header.

Specified by:
create in interface IndexHeaderWriter
Throws:
java.io.IOException

create

public boolean create(java.lang.String filename,
                      java.util.Properties options)
               throws java.io.IOException
Create an index header.

Specified by:
create in interface IndexHeaderWriter
Throws:
java.io.IOException

flush

public long flush()
           throws java.io.IOException
Flush the current values to the header file.

Specified by:
flush in interface IndexHeaderWriter
Throws:
java.io.IOException

getWriteLock

public java.nio.channels.FileLock getWriteLock()
Get a write-lock on this index.


releaseWriteLock

public boolean releaseWriteLock()
Release a FileLock.


isWriteLocked

public boolean isWriteLocked()
Has the Index been write-locked.


syncWithIndex

protected void syncWithIndex()
                      throws java.io.IOException
Sync this header with the Index header, and write it out, if required to.

Throws:
java.io.IOException

close

public long close()
           throws java.io.IOException
Operation on close

Specified by:
close in interface IndexHeaderReader
Overrides:
close in class IndexDecoder
Throws:
java.io.IOException

reallyClose

protected long reallyClose()
                    throws java.io.IOException
The final close functionaliy. Release the write lock, and really really close.

Throws:
java.io.IOException

write

public long write()
           throws java.io.IOException
Write the contents of the header file out It assumes the header file is alreayd open for writing.

Specified by:
write in interface IndexHeaderWriter
Returns:
the total no of bytes written
Throws:
java.io.IOException

writeToChannel

protected long writeToChannel(java.nio.channels.FileChannel channel)
                       throws java.io.IOException
Write the contents of the header file out It assumes the header file is alreayd open for writing.

Returns:
the total no of bytes written
Throws:
java.io.IOException

convertOptions

protected java.nio.ByteBuffer convertOptions()
Convert the options to their file format.


processDescription

protected int processDescription(HeaderOptionProcess what,
                                 HeaderOption anOption,
                                 java.nio.ByteBuffer optionBuffer)
A description.


processIndexPath

protected int processIndexPath(HeaderOptionProcess what,
                               HeaderOption anOption,
                               java.nio.ByteBuffer optionBuffer)
An index path name.


processDataPath

protected int processDataPath(HeaderOptionProcess what,
                              HeaderOption anOption,
                              java.nio.ByteBuffer optionBuffer)
A data path name.


processDataType

protected int processDataType(HeaderOptionProcess what,
                              HeaderOption anOption,
                              java.nio.ByteBuffer optionBuffer)
A data type.


processIsInTimeOrder

protected int processIsInTimeOrder(HeaderOptionProcess what,
                                   HeaderOption anOption,
                                   java.nio.ByteBuffer optionBuffer)
Is the index in time order


processNoDataFileHeader

protected int processNoDataFileHeader(HeaderOptionProcess what,
                                      HeaderOption anOption,
                                      java.nio.ByteBuffer optionBuffer)
Is there a header on the data file


processReferenceMapping

protected int processReferenceMapping(HeaderOptionProcess what,
                                      HeaderOption anOption,
                                      java.nio.ByteBuffer optionBuffer)
The referenced indexes mapping