FileDocCategorySizeDatePackage
IntegrityChecker.javaAPI DocGlassfish v2 API9069Tue May 22 16:54:18 BST 2007oracle.toplink.essentials.exceptions

IntegrityChecker

public class IntegrityChecker extends Object implements Serializable

Purpose: IntegrityChecker is used for catching all the descriptor exceptions, and checking database tables. It gives the user options if he/she wants to catch descriptor exceptions, check database, and check InstantiationPolicy or not.

Fields Summary
protected Vector
caughtExceptions
To add all the Descriptor exceptions
protected Vector
tables
To load the tables from database
protected boolean
shouldCatchExceptions
To know that should we catch all the descriptors exceptions or not
protected boolean
shouldCheckDatabase
To know that should we check database tables or not
protected boolean
shouldCheckInstantiationPolicy
To know that should we check InstantiationPolicy or not
Constructors Summary
public IntegrityChecker()
PUBLIC: IntegrityChecker is used for catching all the Descriptor Exceptions, and check database tables. IntegrityChecker gives the option to the user that does he wants to catch all the descriptor exceptions,check database, and check InstantiationPolicy or not.


                                              
      
        super();
        this.shouldCatchExceptions = true;
        this.shouldCheckDatabase = false;
        this.shouldCheckInstantiationPolicy = true;
    
Methods Summary
public voidcatchExceptions()
PUBLIC: This method is used for catching all the Descriptor Exceptions

        setShouldCatchExceptions(true);
    
public voidcheckDatabase()
PUBLIC: This method is used to check the database tables.

        setShouldCheckDatabase(true);
    
public voidcheckInstantiationPolicy()
PUBLIC: This method is used to check the InstantiationPolicy.

        setShouldCheckInstantiationPolicy(true);
    
public booleancheckTable(oracle.toplink.essentials.internal.helper.DatabaseTable table, oracle.toplink.essentials.internal.sessions.AbstractSession session)
INTERNAL: This method checks that tables are present in the database.

        if (getTables().size() == 0) {
            // load the tables from the session
            initializeTables(session);
        }
        //MySQL converts all the table names to lower case.
        if (session.getPlatform().isMySQL()) {
            return getTables().contains(table.getName().toLowerCase());
        }
        return getTables().contains(table.getName());
    
public voiddontCatchExceptions()
PUBLIC: This method is used for don't catching all the Descriptor Exceptions

        setShouldCatchExceptions(false);
    
public voiddontCheckDatabase()
PUBLIC: This method is used for don't checking the database tables and fields.

        setShouldCheckDatabase(false);
    
public voiddontCheckInstantiationPolicy()
PUBLIC: This method is used for don't checking the InstantiationPolicy.

        setShouldCheckInstantiationPolicy(false);
    
public java.util.VectorgetCaughtExceptions()
PUBLIC: This method returns the vecotr which adds all the Descriptors Exceptions.

        if (caughtExceptions == null) {
            caughtExceptions = new Vector();
        }
        return caughtExceptions;
    
public java.util.VectorgetTables()
INTERNAL: This method returns a vector which holds all the tables of database

        if (tables == null) {
            tables = new Vector();
        }
        return tables;
    
public voidhandleError(java.lang.RuntimeException runtimeException)
INTERNAL: This method handle all the Descriptor Exceptions. This method throw the exception or add the exceptions into a vector depand on the value of shouldCatchExceptions.

        if (!shouldCatchExceptions()) {
            throw runtimeException;
        }
        getCaughtExceptions().addElement(runtimeException);
    
public booleanhasErrors()
INTERNAL: Return if any errors occured.

        if ((caughtExceptions != null) && (caughtExceptions.size() > 0)) {
            return true;
        }
        return false;
    
public booleanhasRuntimeExceptions()
INTERNAL: Return if any runtime errors occured.

        if (hasErrors()) {
            for (Enumeration exceptionsEnum = getCaughtExceptions().elements();
                     exceptionsEnum.hasMoreElements();) {
                if (exceptionsEnum.nextElement() instanceof RuntimeException) {
                    return true;
                }
            }
        }
        return false;
    
public voidinitializeTables(oracle.toplink.essentials.internal.sessions.AbstractSession session)
INTERNAL: This method is used to get all the database tables and add them into a vector.

        Vector result = session.getAccessor().getTableInfo(null, null, null, null, session);
        for (Enumeration resultEnum = result.elements(); resultEnum.hasMoreElements();) {
            AbstractRecord row = (AbstractRecord)resultEnum.nextElement();
            tables.addElement(row.get("TABLE_NAME"));
        }
    
public voidsetCaughtExceptions(java.util.Vector exceptions)
INTERNAL:

        this.caughtExceptions = exceptions;
    
public voidsetShouldCatchExceptions(boolean answer)
PUBLIC: This method assigns the value to the variable (shouldCatchExceptions) that we should catch all Descriptor Exceptions or not.

        shouldCatchExceptions = answer;
    
public voidsetShouldCheckDatabase(boolean answer)
PUBLIC: This method assigns the value to the variable (shouldCheckDatabase) that we should check database or not.

        shouldCheckDatabase = answer;
    
public voidsetShouldCheckInstantiationPolicy(boolean answer)
PUBLIC: This method assigns the value to the variable (shouldCheckInstantiationPolicy) that we should check InstantiationPolicy or not.

        shouldCheckInstantiationPolicy = answer;
    
public booleanshouldCatchExceptions()
PUBLIC: This method is used to know that all the Descriptor Exceptions should be thrown or not.

        return shouldCatchExceptions;
    
public booleanshouldCheckDatabase()
PUBLIC: This method is used to know that database tables and fields should be checked or not.

        return shouldCheckDatabase;
    
public booleanshouldCheckInstantiationPolicy()
PUBLIC: This method tells us that we should check InstantiationPolicy or not.

        return shouldCheckInstantiationPolicy;