jigcell.compare.data.type
Class TypeChecker

java.lang.Object
  extended by jigcell.compare.data.type.TypeChecker
All Implemented Interfaces:
ITypeChecker
Direct Known Subclasses:
BooleanTypeChecker, IntegerTypeChecker, ListTypeChecker, RealTypeChecker, StringTypeChecker, UntypedTypeChecker

public abstract class TypeChecker
extends java.lang.Object
implements ITypeChecker

Base class for type checkers.

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

Author:
Nicholas Allen

Field Summary
static java.util.Comparator COMPARATOR_NAME
          Sorts type checkers by name in alphabetical order.
 
Fields inherited from interface jigcell.compare.ITypeChecker
ATTRIBUTE_TYPE, METHOD_GENERATE, OPTION_TYPECHECKER
 
Constructor Summary
protected TypeChecker()
          Creates a new type checker.
 
Method Summary
static int compareByName(java.lang.Object checker1, java.lang.Object checker2)
          Compares two type checkers by name.
 IComponentDescription getDescription()
          A description for this type.
 IDataElement.Type getType()
          The structural type this checker matches.
static ITypeChecker getTypeCheckerForGenerator(IDataGenerator generator)
          The type checker of a generator.
 boolean isCompatible(ITypeChecker type)
          Whether a data type can be converted to this type.
static boolean isCompatible(ITypeChecker checker1, ITypeChecker checker2)
          Tests that two type checkers are compatible.
 java.lang.String toString()
           
 boolean validate(IDataElement data)
          Whether a data element is an instance of this type.
static boolean validate(ITypeChecker checker, IDataGenerator generator)
          Tests a type checker against the element of a generator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jigcell.compare.ITypeChecker
getName
 

Field Detail

COMPARATOR_NAME

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

Constructor Detail

TypeChecker

protected TypeChecker()
Creates a new type checker.

Method Detail

compareByName

public static int compareByName(java.lang.Object checker1,
                                java.lang.Object checker2)
Compares two type checkers by name. The comparison is case-insensitive.

Parameters:
checker1 - Checker
checker2 - Checker

getTypeCheckerForGenerator

public static ITypeChecker getTypeCheckerForGenerator(IDataGenerator generator)
The type checker of a generator.

Parameters:
generator - Generator

isCompatible

public static boolean isCompatible(ITypeChecker checker1,
                                   ITypeChecker checker2)
Tests that two type checkers are compatible.

Parameters:
checker1 - Type checker
checker2 - Type checker

validate

public static boolean validate(ITypeChecker checker,
                               IDataGenerator generator)
Tests a type checker against the element of a generator.

Parameters:
checker - Type checker
generator - Data generator

getDescription

public IComponentDescription getDescription()
A description for this type. Implementations that do not want to provide a description should return null.

Specified by:
getDescription in interface ITypeChecker

getType

public IDataElement.Type getType()
The structural type this checker matches.

Specified by:
getType in interface ITypeChecker

isCompatible

public boolean isCompatible(ITypeChecker type)
Whether a data type can be converted to this type.

Specified by:
isCompatible in interface ITypeChecker
Parameters:
type - Type to convert from

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

validate

public boolean validate(IDataElement data)
Whether a data element is an instance of this type.

Specified by:
validate in interface ITypeChecker
Parameters:
data - Data element