com.sun.jdo.api.persistence.model.util
Class ModelValidator

java.lang.Object
  extended by com.sun.jdo.api.persistence.model.util.ModelValidator

public class ModelValidator
extends Object

Version:
%I%
Author:
Rochelle Raccah

Constructor Summary
ModelValidator(Model model, String className, ClassLoader classLoader, ResourceBundle bundle)
          Create a new model validator object.
ModelValidator(Model model, String className, ResourceBundle bundle)
           
 
Method Summary
protected  com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createClassExistenceComponent(String className)
          Create a validation component which can check whether the class exists.
protected  com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createClassExistenceComponent(String className, PersistenceFieldElement relatedField)
          Create a validation component which can check whether the class exists.
protected  com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createClassMappingComponent(PersistenceClassElement persistenceClass)
          Create a validation component which can check whether the class is unmapped.
protected  com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createClassPersistenceComponent(String className)
          Create a validation component which can check the class persistence.
protected  com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createClassPersistenceComponent(String className, PersistenceFieldElement relatedField)
          Create a validation component which can check the class persistence.
protected  com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createCollectionClassComponent(RelationshipElement field)
          Create a validation component which can check whether the collection class is valid given the relationship field type.
protected  com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createColumnExistenceComponent(String columnName)
          Create a validation component which can check whether the given column exists.
protected  com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createColumnExistenceComponent(String columnName, MappingFieldElement relatedField)
          Create a validation component which can check whether the given column or column pair exists.
protected  com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createColumnOverlapComponent(MappingFieldElement field)
          Create a validation component which can check whether the field is one of a set mapped to overlapping columns
protected  com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createElementClassComponent(RelationshipElement field)
          Create a validation component which can check whether the relationship is mapped to columns even though the element class is null.
protected  com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createFieldBlobMappingComponent(PersistenceFieldElement field)
          Create a validation component which can check whether the field is mapped to a blob type and if so, whether it is a key field or belongs to the default fetch group.
protected  com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createFieldCardinalityComponent(PersistenceFieldElement field)
          Create a validation component which can check whether the cardinality bounds are semantically valid given the relationship field type.
protected  com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createFieldConsistencyComponent(MappingFieldElement field)
          Create a validation component which can check whether the field is consistent (if in mapping model but not jdo, it is a problem).
protected  com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createFieldConsistencyComponent(PersistenceFieldElement field)
          Create a validation component which can check whether the field is consistent (field in both models or relationship in both).
protected  com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createFieldDefaultFetchGroupComponent(MappingFieldElement field)
          Create a validation component which can check whether the field is part of a managed (multiple fields to same column) group and in an illegal fetch group.
protected  com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createFieldExistenceComponent(Object field)
          Create a validation component which can check whether the field exists.
protected  com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createFieldExistenceComponent(String fieldName)
          Create a validation component which can check whether the field exists.
protected  com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createFieldMappingComponent(PersistenceFieldElement field)
          Create a validation component which can check whether the field is unmapped.
protected  com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createFieldPersistenceComponent(PersistenceFieldElement field)
          Create a validation component which can check whether the field is persistent.
protected  com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createFieldPersistenceTypeComponent(PersistenceFieldElement field)
          Create a validation component which can check the persistence type of the field (whether it is a relationship or not).
protected  com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createInverseFieldComponent(RelationshipElement field)
          Create a validation component which can check whether the inverse of the inverse of the relationship is the relationship itself.
protected  com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createInverseMappingComponent(RelationshipElement field)
          Create a validation component which can check whether the mapping of the relationship and the mapping of its inverse are inverses of each other.
protected  com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createKeyClassComponent(String className)
          Create a validation component which can check whether the key class of the persistence capable class is valid.
protected  com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createKeyColumnMappingComponent(PersistenceClassElement persistenceClass)
          Create a validation component which can check whether the class contains field mappings for all primary key columns.
protected  com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createPrimaryTableComponent(MappingTableElement primaryTable)
          Create a validation component which can check whether the class is mapped to tables even though the schema is null or the class is mapped to a primary table without a primary key.
protected  com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createRelatedClassMatchesComponent(RelationshipElement field)
          Create a validation component which can check whether the inverse of the relationship belongs to the related class (type or element class depending on cardinality).
protected  com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createRelatedSchemaMatchesComponent(String relatedClass, PersistenceFieldElement relatedField)
          Create a validation component which can check whether the schema of the related class matches that of the class we are checking.
protected  com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createRelatedTableMatchesComponent(String relatedClass, PersistenceFieldElement relatedField, List tableNames, String pairName)
          Create a validation component which can check whether any of the supplied tables of the related class (which includes primary and secondary tables) contains the table of the column stored in the relationship definition.
protected  com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createSchemaExistenceComponent(String className)
          Create a validation component which can check whether the schema of the given class exists.
protected  com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createSchemaExistenceComponent(String className, PersistenceFieldElement relatedField)
          Create a validation component which can check whether the schema of the given class exists.
protected  com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createSerializableClassComponent(String className)
          Create a validation component which can check that the persistence capable class implement methods readObject and writeObject, if the class implements the intreface java.io.Serializable
protected  com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createTableExistenceComponent(String tableName)
          Create a validation component which can check whether the given table exists.
protected  com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createTableExistenceComponent(String tableName, PersistenceFieldElement relatedField)
          Create a validation component which can check whether the given table exists.
protected  com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createVersionConsistencyComponent(MappingClassElement mappingClass)
          Create a validation component which checks whether the rules for version consistency are followed.
 Collection fullValidationCheck()
          Main method used for validating the combination of java (or class) information and mapping/jdo information by running through the full validation check and returning a collection of ModelValidationExceptions containing any errors or warnings encountered.
 Collection getBasicValidationList()
          Computes and returns a collection of ValidationComponents representing the tests to be performed during parse.
 ClassLoader getClassLoader()
          Get the class loader used to load the class being validated.
 String getClassName()
          Get the name of the class being validated.
 Collection getFullValidationList()
          Computes and returns a collection of ValidationComponents representing the tests to be performed during validation.
protected  ResourceBundle getMessages()
           
 Model getModel()
          Get the model object used for validation.
 boolean parseCheck()
          Main method used for parsing the combination of java (or class) information and mapping/jdo information by running through a subset of the full validation check and aborting (and returning false at the first error or warning.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModelValidator

public ModelValidator(Model model,
                      String className,
                      ResourceBundle bundle)

ModelValidator

public ModelValidator(Model model,
                      String className,
                      ClassLoader classLoader,
                      ResourceBundle bundle)
Create a new model validator object.

Parameters:
model - model object used for validation
className - the name of the class being validated
Method Detail

getModel

public Model getModel()
Get the model object used for validation.

Returns:
the model object used for validation

getClassName

public String getClassName()
Get the name of the class being validated.

Returns:
the name of the class being validated

getClassLoader

public ClassLoader getClassLoader()
Get the class loader used to load the class being validated.

Returns:
the class loader of the class being validated

getMessages

protected ResourceBundle getMessages()
Returns:
I18N message handler for this element

parseCheck

public boolean parseCheck()
Main method used for parsing the combination of java (or class) information and mapping/jdo information by running through a subset of the full validation check and aborting (and returning false at the first error or warning.

Returns:
true if no errors or warnings occur, false otherwise.
See Also:
getBasicValidationList()

fullValidationCheck

public Collection fullValidationCheck()
Main method used for validating the combination of java (or class) information and mapping/jdo information by running through the full validation check and returning a collection of ModelValidationExceptions containing any errors or warnings encountered.

Returns:
a collection of ModelValidationExceptions containing any errors or warnings encountered. If no errors or warnings were encountered, the collection will be empty, not null.
See Also:
getFullValidationList()

getBasicValidationList

public Collection getBasicValidationList()
Computes and returns a collection of ValidationComponents representing the tests to be performed during parse.

Returns:
a collection of ValidationComponents representing the tests to be performed during parse.
See Also:
getDatabaseValidationList(), getFieldsValidationList(), getFullValidationList()

getFullValidationList

public Collection getFullValidationList()
Computes and returns a collection of ValidationComponents representing the tests to be performed during validation. These include all those in the basic list plus those which check cardinality and the related classes in more detail.

Returns:
a collection of ValidationComponents representing the tests to be performed during validation.
See Also:
getRelatedClassValidationList(com.sun.jdo.api.persistence.model.jdo.PersistenceFieldElement), getBasicValidationList()

createClassExistenceComponent

protected com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createClassExistenceComponent(String className,
                                                                                                                  PersistenceFieldElement relatedField)
Create a validation component which can check whether the class exists.

Parameters:
className - the class whose existence is being checked
relatedField - the relationship field whose class is being checked, may be null in which case we are probably checking the same class as the validator is checking overall
Returns:
the validation component

createClassExistenceComponent

protected com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createClassExistenceComponent(String className)
Create a validation component which can check whether the class exists.

Parameters:
className - the class whose existence is being checked
Returns:
the validation component

createClassPersistenceComponent

protected com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createClassPersistenceComponent(String className,
                                                                                                                    PersistenceFieldElement relatedField)
Create a validation component which can check the class persistence.

Parameters:
className - the class whose persistence is being checked
relatedField - the relationship field whose class is being checked, may be null in which case we are probably checking the same class as the validator is checking overall
Returns:
the validation component

createClassPersistenceComponent

protected com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createClassPersistenceComponent(String className)
Create a validation component which can check the class persistence.

Parameters:
className - the class whose persistence is being checked
Returns:
the validation component

createFieldExistenceComponent

protected com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createFieldExistenceComponent(String fieldName)
Create a validation component which can check whether the field exists.

Parameters:
fieldName - the field whose existence is being checked
Returns:
the validation component

createFieldExistenceComponent

protected com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createFieldExistenceComponent(Object field)
Create a validation component which can check whether the field exists.

Parameters:
field - the field whose existence is being checked
Returns:
the validation component

createFieldPersistenceComponent

protected com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createFieldPersistenceComponent(PersistenceFieldElement field)
Create a validation component which can check whether the field is persistent.

Parameters:
field - the field whose persistence is being checked
Returns:
the validation component

createFieldConsistencyComponent

protected com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createFieldConsistencyComponent(PersistenceFieldElement field)
Create a validation component which can check whether the field is consistent (field in both models or relationship in both).

Parameters:
field - the field whose consistency is being checked
Returns:
the validation component

createFieldConsistencyComponent

protected com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createFieldConsistencyComponent(MappingFieldElement field)
Create a validation component which can check whether the field is consistent (if in mapping model but not jdo, it is a problem).

Parameters:
field - the field whose consistency is being checked
Returns:
the validation component

createFieldPersistenceTypeComponent

protected com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createFieldPersistenceTypeComponent(PersistenceFieldElement field)
Create a validation component which can check the persistence type of the field (whether it is a relationship or not).

Parameters:
field - the field whose persistence type is being checked
Returns:
the validation component

createFieldCardinalityComponent

protected com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createFieldCardinalityComponent(PersistenceFieldElement field)
Create a validation component which can check whether the cardinality bounds are semantically valid given the relationship field type.

Parameters:
field - the relationship whose cardinality bounds are being checked
Returns:
the validation component

createFieldMappingComponent

protected com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createFieldMappingComponent(PersistenceFieldElement field)
Create a validation component which can check whether the field is unmapped.

Parameters:
field - the field whose mapping is being checked
Returns:
the validation component

createFieldBlobMappingComponent

protected com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createFieldBlobMappingComponent(PersistenceFieldElement field)
Create a validation component which can check whether the field is mapped to a blob type and if so, whether it is a key field or belongs to the default fetch group. Note that it's somewhat important to check for the key field first because if a field is key, its fetch group value in the model is ignored.

Parameters:
field - the field whose mapping/key field/fetch group consistency is being checked
Returns:
the validation component

createCollectionClassComponent

protected com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createCollectionClassComponent(RelationshipElement field)
Create a validation component which can check whether the collection class is valid given the relationship field type.

Parameters:
field - the relationship whose collection class is being checked
Returns:
the validation component

createElementClassComponent

protected com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createElementClassComponent(RelationshipElement field)
Create a validation component which can check whether the relationship is mapped to columns even though the element class is null.

Parameters:
field - the relationship whose element class is being checked
Returns:
the validation component

createVersionConsistencyComponent

protected com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createVersionConsistencyComponent(MappingClassElement mappingClass)
Create a validation component which checks whether the rules for version consistency are followed. This includes:

Parameters:
mappingClass - the mapping class element whose consistency is being checked
Returns:
the validation component

createInverseFieldComponent

protected com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createInverseFieldComponent(RelationshipElement field)
Create a validation component which can check whether the inverse of the inverse of the relationship is the relationship itself.

Parameters:
field - the relationship whose inverse relationship is being checked
Returns:
the validation component

createRelatedClassMatchesComponent

protected com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createRelatedClassMatchesComponent(RelationshipElement field)
Create a validation component which can check whether the inverse of the relationship belongs to the related class (type or element class depending on cardinality).

Parameters:
field - the relationship whose inverse relationship is being checked
Returns:
the validation component

createInverseMappingComponent

protected com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createInverseMappingComponent(RelationshipElement field)
Create a validation component which can check whether the mapping of the relationship and the mapping of its inverse are inverses of each other.

Parameters:
field - the relationship whose inverse relationship is being checked
Returns:
the validation component

createFieldDefaultFetchGroupComponent

protected com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createFieldDefaultFetchGroupComponent(MappingFieldElement field)
Create a validation component which can check whether the field is part of a managed (multiple fields to same column) group and in an illegal fetch group. If the field is in one of these groups, it is not allowed to be in the default fetch group.

Parameters:
field - the field whose fetch group is being checked
Returns:
the validation component

createRelatedSchemaMatchesComponent

protected com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createRelatedSchemaMatchesComponent(String relatedClass,
                                                                                                                        PersistenceFieldElement relatedField)
Create a validation component which can check whether the schema of the related class matches that of the class we are checking.

Parameters:
relatedClass - the class whose schema is being checked
relatedField - the relationship field whose schema is being compared
Returns:
the validation component

createRelatedTableMatchesComponent

protected com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createRelatedTableMatchesComponent(String relatedClass,
                                                                                                                       PersistenceFieldElement relatedField,
                                                                                                                       List tableNames,
                                                                                                                       String pairName)
Create a validation component which can check whether any of the supplied tables of the related class (which includes primary and secondary tables) contains the table of the column stored in the relationship definition.

Parameters:
relatedClass - the class whose table is being checked
relatedField - the relationship field whose table is being compared
tableNames - the list of names of the tables we expect the column to match
pairName - the name of the pair whose reference column is to be checked
Returns:
the validation component

createSchemaExistenceComponent

protected com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createSchemaExistenceComponent(String className)
Create a validation component which can check whether the schema of the given class exists.

Parameters:
className - the class whose mapped schema's existence is being checked
Returns:
the validation component

createSchemaExistenceComponent

protected com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createSchemaExistenceComponent(String className,
                                                                                                                   PersistenceFieldElement relatedField)
Create a validation component which can check whether the schema of the given class exists.

Parameters:
className - the class whose mapped schema's existence is being checked
relatedField - the relationship field whose class' mapped schema is being checked, may be null in which case we are probably checking the same class as the validator is checking overall
Returns:
the validation component

createPrimaryTableComponent

protected com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createPrimaryTableComponent(MappingTableElement primaryTable)
Create a validation component which can check whether the class is mapped to tables even though the schema is null or the class is mapped to a primary table without a primary key.

Parameters:
primaryTable - the primary table for the class
Returns:
the validation component

createTableExistenceComponent

protected com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createTableExistenceComponent(String tableName)
Create a validation component which can check whether the given table exists.

Parameters:
tableName - the table whose existence is being checked
Returns:
the validation component

createTableExistenceComponent

protected com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createTableExistenceComponent(String tableName,
                                                                                                                  PersistenceFieldElement relatedField)
Create a validation component which can check whether the given table exists.

Parameters:
tableName - the table whose existence is being checked
relatedField - the relationship field whose class' table is being checked, may be null in which case we are probably checking the same class as the validator is checking overall
Returns:
the validation component

createColumnExistenceComponent

protected com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createColumnExistenceComponent(String columnName)
Create a validation component which can check whether the given column exists.

Parameters:
columnName - the column whose existence is being checked
Returns:
the validation component

createColumnExistenceComponent

protected com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createColumnExistenceComponent(String columnName,
                                                                                                                   MappingFieldElement relatedField)
Create a validation component which can check whether the given column or column pair exists.

Parameters:
columnName - the column or pair whose existence is being checked
relatedField - the field whose class' column is being checked, may be null in which case we are probably checking the same secondary table setup
Returns:
the validation component

createColumnOverlapComponent

protected com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createColumnOverlapComponent(MappingFieldElement field)
Create a validation component which can check whether the field is one of a set mapped to overlapping columns

Parameters:
field - the field whose column mapping is being checked
Returns:
the validation component

createKeyClassComponent

protected com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createKeyClassComponent(String className)
Create a validation component which can check whether the key class of the persistence capable class is valid. This includes:


createSerializableClassComponent

protected com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createSerializableClassComponent(String className)
Create a validation component which can check that the persistence capable class implement methods readObject and writeObject, if the class implements the intreface java.io.Serializable

Parameters:
className - the class whose methods are checked
Returns:
the validation component

createClassMappingComponent

protected com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createClassMappingComponent(PersistenceClassElement persistenceClass)
Create a validation component which can check whether the class is unmapped.

Parameters:
persistenceClass - the class whose mapping is being checked
Returns:
the validation component

createKeyColumnMappingComponent

protected com.sun.jdo.api.persistence.model.util.ModelValidator.ValidationComponent createKeyColumnMappingComponent(PersistenceClassElement persistenceClass)
Create a validation component which can check whether the class contains field mappings for all primary key columns.

Parameters:
persistenceClass - the class whose mapping is being checked
Returns:
the validation component


Copyright © 2012 GlassFish Community. All Rights Reserved.