Humboldt Alignment Editor 2.5.0

eu.esdihumboldt.hale.common.align.model
Class AlignmentUtil

java.lang.Object
  extended by eu.esdihumboldt.hale.common.align.model.AlignmentUtil

public abstract class AlignmentUtil
extends Object

Alignment model utility methods.

Author:
Simon Templer

Constructor Summary
AlignmentUtil()
           
 
Method Summary
static EntityDefinition createEntity(TypeDefinition type, List<ChildContext> path, SchemaSpaceID schemaSpace, Filter filter)
          Create an entity definition from a type and a child path.
static EntityDefinition deriveEntity(EntityDefinition entity, int pathLength)
          Derive an entity definition from the given one but with a maximum path length.
static boolean entityOrChildContained(EntityDefinition entity, Iterable<? extends Entity> candidates)
          Determines if the given entity definition or one of its children is contained in the given entity candidates.
static boolean entityOrChildMapped(EntityDefinition entity, Alignment alignment)
          States if the given entity definition or one of its children is mapped in the given alignment.
static EntityDefinition getAllDefaultEntity(EntityDefinition entity)
          Get the entity definition based on the given entity definition with the default instance context for each path entry.
static EntityDefinition getChild(EntityDefinition entity, QName childName)
          Get the default child of the given entity.
static Condition getContextCondition(EntityDefinition candidate)
          Get the context condition of the given entity definition.
static Integer getContextIndex(EntityDefinition candidate)
          Get the context index of the given entity definition.
static Integer getContextName(EntityDefinition candidate)
          Get the context name of the given entity definition.
static String getContextText(EntityDefinition entityDef)
          Get a text representation for the entity definition context.
static EntityDefinition getDefaultEntity(EntityDefinition entity)
          Get the entity definition with the default instance context which is a sibling to (or the same as) the given entity definition.
static EntityDefinition getParent(EntityDefinition entity)
          Get the parent entity definition for the given entity definition.
static Collection<? extends Cell> getPropertyCellsFromTypeCell(Alignment align, Cell tCell)
          Get a collection of property cells from a type cell
static TypeEntityDefinition getTypeEntity(EntityDefinition entityDef)
          Get the type entity definition of the given entity definition.
static boolean hasTypeRelation(Alignment alignment)
          Determines if the given alignment has any type relations.
static boolean hasTypeRelation(Alignment alignment, TypeEntityDefinition sourceType, TypeEntityDefinition targetType)
          Determines if the given alignment contains a relation between the given types.
static boolean isAugmentation(Cell cell)
          Determines if the given cell is an augmentation.
static boolean isDefaultEntity(EntityDefinition entity)
          Determines if the given entity is a default entity.
static boolean isParent(EntityDefinition parent, EntityDefinition child)
          Determines if a given entity definition is a parent of another entity definition.
static boolean isTypeCell(Cell cell)
          Determines if the given cell is a type cell.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AlignmentUtil

public AlignmentUtil()
Method Detail

isTypeCell

public static boolean isTypeCell(Cell cell)
Determines if the given cell is a type cell.

Parameters:
cell - the cell
Returns:
if the cell is a type cell

hasTypeRelation

public static boolean hasTypeRelation(Alignment alignment)
Determines if the given alignment has any type relations.

Parameters:
alignment - the alignment
Returns:
if any type cells are present in the alignment

hasTypeRelation

public static boolean hasTypeRelation(Alignment alignment,
                                      TypeEntityDefinition sourceType,
                                      TypeEntityDefinition targetType)
Determines if the given alignment contains a relation between the given types.

Parameters:
alignment - the alignment
sourceType - the source type, may be null for any source type
targetType - the target type, may be null for any target type
Returns:
if a relation between the given types exists in the alignment

isAugmentation

public static boolean isAugmentation(Cell cell)
Determines if the given cell is an augmentation.

Parameters:
cell - the cell
Returns:
if the cell is an augmentation

getParent

public static EntityDefinition getParent(EntityDefinition entity)
Get the parent entity definition for the given entity definition.

Parameters:
entity - the entity definition
Returns:
the parent entity definition or null if it has no parent

getChild

public static EntityDefinition getChild(EntityDefinition entity,
                                        QName childName)
Get the default child of the given entity.

Parameters:
entity - the parent entity
childName - the child name
Returns:
the child entity or null if no child with the given name exists

createEntity

public static EntityDefinition createEntity(TypeDefinition type,
                                            List<ChildContext> path,
                                            SchemaSpaceID schemaSpace,
                                            Filter filter)
Create an entity definition from a type and a child path.

Parameters:
type - the path parent
path - the child path
schemaSpace - the associated schema space
filter - the entity filter on the type, may be null
Returns:
the created entity definition

getDefaultEntity

public static EntityDefinition getDefaultEntity(EntityDefinition entity)
Get the entity definition with the default instance context which is a sibling to (or the same as) the given entity definition.

Parameters:
entity - the entity definition
Returns:
the entity definition with the default context in the last path element

getAllDefaultEntity

public static EntityDefinition getAllDefaultEntity(EntityDefinition entity)
Get the entity definition based on the given entity definition with the default instance context for each path entry.

Parameters:
entity - the entity definition
Returns:
the entity definition with the default context in all path elements

deriveEntity

public static EntityDefinition deriveEntity(EntityDefinition entity,
                                            int pathLength)
Derive an entity definition from the given one but with a maximum path length.

Parameters:
entity - the entity definition
pathLength - the maximum path length
Returns:
the entity definition derived from the given entity definition but with the property path shortened if needed, otherwise the given definition will be returned

getPropertyCellsFromTypeCell

public static Collection<? extends Cell> getPropertyCellsFromTypeCell(Alignment align,
                                                                      Cell tCell)
Get a collection of property cells from a type cell

Parameters:
align - the alignment to get the property cells from
tCell - the type cell
Returns:
the property cells

isParent

public static boolean isParent(EntityDefinition parent,
                               EntityDefinition child)
Determines if a given entity definition is a parent of another entity definition.

Parameters:
parent - the parent
child - the potential child
Returns:
if the first entity definition is a parent of the second or if both are equal

entityOrChildMapped

public static boolean entityOrChildMapped(EntityDefinition entity,
                                          Alignment alignment)
States if the given entity definition or one of its children is mapped in the given alignment.

Parameters:
entity - the entity definition
alignment - the alignment
Returns:
if the alignment contains a relation where the given entity or one of its children (including grand-children etc.) is involved

entityOrChildContained

public static boolean entityOrChildContained(EntityDefinition entity,
                                             Iterable<? extends Entity> candidates)
Determines if the given entity definition or one of its children is contained in the given entity candidates.

Parameters:
entity - the entity definition
candidates - the entity candidates to test
Returns:
if at least one of the entity candidates is the given entity or a child (or grand-child etc.)

getTypeEntity

public static TypeEntityDefinition getTypeEntity(EntityDefinition entityDef)
Get the type entity definition of the given entity definition.

Parameters:
entityDef - the entity definition
Returns:
the entity definition if it is a TypeEntityDefinition, otherwise a new type entity definition is created

getContextName

public static Integer getContextName(EntityDefinition candidate)
Get the context name of the given entity definition.

Parameters:
candidate - the entity definition
Returns:
the context name, null for the default context

getContextIndex

public static Integer getContextIndex(EntityDefinition candidate)
Get the context index of the given entity definition.

Parameters:
candidate - the entity definition
Returns:
the context name, null for the default context

getContextCondition

public static Condition getContextCondition(EntityDefinition candidate)
Get the context condition of the given entity definition.

Parameters:
candidate - the entity definition
Returns:
the context name, null for the default context

getContextText

public static String getContextText(EntityDefinition entityDef)
Get a text representation for the entity definition context.

Parameters:
entityDef - the entity definition
Returns:
the context text or null if it is the default context or the context has no text representation

isDefaultEntity

public static boolean isDefaultEntity(EntityDefinition entity)
Determines if the given entity is a default entity.

Parameters:
entity - the entity to check
Returns:
if the entity is a default entity

Humboldt Alignment Editor 2.5.0

Build 2012-12-03_12-30-59
Revision 9d2dd4b0318cda9f1393b1ddd390f7f792d70a2d