jigcell.compare.data
Class DataGenerator

java.lang.Object
  extended by javax.swing.TransferHandler
      extended by jigcell.compare.impl.Transferer
          extended by jigcell.compare.impl.DataSource
              extended by jigcell.compare.data.DataGenerator
All Implemented Interfaces:
java.awt.datatransfer.Transferable, java.beans.PropertyChangeListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, IDataGenerator, IDataSource, IReadableDataSource
Direct Known Subclasses:
EditableDataGenerator

public abstract class DataGenerator
extends DataSource
implements IDataGenerator

A default implementation of DataGenerator.

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 interface jigcell.compare.IDataSource
IDataSource.Option
 
Field Summary
static java.util.Comparator COMPARATOR_NAME
          Sorts data generators by name in alphabetical order.
private  DataGenerator copiedFrom
          Generator this was copied from
private  boolean copyName
          Whether to link the name of this generator with the one it was copied from
protected static java.lang.String DESCRIPTION_READ
          Read operation description
static java.lang.String SEPARATOR_ESCAPE
          Separator for escaped values
static char[] SPECIAL_CHARS
          Characters that should not be used in a name
 
Fields inherited from class jigcell.compare.impl.DataSource
OPTIONS_LOCK, SEPARATOR_PAIR, SEPARATOR_PART, SEPARATORS
 
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
 
Fields inherited from interface jigcell.compare.IDataGenerator
ATTRIBUTE_COMMENT, ATTRIBUTE_GUID, PROPERTY_GENERATOR_EDIT, RESOURCE_GENERATORS
 
Fields inherited from interface jigcell.compare.IReadableDataSource
OPTION_READDESCRIPTION, OPTION_READICON
 
Fields inherited from interface jigcell.compare.IDataSource
OPTION_NAME
 
Constructor Summary
DataGenerator()
          Creates a new data generator.
 
Method Summary
 java.lang.Object clone()
          A copy of this data source.
static int compareByName(java.lang.Object generator1, java.lang.Object generator2)
          Compares two data generators by name.
 IDataGenerator copy(boolean shallow)
          An equivalent copy of this generator.
protected  void copy(boolean shallow, IDataGenerator target)
          Copies state for this generator.
protected  java.lang.String generateGUID()
          Generates a guid based on this instance.
 java.lang.String getAttribute(java.lang.String key)
          A keyed attribute that must be persisted with this generator.
 java.lang.String getComment()
          A comment suitable for display to the user.
 IDataGenerator getCopiedFrom()
          The generator this was copied from or null if this is not a copy.
 IDataElement getElement()
          A DataElement corresponding to this object.
 java.lang.String getName()
          The name of this data source.
 java.lang.Class getPredictedContents()
          A prediction on the type of data this source contains.
 java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor flavor)
          A transferable object for the given data flavor.
protected  void initializeSource()
          Performs any initialization work for the view that must be duplicated for each new instance.
 boolean isCopy()
          Whether this generator is a copy of another.
 boolean isCopyRelated(IDataGenerator generator)
          Whether this generator was copied from or to another.
 java.lang.Object read()
          The contents of this data source or the first available content if multiple objects are supported.
 void setCopyName(boolean copyName)
           
 void setName(java.lang.String name)
          Sets the data source name.
 java.lang.String toString()
          The name of this generator.
 
Methods inherited from class jigcell.compare.impl.DataSource
addOption, addPropertyChangeListener, addPropertyChangeListener, configure, getOption, getOptions, getOptionType, getPropertyChangeListeners, getPropertyChangeListeners, getReadDescriptionOption, getReadIconOption, getState, getWriteDescriptionOption, getWriteIconOption, persistSource, propertyChange, removePropertyChangeListener, removePropertyChangeListener, setOption, setOptions, setOptionType, setReadDescriptionOption, setReadIconOption, setState, setWriteDescriptionOption, setWriteIconOption, unpersistSource
 
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
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jigcell.compare.IDataGenerator
isCached, setAttribute
 
Methods inherited from interface jigcell.compare.IReadableDataSource
getReadDescriptionOption, getReadIconOption, setReadDescriptionOption, setReadIconOption
 
Methods inherited from interface jigcell.compare.IDataSource
addOption, configure, getOption, getState, setOption, setState
 
Methods inherited from interface java.awt.datatransfer.Transferable
getTransferDataFlavors, isDataFlavorSupported
 

Field Detail

SPECIAL_CHARS

public static final char[] SPECIAL_CHARS
Characters that should not be used in a name


COMPARATOR_NAME

public static final java.util.Comparator COMPARATOR_NAME
Sorts data generators by name in alphabetical order. The comparison is case-insensitive.


SEPARATOR_ESCAPE

public static final java.lang.String SEPARATOR_ESCAPE
Separator for escaped values

See Also:
Constant Field Values

DESCRIPTION_READ

protected static final java.lang.String DESCRIPTION_READ
Read operation description

See Also:
Constant Field Values

copyName

private transient boolean copyName
Whether to link the name of this generator with the one it was copied from


copiedFrom

private transient DataGenerator copiedFrom
Generator this was copied from

Constructor Detail

DataGenerator

public DataGenerator()
Creates a new data generator.

Method Detail

compareByName

public static int compareByName(java.lang.Object generator1,
                                java.lang.Object generator2)
Compares two data generators by name. The comparison is case-insensitive.

Parameters:
generator1 - Generator
generator2 - Generator

clone

public java.lang.Object clone()
Description copied from class: DataSource
A copy of this data source. This method will return null instead of throwing an exception on failure.

Specified by:
clone in interface IDataSource
Overrides:
clone in class DataSource

copy

public IDataGenerator copy(boolean shallow)
An equivalent copy of this generator.

Specified by:
copy in interface IDataGenerator
Parameters:
shallow - Whether the copy is shallow

getAttribute

public java.lang.String getAttribute(java.lang.String key)
A keyed attribute that must be persisted with this generator.

Specified by:
getAttribute in interface IDataGenerator
Parameters:
key - Attribute key

getComment

public java.lang.String getComment()
A comment suitable for display to the user.

Specified by:
getComment in interface IDataGenerator

getCopiedFrom

public IDataGenerator getCopiedFrom()
The generator this was copied from or null if this is not a copy.

Specified by:
getCopiedFrom in interface IDataGenerator

getElement

public IDataElement getElement()
A DataElement corresponding to this object. This may be a potentially expensive operation if isCached is false.

Specified by:
getElement in interface IDataGenerator

getName

public java.lang.String getName()
The name of this data source.

Specified by:
getName in interface IDataSource
Overrides:
getName in class DataSource

getPredictedContents

public java.lang.Class getPredictedContents()
A prediction on the type of data this source contains.

Specified by:
getPredictedContents in interface IReadableDataSource

getTransferData

public java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor flavor)
                                 throws java.awt.datatransfer.UnsupportedFlavorException,
                                        java.io.IOException
A transferable object for the given data flavor.

Specified by:
getTransferData in interface java.awt.datatransfer.Transferable
Overrides:
getTransferData in class Transferer
Parameters:
flavor - Flavor
Throws:
java.awt.datatransfer.UnsupportedFlavorException
java.io.IOException

isCopy

public boolean isCopy()
Whether this generator is a copy of another.

Specified by:
isCopy in interface IDataGenerator

isCopyRelated

public boolean isCopyRelated(IDataGenerator generator)
Whether this generator was copied from or to another.

Specified by:
isCopyRelated in interface IDataGenerator

read

public java.lang.Object read()
                      throws java.lang.Exception
The contents of this data source or the first available content if multiple objects are supported.

Specified by:
read in interface IReadableDataSource
Throws:
java.lang.Exception

setCopyName

public void setCopyName(boolean copyName)
See Also:
IEditableDataGenerator.setCopyName(boolean)

setName

public void setName(java.lang.String name)
Sets the data source name.

Overrides:
setName in class DataSource
Parameters:
name - Name

toString

public java.lang.String toString()
The name of this generator.

Overrides:
toString in class DataSource

copy

protected void copy(boolean shallow,
                    IDataGenerator target)
Copies state for this generator.

Parameters:
shallow - Whether the copy is shallow
target - Generator to copy to

generateGUID

protected java.lang.String generateGUID()
Generates a guid based on this instance.


initializeSource

protected void initializeSource()
Performs any initialization work for the view that must be duplicated for each new instance. This method is called exactly once and only during object construction.

Overrides:
initializeSource in class DataSource