Vordel SDK

com.vordel.es
Class EntityTypeImpl

java.lang.Object
  extended by com.vordel.es.EntityTypeImpl
All Implemented Interfaces:
EntityType, java.lang.Comparable

public class EntityTypeImpl
extends java.lang.Object
implements EntityType

The type definition for Entities in the EntityStore framework


Field Summary
 
Fields inherited from interface com.vordel.es.EntityType
ABSTRACT, CARDINALITY, COMPONENT_TYPE, CONSTANT, DEFAULT, DEFAULT_REF, DEFAULT_VALUE, ENTITY_TYPE, EXTENDS, FIELD, IS_KEY, NAME, ONE_OR_MANY, TYPE, VSTAMP, ZERO_OR_MANY, ZERO_OR_ONE
 
Constructor Summary
EntityTypeImpl(TypeStore ts, java.io.InputStream stream)
          Create a new EntityType
EntityTypeImpl(TypeStore ts, org.w3c.dom.Node doc)
          Create a new EntityType from a Document model
EntityTypeImpl(TypeStore ts, java.lang.String schema)
          Create a new EntityType
 
Method Summary
 boolean allowsChildEntities()
          Does this type allow child Entities
 boolean allowsComponent(EntityType t)
          Does this type allow entities of the specified type?
 boolean allowsReferences()
           
 boolean allowsSoftReferences()
           
 int compareTo(java.lang.Object other)
           
 Field createField(java.lang.String fieldName, ESPK reference)
          Convienence method for creating a Field based on the FieldType as defined by this EntityType definition
 Field createField(java.lang.String fieldName, java.lang.String value)
          Convienence method for creating a Field based on the FieldType as defined by this EntityType definition
 Field createField(java.lang.String fieldName, Value[] vals)
          Convienence method for creating a Field based on the FieldType as defined by this EntityType definition
 boolean equals(java.lang.Object other)
          Equality is based on type name.
 boolean extendsType(java.lang.String parentType)
           
 java.util.Collection<java.lang.String> getAllConstantFieldNames()
           
 java.util.Collection<Field> getAllConstantFields()
           
 java.util.Set<java.lang.String> getAllDeclaredConstantFieldNames()
           
 java.util.Set<java.lang.String> getAllDeclaredFieldNames()
          Get all fields defined for this type, excluding superTypes.
 java.util.Collection<java.lang.String> getAllDeclaredKeyFields()
           
 java.util.Collection<java.lang.String> getAllDefaultedFieldNames()
           
 java.util.Collection<java.lang.String> getAllFieldNames()
           
 javax.xml.parsers.DocumentBuilder getBuilder()
           
 Field getConstantField(java.lang.String fieldName)
          Get the constant field with the name 'fieldName'
 java.util.Map<java.lang.String,java.lang.Object> getDeclaredComponentTypes()
          Get a copy of the component type map for this type Key is component type name Value is the cardinality of allowed occurrances under a node of this type
 FieldType getFieldType(java.lang.String name)
          Get the field type for the specified field name.
 java.lang.String[] getKeyFieldNames()
           
 java.lang.String getName()
          Get the name of this type.
 org.w3c.dom.Element getRootElement()
           
 EntityType getSuperType()
          Get the super type of this type.
 int hashCode()
           
 boolean hasSuperType(java.lang.String candidate)
          Check to see if the specified type is an ancestor of this type
 boolean isAbstract()
          See if this type is abstract.
 boolean isCompatible(EntityType other)
          Compatibility is a check that the contents of an Entity of this type can be applied safely to the contents of an Entity of another compatible type.
 boolean isConstantField(java.lang.String fieldName)
           
 boolean isKeyField(Field f)
           
 boolean isSubType(EntityType candidate)
          Check that the specified type is a subtype of this type.
 java.lang.String serialize()
          Deprecated. Serialising XML to strings is evil. replaced by (write)
 java.lang.String toString()
          The name of the type is the preferred representation
protected  void validate()
           
 void write(java.io.OutputStream os)
           
static void write(java.io.OutputStream os, java.lang.String encoding, org.w3c.dom.Node node)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EntityTypeImpl

public EntityTypeImpl(TypeStore ts,
                      java.io.InputStream stream)
               throws EntityStoreException
Create a new EntityType

Parameters:
ts - A Type store from where to wire up the inheritance hierarchy
stream - An input stream from where to obtain the type's definition
Throws:
EntityStoreException

EntityTypeImpl

public EntityTypeImpl(TypeStore ts,
                      java.lang.String schema)
               throws EntityStoreException
Create a new EntityType

Parameters:
ts - A Type store from where to wire up the inheritance hierarchy
schema - A string representing the type's definition
Throws:
EntityStoreException

EntityTypeImpl

public EntityTypeImpl(TypeStore ts,
                      org.w3c.dom.Node doc)
               throws EntityStoreException
Create a new EntityType from a Document model

Parameters:
ts -
doc -
Throws:
EntityStoreException
Method Detail

getRootElement

public org.w3c.dom.Element getRootElement()
Specified by:
getRootElement in interface EntityType

getBuilder

public javax.xml.parsers.DocumentBuilder getBuilder()
                                             throws EntityStoreException
Specified by:
getBuilder in interface EntityType
Throws:
EntityStoreException

validate

protected void validate()
                 throws EntityStoreException
Throws:
EntityStoreException

getDeclaredComponentTypes

public java.util.Map<java.lang.String,java.lang.Object> getDeclaredComponentTypes()
Get a copy of the component type map for this type Key is component type name Value is the cardinality of allowed occurrances under a node of this type

Specified by:
getDeclaredComponentTypes in interface EntityType
Returns:
a Map, keyed by component type name. The values are the cardinality of each keyed component type.

getAllDeclaredFieldNames

public java.util.Set<java.lang.String> getAllDeclaredFieldNames()
Get all fields defined for this type, excluding superTypes.

Specified by:
getAllDeclaredFieldNames in interface EntityType
Returns:
a sorted Set of Strings, each one the name of a field defined by this type.

getAllDeclaredConstantFieldNames

public java.util.Set<java.lang.String> getAllDeclaredConstantFieldNames()
Specified by:
getAllDeclaredConstantFieldNames in interface EntityType

getAllDeclaredKeyFields

public java.util.Collection<java.lang.String> getAllDeclaredKeyFields()
Specified by:
getAllDeclaredKeyFields in interface EntityType

getFieldType

public FieldType getFieldType(java.lang.String name)
Get the field type for the specified field name.

Specified by:
getFieldType in interface EntityType
Parameters:
name - The name of the field
Returns:
the type of the field, or null if the named field is undefined for this type

isConstantField

public boolean isConstantField(java.lang.String fieldName)
Specified by:
isConstantField in interface EntityType

allowsReferences

public boolean allowsReferences()
Specified by:
allowsReferences in interface EntityType

getConstantField

public Field getConstantField(java.lang.String fieldName)
Get the constant field with the name 'fieldName'

Specified by:
getConstantField in interface EntityType
Returns:
a Field which has a single constant value

getAllConstantFields

public java.util.Collection<Field> getAllConstantFields()
Specified by:
getAllConstantFields in interface EntityType

getAllDefaultedFieldNames

public java.util.Collection<java.lang.String> getAllDefaultedFieldNames()
Specified by:
getAllDefaultedFieldNames in interface EntityType

getAllFieldNames

public java.util.Collection<java.lang.String> getAllFieldNames()
Specified by:
getAllFieldNames in interface EntityType

getAllConstantFieldNames

public java.util.Collection<java.lang.String> getAllConstantFieldNames()
Specified by:
getAllConstantFieldNames in interface EntityType

getSuperType

public EntityType getSuperType()
Get the super type of this type.

Specified by:
getSuperType in interface EntityType
Returns:
The EntityType which this type extends

isAbstract

public boolean isAbstract()
See if this type is abstract.

Specified by:
isAbstract in interface EntityType
Returns:
true if this is an abstract type, false otherwise.

getName

public java.lang.String getName()
Get the name of this type. The name is unique in the context of an EntityStore.

Specified by:
getName in interface EntityType
Returns:
The name of the type

getKeyFieldNames

public java.lang.String[] getKeyFieldNames()
Specified by:
getKeyFieldNames in interface EntityType

allowsChildEntities

public boolean allowsChildEntities()
Does this type allow child Entities

Specified by:
allowsChildEntities in interface EntityType

allowsComponent

public boolean allowsComponent(EntityType t)
Does this type allow entities of the specified type?

Specified by:
allowsComponent in interface EntityType
Parameters:
t - The candidate child type

write

public void write(java.io.OutputStream os)
           throws java.io.IOException
Specified by:
write in interface EntityType
Throws:
java.io.IOException

write

public static void write(java.io.OutputStream os,
                         java.lang.String encoding,
                         org.w3c.dom.Node node)
                  throws java.io.IOException
Throws:
java.io.IOException

serialize

public java.lang.String serialize()
                           throws EntityStoreException
Deprecated. Serialising XML to strings is evil. replaced by (write)

Get the XML form of this EntityType

Specified by:
serialize in interface EntityType
Returns:
a String containing an XML document which describes this type
Throws:
EntityStoreException

toString

public java.lang.String toString()
The name of the type is the preferred representation

Overrides:
toString in class java.lang.Object

isSubType

public boolean isSubType(EntityType candidate)
Check that the specified type is a subtype of this type.

Specified by:
isSubType in interface EntityType
Parameters:
candidate - The candidate type
Returns:
true if the specified type is indeed a subtype of this type, false otherwise.

hasSuperType

public boolean hasSuperType(java.lang.String candidate)
Description copied from interface: EntityType
Check to see if the specified type is an ancestor of this type

Specified by:
hasSuperType in interface EntityType
Returns:
true if the candidate is an ancestor type of this type, false otherwise

createField

public Field createField(java.lang.String fieldName,
                         Value[] vals)
                  throws EntityStoreException
Convienence method for creating a Field based on the FieldType as defined by this EntityType definition

Specified by:
createField in interface EntityType
Parameters:
fieldName - The name of the field to create
vals - The initial values of the Field
Returns:
A new Field, for addition to the entity
Throws:
EntityStoreException - If the values are incompatible with the type definition

createField

public Field createField(java.lang.String fieldName,
                         java.lang.String value)
                  throws EntityStoreException
Convienence method for creating a Field based on the FieldType as defined by this EntityType definition

Specified by:
createField in interface EntityType
Parameters:
fieldName - The name of the field to create
value - A single data value
Returns:
A new Field, for addition to the entity
Throws:
EntityStoreException - If the values are incompatible with the type definition

createField

public Field createField(java.lang.String fieldName,
                         ESPK reference)
                  throws EntityStoreException
Convienence method for creating a Field based on the FieldType as defined by this EntityType definition

Specified by:
createField in interface EntityType
Parameters:
fieldName - The name of the field to create
reference - A single data reference
Returns:
A new Field, for addition to the entity
Throws:
EntityStoreException - If the values are incompatible with the type definition

equals

public boolean equals(java.lang.Object other)
Equality is based on type name.

Overrides:
equals in class java.lang.Object

isCompatible

public boolean isCompatible(EntityType other)
Compatibility is a check that the contents of an Entity of this type can be applied safely to the contents of an Entity of another compatible type.

Specified by:
isCompatible in interface EntityType
Parameters:
other - The EntityType to compare with this one.
Returns:
true if the types are compatible, false otherwise.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

compareTo

public int compareTo(java.lang.Object other)
Specified by:
compareTo in interface java.lang.Comparable

isKeyField

public boolean isKeyField(Field f)
Specified by:
isKeyField in interface EntityType

allowsSoftReferences

public boolean allowsSoftReferences()
Specified by:
allowsSoftReferences in interface EntityType

extendsType

public boolean extendsType(java.lang.String parentType)
Specified by:
extendsType in interface EntityType

Vordel SDK


This documentation and all its contents and graphics, copyright © 1999 - 2011 Vordel