jigcell.compare.data
Class PackedTreeDataElement

java.lang.Object
  extended by javax.swing.TransferHandler
      extended by jigcell.compare.impl.Transferer
          extended by jigcell.compare.data.DataElement
              extended by jigcell.compare.data.EditableDataElement
                  extended by jigcell.compare.data.TreeDataElement
                      extended by jigcell.compare.data.PackedTreeDataElement
All Implemented Interfaces:
java.awt.datatransfer.Transferable, java.io.Serializable, IDataElement, IEditableDataElement
Direct Known Subclasses:
PackedTreeDataElement2

public class PackedTreeDataElement
extends TreeDataElement

An implementation of EditableDataElement that uses a red-black tree to store values. The tree keys are boxed. Each key can hold a pack of values so this structure uses less memory than SparseTreeDataElement for dense collections. The size of the pack is adjustable. PackedTreeDataElement does not protect against concurrent edits. The maximum number of values this element can contain is approximately 2^60, but is likely to fail before then.

This code is licensed under the DARPA BioCOMP Open Source License. See LICENSE for more details.

Author:
Nicholas Allen
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class jigcell.compare.data.EditableDataElement
EditableDataElement.EditableDataElementDelegate
 
Nested classes/interfaces inherited from interface jigcell.compare.IDataElement
IDataElement.Type
 
Field Summary
protected static java.lang.String MESSAGE_CHUNKSIZEERROR
          Error message when the chunk size is too small
protected static java.lang.String MESSAGE_LASTERROR
          Error message when the last value in a pack is incorrect
protected  long size
          Element packing size
protected static int SIZE_DEFAULTPACK
          Size of default element pack
 
Fields inherited from class jigcell.compare.data.TreeDataElement
length, values
 
Fields inherited from class jigcell.compare.data.EditableDataElement
DOUBLE_NaN, DOUBLE_NINFINITY, DOUBLE_PINFINITY, MESSAGE_PARSEBLOCKERROR, MESSAGE_PARSEERROR, MESSAGE_PARSEEXTRAERROR, MESSAGE_PARSELITERALERROR, PATTERN_FP, prototypeChild, TOKEN_ALL, TOKEN_BLOCKELEMENT, TOKEN_BLOCKEND, TOKEN_BLOCKSTART, TOKEN_LITERAL
 
Fields inherited from class jigcell.compare.data.DataElement
lockCount, LONGPOOL, PATTERN_FALSE, PATTERN_NAN, PATTERN_NINFINITY, PATTERN_NINFINITY2, PATTERN_NULL, PATTERN_PINFINITY, PATTERN_PINFINITY2, PATTERN_TRUE, PATTERN_VOID, SIZE_LONGPOOL
 
Fields inherited from class jigcell.compare.impl.Transferer
CSV_FOOTER, CSV_LINEPOSTPEND, CSV_LINEPREPEND, CSV_LINESEPARATOR, HTML_FOOTER, HTML_HEADPOSTPEND, HTML_HEADPREPEND, HTML_HEADSEPARATOR, HTML_LINEPOSTPEND, HTML_LINEPREPEND, HTML_LINESEPARATOR
 
Fields inherited from class javax.swing.TransferHandler
COPY, COPY_OR_MOVE, MOVE, NONE
 
Constructor Summary
PackedTreeDataElement()
          Creates a new data element backed by a tree with packed storage.
PackedTreeDataElement(int size)
          Creates a new data element with packed storage.
 
Method Summary
protected  EditableDataElement constructNew()
          Constructs a new element of the same type as this element.
static IEditableDataElement createElement(java.io.Reader reader)
          Generates a PackedTreeDataElement from streaming input.
static IEditableDataElement createElementSafe(java.io.Reader reader)
          Generates a PackedTreeDataElement from streaming input.
protected  java.lang.Object getDirect(long pos)
          Gets the value at a position.
protected  long lastValue()
          Finds the last defined value.
protected  void putDirect(long pos, java.lang.Object value)
          Sets the value at a position.
protected  void removeDirect(long pos)
          Removes the value at a position.
 
Methods inherited from class jigcell.compare.data.TreeDataElement
clear, getLength, getValues, isAvailable, memoryLock, memoryUnlock, setLengthDirect, setValue, setValues, unsetValue
 
Methods inherited from class jigcell.compare.data.EditableDataElement
copyValue, createElement, createElement, createElement, createElementSafe, createElementSafe, createScalarElement, createScalarElement, createScalarElement, createScalarElement, forceSlice, forceSlice, forceSlice, forceSlice, getBooleanValue, getChecked, getIntegralValue, getListValue, getLiteralValue, getPrototypeChild, getRealValue, getType, getType, makeList, moveValue, putChecked, setPrototypeChild, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValueInterpreted, setValueInterpreted, swapValues
 
Methods inherited from class jigcell.compare.data.DataElement
forceBooleanValue, forceBooleanValue, forceIntegralValue, forceIntegralValue, forceListValue, forceLiteralValue, forceLiteralValue, forceRealValue, forceRealValue, forceSlice, getBooleanValue, getIntegralValue, getLiteralValue, getLongObject, getRealValue, getSlice, getSlice, getSlice, getSlice, getSlice, getTransferData, isScalar, isSpecialNonNumeric, toString, toString, toString, toString, toString, toString, toString, toString, toString, toString, toString, toString, toString, toString, toString, toString
 
Methods inherited from class jigcell.compare.impl.Transferer
addExtension, addFlavor, createCSVTable, createFormattedTable, createHTMLTable, getExceptionRecorder, getExpectedClasses, getExpectedClasses, getExpectedClasses, getFlavors, getFlavors, getPreferredExtensions, getPreferredExtensions, getTransferClass, getTransferDataFlavors, getTransferFlavor, isDataFlavorSupported, transfer
 
Methods inherited from class javax.swing.TransferHandler
canImport, createTransferable, exportAsDrag, exportDone, exportToClipboard, getCopyAction, getCutAction, getPasteAction, getSourceActions, getVisualRepresentation, importData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jigcell.compare.IDataElement
forceBooleanValue, forceBooleanValue, forceIntegralValue, forceIntegralValue, forceListValue, forceLiteralValue, forceLiteralValue, forceRealValue, forceRealValue, forceSlice, getBooleanValue, getIntegralValue, getLiteralValue, getRealValue, getSlice, getSlice, getSlice, getSlice, getSlice, isScalar, toString, toString, toString, toString, toString, toString, toString
 
Methods inherited from interface java.awt.datatransfer.Transferable
getTransferData, getTransferDataFlavors, isDataFlavorSupported
 

Field Detail

SIZE_DEFAULTPACK

protected static final int SIZE_DEFAULTPACK
Size of default element pack

See Also:
Constant Field Values

MESSAGE_CHUNKSIZEERROR

protected static final java.lang.String MESSAGE_CHUNKSIZEERROR
Error message when the chunk size is too small

See Also:
Constant Field Values

MESSAGE_LASTERROR

protected static final java.lang.String MESSAGE_LASTERROR
Error message when the last value in a pack is incorrect

See Also:
Constant Field Values

size

protected long size
Element packing size

Constructor Detail

PackedTreeDataElement

public PackedTreeDataElement()
Creates a new data element backed by a tree with packed storage.


PackedTreeDataElement

public PackedTreeDataElement(int size)
Creates a new data element with packed storage.

Parameters:
size - Pack size
Method Detail

createElement

public static IEditableDataElement createElement(java.io.Reader reader)
Generates a PackedTreeDataElement from streaming input.

Parameters:
reader - Reader

createElementSafe

public static IEditableDataElement createElementSafe(java.io.Reader reader)
Generates a PackedTreeDataElement from streaming input. If an element cannot be created, an empty element in returned.

Parameters:
reader - Reader

constructNew

protected EditableDataElement constructNew()
Constructs a new element of the same type as this element.

Specified by:
constructNew in class EditableDataElement

getDirect

protected java.lang.Object getDirect(long pos)
Gets the value at a position. Boolean values are represented by Boolean. Empty values are represented by null. Integral values are represented by Integer. Literal values are represented by String. Multiple values are represented by DataElement. Real values are represented by Double. The position of the object may be anything.

Specified by:
getDirect in class EditableDataElement
Parameters:
pos - Position

lastValue

protected long lastValue()
Finds the last defined value.

Specified by:
lastValue in class TreeDataElement

putDirect

protected void putDirect(long pos,
                         java.lang.Object value)
Sets the value at a position. Boolean values are represented by Boolean. Empty values are represented by null. Integral values are represented by Integer. Literal values are represented by String. Multiple values are represented by DataElement. Real values are represented by Double. The position of the object may be anything.

Specified by:
putDirect in class EditableDataElement
Parameters:
pos - Position
value - Value

removeDirect

protected void removeDirect(long pos)
Removes the value at a position. The position of the object may be anything.

Specified by:
removeDirect in class EditableDataElement
Parameters:
pos - Position