textbender.a.u.transfer.clipboard
Class IndexBlock

java.lang.Object
  extended by IndexBlock
All Implemented Interfaces:
Serializable, Comparable<IndexBlock>

@ThreadRestricted
final class IndexBlock
extends Object
implements Comparable<IndexBlock>, Serializable

Maps between clip indeces and g-indeces.


Nested Class Summary
(package private) static class IndexBlock.SourceParse
          Parser results...
 
Constructor Summary
IndexBlock(long clipIndex0, int size, File sourceDocumentFile)
          Creates an IndexBlock.
 
Method Summary
(package private)  long clipIndex0()
          The leading clip-index of this block.
(package private)  long clipIndexOf(int gIndex)
           
 int compareTo(IndexBlock other)
          Compares based on clipIndex0.
 boolean equals(Object o)
          Returns true iff o is an index block with the same clipIndex0.
(package private)  int gIndexOf(long clipIndex)
           
(package private)  int size()
          Capacity of this block, in terms of unique clip indeces it can map.
(package private)  File sourceDocumentFile()
          Cached copy of the transfer source document.
(package private)  IndexBlock.SourceParse sourceParse(DOMImplementationLS domLS, LSParser parser, StringBuilder b, UUIDStringifier uuidStringifier)
          Returns parser results for the document, and caches them for later calls.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IndexBlock

IndexBlock(long clipIndex0,
           int size,
           File sourceDocumentFile)
Creates an IndexBlock.

Parameters:
clipIndex0 - per clipIndex0()
size - per size()
sourceDocumentFile - per sourceDocumentFile()
Method Detail

clipIndex0

long clipIndex0()
The leading clip-index of this block.


clipIndexOf

long clipIndexOf(int gIndex)
Parameters:
gIndex - of a gene of the document
Returns:
clipIndex to which that gene is mapped

gIndexOf

int gIndexOf(long clipIndex)
Parameters:
clipIndex - of a clip gene
Returns:
gIndex of the corresponding source gene in the document

size

int size()
Capacity of this block, in terms of unique clip indeces it can map. The size is at least as large as the document's gene count.


sourceDocumentFile

File sourceDocumentFile()
Cached copy of the transfer source document.

Since index blocks are used for multiple soure document versions, the source document may include changes made since the clip-gene was originally created, when the transfer was initiated. Using it to complete the transfer (carrying meta-data over to the target, etc.) may lead to postive ancestry errors (over-attribution), and the appearance that transfer occured from the later version of the soure.

This anachronism could be corrected at the cost of increased storage space, and longer clip indeces in the text; or of more complicated code. But its consequences are mild. Usually the anomaly will be rare, especially if replacement is not over-delayed. However, when a transfer is made from an older version of a document, while a newer one is still in the cache, even immediate replacement will not help.


sourceParse

IndexBlock.SourceParse sourceParse(DOMImplementationLS domLS,
                                   LSParser parser,
                                   StringBuilder b,
                                   UUIDStringifier uuidStringifier)
                             throws IOException,
                                    TextbenderException
Returns parser results for the document, and caches them for later calls.

Parameters:
domLS - DOM implementation to use
parser - parser to use
b - string builder to use, overwriting its existing content
uuidStringifier - UUID stringifier to use
Returns:
parser results, or null if the last call resulted in an exception
Throws:
TextbenderException - if document cannot be parsed
IOException

compareTo

public int compareTo(IndexBlock other)
Compares based on clipIndex0.

Specified by:
compareTo in interface Comparable<IndexBlock>
See Also:
equals(Object)

equals

public boolean equals(Object o)
Returns true iff o is an index block with the same clipIndex0.

Overrides:
equals in class Object
See Also:
compareTo(IndexBlock)