/*
 * IMPORTANT!!!! XSL Autogenerated class, DO NOT EDIT!!!!!
 * Template: Infrastructure8.2 rev3 [oneit.objstore.BusinessObjectTemplate.xsl]
 *
 *   Version: 1.0
 *   Vendor: Apache Software Foundation (Xalan XSLTC)
 *   Vendor URL: http://xml.apache.org/xalan-j
 */


    package performa.orm;

import java.io.*;
import java.util.*;
import oneit.appservices.config.*;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.objstore.assocs.*;
import oneit.objstore.attributes.*;
import oneit.objstore.rdbms.filters.*;
import oneit.objstore.parser.*;
import oneit.objstore.validator.*;
import oneit.objstore.utils.*;
import oneit.utils.*;
import oneit.utils.filter.Filter;
import oneit.utils.transform.*;
import oneit.utils.parsers.FieldException;



public abstract class BaseQuestion extends BaseBusinessClass
{
    // Reference instance for the object
    public static final Question REFERENCE_Question = new Question ();

    // Reference instance for the object
    public static final Question DUMMY_Question = new DummyQuestion ();

    // Static constants corresponding to field names
    
    public static final String FIELD_LeftQuestionNo = "LeftQuestionNo";
    public static final String FIELD_LeftQuestion = "LeftQuestion";
    public static final String FIELD_RightQuestionNo = "RightQuestionNo";
    public static final String FIELD_RightQuestion = "RightQuestion";

    // Static constants corresponding to searches
    

    // Static constants corresponding to attribute helpers
    private static final DefaultAttributeHelper<Question> HELPER_LeftQuestionNo = DefaultAttributeHelper.INSTANCE;
    private static final DefaultAttributeHelper<Question> HELPER_LeftQuestion = DefaultAttributeHelper.INSTANCE;
    private static final DefaultAttributeHelper<Question> HELPER_RightQuestionNo = DefaultAttributeHelper.INSTANCE;
    private static final DefaultAttributeHelper<Question> HELPER_RightQuestion = DefaultAttributeHelper.INSTANCE;
    

    // Private attributes corresponding to business object data
    private Integer _LeftQuestionNo;
    private String _LeftQuestion;
    private Integer _RightQuestionNo;
    private String _RightQuestion;
    

    // Private attributes corresponding to single references
    

    // Private attributes corresponding to multiple references
    

    // Map of maps of metadata
    private static final Map ATTRIBUTES_METADATA_Question = new HashMap ();

    // Arrays of validators for each attribute
    private static final AttributeValidator[] FIELD_LeftQuestionNo_Validators;
    private static final AttributeValidator[] FIELD_LeftQuestion_Validators;
    private static final AttributeValidator[] FIELD_RightQuestionNo_Validators;
    private static final AttributeValidator[] FIELD_RightQuestion_Validators;
    

    // Arrays of behaviour decorators
    private static final QuestionBehaviourDecorator[] Question_BehaviourDecorators;
    
    static
    {
        try
        {
            
            
            Map  validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));

            FIELD_LeftQuestionNo_Validators = (AttributeValidator[])setupAttribMetaData_LeftQuestionNo(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_LeftQuestion_Validators = (AttributeValidator[])setupAttribMetaData_LeftQuestion(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_RightQuestionNo_Validators = (AttributeValidator[])setupAttribMetaData_RightQuestionNo(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_RightQuestion_Validators = (AttributeValidator[])setupAttribMetaData_RightQuestion(validatorMapping).toArray (new AttributeValidator[0]);
            

            REFERENCE_Question.initialiseReference ();
            DUMMY_Question.initialiseReference ();
            Question_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(Question.class).toArray(new QuestionBehaviourDecorator[0]);
        }
        catch (RuntimeException e)
        {
            LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR1, e, "Error initialising");
            throw e;
        }
    }

    
    // Meta Info setup
    private static List setupAttribMetaData_LeftQuestionNo(Map validatorMapping)
    {
        Map  metaInfo   = new HashMap ();

        metaInfo.put ("dbcol", "left_quest_number");
        metaInfo.put ("name", "LeftQuestionNo");
        metaInfo.put ("type", "Integer");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Question.LeftQuestionNo:", metaInfo);
        ATTRIBUTES_METADATA_Question.put (FIELD_LeftQuestionNo, Collections.unmodifiableMap (metaInfo));

        List validators = BaseBusinessClass.getAttribValidators(Question.class, "LeftQuestionNo", metaInfo, validatorMapping);
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for Question.LeftQuestionNo:", validators);        

        return validators;
    }
    
    // Meta Info setup
    private static List setupAttribMetaData_LeftQuestion(Map validatorMapping)
    {
        Map  metaInfo   = new HashMap ();

        metaInfo.put ("dbcol", "left_quest");
        metaInfo.put ("length", "80");
        metaInfo.put ("name", "LeftQuestion");
        metaInfo.put ("type", "String");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Question.LeftQuestion:", metaInfo);
        ATTRIBUTES_METADATA_Question.put (FIELD_LeftQuestion, Collections.unmodifiableMap (metaInfo));

        List validators = BaseBusinessClass.getAttribValidators(Question.class, "LeftQuestion", metaInfo, validatorMapping);
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for Question.LeftQuestion:", validators);        

        return validators;
    }
    
    // Meta Info setup
    private static List setupAttribMetaData_RightQuestionNo(Map validatorMapping)
    {
        Map  metaInfo   = new HashMap ();

        metaInfo.put ("dbcol", "right_quest_number");
        metaInfo.put ("name", "RightQuestionNo");
        metaInfo.put ("type", "Integer");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Question.RightQuestionNo:", metaInfo);
        ATTRIBUTES_METADATA_Question.put (FIELD_RightQuestionNo, Collections.unmodifiableMap (metaInfo));

        List validators = BaseBusinessClass.getAttribValidators(Question.class, "RightQuestionNo", metaInfo, validatorMapping);
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for Question.RightQuestionNo:", validators);        

        return validators;
    }
    
    // Meta Info setup
    private static List setupAttribMetaData_RightQuestion(Map validatorMapping)
    {
        Map  metaInfo   = new HashMap ();

        metaInfo.put ("dbcol", "right_quest");
        metaInfo.put ("length", "80");
        metaInfo.put ("name", "RightQuestion");
        metaInfo.put ("type", "String");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Question.RightQuestion:", metaInfo);
        ATTRIBUTES_METADATA_Question.put (FIELD_RightQuestion, Collections.unmodifiableMap (metaInfo));

        List validators = BaseBusinessClass.getAttribValidators(Question.class, "RightQuestion", metaInfo, validatorMapping);
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for Question.RightQuestion:", validators);        

        return validators;
    }
    
    // END OF STATIC METADATA DEFINITION    
    
    
    
    // This constructor should not be called
    protected BaseQuestion ()
    {
    }


    protected BBCBehaviourDecorator[] getBehaviours()
    {
        return Question_BehaviourDecorators;
    }
    
    


    


    // Initialise the attributes
    protected void _initialiseNewObjAttributes (ObjectTransaction transaction) throws StorageException
    {
        super._initialiseNewObjAttributes (transaction);

        
        _LeftQuestionNo = (Integer)(HELPER_LeftQuestionNo.initialise (_LeftQuestionNo));
        _LeftQuestion = (String)(HELPER_LeftQuestion.initialise (_LeftQuestion));
        _RightQuestionNo = (Integer)(HELPER_RightQuestionNo.initialise (_RightQuestionNo));
        _RightQuestion = (String)(HELPER_RightQuestion.initialise (_RightQuestion));
    }


    // Initialise the associations
    protected void _initialiseAssociations ()
    {
        super._initialiseAssociations ();

        
    }


    // Initialise the associations
    protected BaseBusinessClass initialiseReference ()
    {
        super.initialiseReference ();
        
        
        
        return this;
    }

    

    /**
     * Get the attribute LeftQuestionNo
     */
    public Integer getLeftQuestionNo ()
    {
        assertValid();
        Integer valToReturn = _LeftQuestionNo;

            for (QuestionBehaviourDecorator bhd : Question_BehaviourDecorators)
            {
                valToReturn = bhd.getLeftQuestionNo ((Question)this, valToReturn);
            }
            
            return valToReturn;
        
    }


    /**
     * Called prior to the attribute changing.  Subclasses need not call super.  If a field exception
     * is thrown, the attribute change will fail.  The new value is different to the old value.
     */
    protected void preLeftQuestionNoChange (Integer newLeftQuestionNo) throws FieldException
    {
    }


    /**
     * Called after the attribute changes.
     * If a field exception is thrown, the value is still changed, however it 
     * may lead to the TX being rolled back
     */
    protected void postLeftQuestionNoChange () throws FieldException
    {
    }

    
    public FieldWriteability getWriteability_LeftQuestionNo ()
    {
        return getFieldWritabilityUtil (FieldWriteability.TRUE);
    }

    /**
     * Set the attribute LeftQuestionNo.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setLeftQuestionNo (Integer newLeftQuestionNo) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_LeftQuestionNo.compare (_LeftQuestionNo, newLeftQuestionNo);
        
        try
        {
            for (QuestionBehaviourDecorator bhd : Question_BehaviourDecorators)
            {
                newLeftQuestionNo = bhd.setLeftQuestionNo ((Question)this, newLeftQuestionNo);
                oldAndNewIdentical = HELPER_LeftQuestionNo.compare (_LeftQuestionNo, newLeftQuestionNo);
            }

            

            if (FIELD_LeftQuestionNo_Validators.length > 0)
            {
                Object newLeftQuestionNoObj = HELPER_LeftQuestionNo.toObject (newLeftQuestionNo);

                if (newLeftQuestionNoObj != null)
                {
                    int     loopMax = FIELD_LeftQuestionNo_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_Question.get (FIELD_LeftQuestionNo);

                    for (int v = 0 ; v < loopMax ; ++v)
                    {
                        FIELD_LeftQuestionNo_Validators[v].checkAttribute (this, FIELD_LeftQuestionNo, metadata, newLeftQuestionNoObj);
                    }
                }
            }
        }
        catch (FieldException e)
        {
            if (!oldAndNewIdentical)
            {
                e.setWouldModify ();
            }
            
            throw e;
        }

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_LeftQuestionNo () != FieldWriteability.FALSE, "Field  LeftQuestionNo is not writeable");
            preLeftQuestionNoChange (newLeftQuestionNo);
            markFieldChange (FIELD_LeftQuestionNo);
            _LeftQuestionNo = newLeftQuestionNo;            
            postFieldChange (FIELD_LeftQuestionNo);
            postLeftQuestionNoChange ();
        }
    }

    /**
     * Get the attribute LeftQuestion
     */
    public String getLeftQuestion ()
    {
        assertValid();
        String valToReturn = _LeftQuestion;

            for (QuestionBehaviourDecorator bhd : Question_BehaviourDecorators)
            {
                valToReturn = bhd.getLeftQuestion ((Question)this, valToReturn);
            }
            
            return valToReturn;
        
    }


    /**
     * Called prior to the attribute changing.  Subclasses need not call super.  If a field exception
     * is thrown, the attribute change will fail.  The new value is different to the old value.
     */
    protected void preLeftQuestionChange (String newLeftQuestion) throws FieldException
    {
    }


    /**
     * Called after the attribute changes.
     * If a field exception is thrown, the value is still changed, however it 
     * may lead to the TX being rolled back
     */
    protected void postLeftQuestionChange () throws FieldException
    {
    }

    
    public FieldWriteability getWriteability_LeftQuestion ()
    {
        return getFieldWritabilityUtil (FieldWriteability.TRUE);
    }

    /**
     * Set the attribute LeftQuestion.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setLeftQuestion (String newLeftQuestion) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_LeftQuestion.compare (_LeftQuestion, newLeftQuestion);
        
        try
        {
            for (QuestionBehaviourDecorator bhd : Question_BehaviourDecorators)
            {
                newLeftQuestion = bhd.setLeftQuestion ((Question)this, newLeftQuestion);
                oldAndNewIdentical = HELPER_LeftQuestion.compare (_LeftQuestion, newLeftQuestion);
            }

            

            if (FIELD_LeftQuestion_Validators.length > 0)
            {
                Object newLeftQuestionObj = HELPER_LeftQuestion.toObject (newLeftQuestion);

                if (newLeftQuestionObj != null)
                {
                    int     loopMax = FIELD_LeftQuestion_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_Question.get (FIELD_LeftQuestion);

                    for (int v = 0 ; v < loopMax ; ++v)
                    {
                        FIELD_LeftQuestion_Validators[v].checkAttribute (this, FIELD_LeftQuestion, metadata, newLeftQuestionObj);
                    }
                }
            }
        }
        catch (FieldException e)
        {
            if (!oldAndNewIdentical)
            {
                e.setWouldModify ();
            }
            
            throw e;
        }

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_LeftQuestion () != FieldWriteability.FALSE, "Field  LeftQuestion is not writeable");
            preLeftQuestionChange (newLeftQuestion);
            markFieldChange (FIELD_LeftQuestion);
            _LeftQuestion = newLeftQuestion;            
            postFieldChange (FIELD_LeftQuestion);
            postLeftQuestionChange ();
        }
    }

    /**
     * Get the attribute RightQuestionNo
     */
    public Integer getRightQuestionNo ()
    {
        assertValid();
        Integer valToReturn = _RightQuestionNo;

            for (QuestionBehaviourDecorator bhd : Question_BehaviourDecorators)
            {
                valToReturn = bhd.getRightQuestionNo ((Question)this, valToReturn);
            }
            
            return valToReturn;
        
    }


    /**
     * Called prior to the attribute changing.  Subclasses need not call super.  If a field exception
     * is thrown, the attribute change will fail.  The new value is different to the old value.
     */
    protected void preRightQuestionNoChange (Integer newRightQuestionNo) throws FieldException
    {
    }


    /**
     * Called after the attribute changes.
     * If a field exception is thrown, the value is still changed, however it 
     * may lead to the TX being rolled back
     */
    protected void postRightQuestionNoChange () throws FieldException
    {
    }

    
    public FieldWriteability getWriteability_RightQuestionNo ()
    {
        return getFieldWritabilityUtil (FieldWriteability.TRUE);
    }

    /**
     * Set the attribute RightQuestionNo.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setRightQuestionNo (Integer newRightQuestionNo) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_RightQuestionNo.compare (_RightQuestionNo, newRightQuestionNo);
        
        try
        {
            for (QuestionBehaviourDecorator bhd : Question_BehaviourDecorators)
            {
                newRightQuestionNo = bhd.setRightQuestionNo ((Question)this, newRightQuestionNo);
                oldAndNewIdentical = HELPER_RightQuestionNo.compare (_RightQuestionNo, newRightQuestionNo);
            }

            

            if (FIELD_RightQuestionNo_Validators.length > 0)
            {
                Object newRightQuestionNoObj = HELPER_RightQuestionNo.toObject (newRightQuestionNo);

                if (newRightQuestionNoObj != null)
                {
                    int     loopMax = FIELD_RightQuestionNo_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_Question.get (FIELD_RightQuestionNo);

                    for (int v = 0 ; v < loopMax ; ++v)
                    {
                        FIELD_RightQuestionNo_Validators[v].checkAttribute (this, FIELD_RightQuestionNo, metadata, newRightQuestionNoObj);
                    }
                }
            }
        }
        catch (FieldException e)
        {
            if (!oldAndNewIdentical)
            {
                e.setWouldModify ();
            }
            
            throw e;
        }

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_RightQuestionNo () != FieldWriteability.FALSE, "Field  RightQuestionNo is not writeable");
            preRightQuestionNoChange (newRightQuestionNo);
            markFieldChange (FIELD_RightQuestionNo);
            _RightQuestionNo = newRightQuestionNo;            
            postFieldChange (FIELD_RightQuestionNo);
            postRightQuestionNoChange ();
        }
    }

    /**
     * Get the attribute RightQuestion
     */
    public String getRightQuestion ()
    {
        assertValid();
        String valToReturn = _RightQuestion;

            for (QuestionBehaviourDecorator bhd : Question_BehaviourDecorators)
            {
                valToReturn = bhd.getRightQuestion ((Question)this, valToReturn);
            }
            
            return valToReturn;
        
    }


    /**
     * Called prior to the attribute changing.  Subclasses need not call super.  If a field exception
     * is thrown, the attribute change will fail.  The new value is different to the old value.
     */
    protected void preRightQuestionChange (String newRightQuestion) throws FieldException
    {
    }


    /**
     * Called after the attribute changes.
     * If a field exception is thrown, the value is still changed, however it 
     * may lead to the TX being rolled back
     */
    protected void postRightQuestionChange () throws FieldException
    {
    }

    
    public FieldWriteability getWriteability_RightQuestion ()
    {
        return getFieldWritabilityUtil (FieldWriteability.TRUE);
    }

    /**
     * Set the attribute RightQuestion.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setRightQuestion (String newRightQuestion) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_RightQuestion.compare (_RightQuestion, newRightQuestion);
        
        try
        {
            for (QuestionBehaviourDecorator bhd : Question_BehaviourDecorators)
            {
                newRightQuestion = bhd.setRightQuestion ((Question)this, newRightQuestion);
                oldAndNewIdentical = HELPER_RightQuestion.compare (_RightQuestion, newRightQuestion);
            }

            

            if (FIELD_RightQuestion_Validators.length > 0)
            {
                Object newRightQuestionObj = HELPER_RightQuestion.toObject (newRightQuestion);

                if (newRightQuestionObj != null)
                {
                    int     loopMax = FIELD_RightQuestion_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_Question.get (FIELD_RightQuestion);

                    for (int v = 0 ; v < loopMax ; ++v)
                    {
                        FIELD_RightQuestion_Validators[v].checkAttribute (this, FIELD_RightQuestion, metadata, newRightQuestionObj);
                    }
                }
            }
        }
        catch (FieldException e)
        {
            if (!oldAndNewIdentical)
            {
                e.setWouldModify ();
            }
            
            throw e;
        }

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_RightQuestion () != FieldWriteability.FALSE, "Field  RightQuestion is not writeable");
            preRightQuestionChange (newRightQuestion);
            markFieldChange (FIELD_RightQuestion);
            _RightQuestion = newRightQuestion;            
            postFieldChange (FIELD_RightQuestion);
            postRightQuestionChange ();
        }
    }



    /**
     * A list of multi assoc names e.g. list of strings.
     */
    public List<String> getSingleAssocs()
    {
        List result = super.getSingleAssocs ();

        

        return result;
    }
    
    
    public BaseBusinessClass getSingleAssocReferenceInstance (String assocName)
    {
        if (assocName == null)
        {
            throw new RuntimeException ("Game over == null!");
        }
        
        else
        {
            return super.getSingleAssocReferenceInstance (assocName);
        }
    }


    public String getSingleAssocBackReference(String assocName)
    {
        if (assocName == null)
        {
            throw new RuntimeException ("Game over == null!");
        }
        
        else
        {
            return super.getSingleAssocBackReference (assocName);
        }
    }
    
    
    public BaseBusinessClass getSingleAssoc (String assocName) throws StorageException
    {
        if (assocName == null)
        {
            throw new RuntimeException ("Game over == null!");
        }
        
        else
        {
            return super.getSingleAssoc (assocName);
        }
    }


    public BaseBusinessClass getSingleAssoc (String assocName, Get getType) throws StorageException
    {
        if (assocName == null)
        {
            throw new RuntimeException ("Game over == null!");
        }
        
        else
        {
            return super.getSingleAssoc (assocName, getType);
        }
    }


    public Long getSingleAssocID (String assocName) throws StorageException
    {
        if (assocName == null)
        {
            throw new RuntimeException ("Game over == null!");
        }
        
        else
        {
            return super.getSingleAssocID (assocName);
        }
    }


    public void setSingleAssoc (String assocName, BaseBusinessClass newValue) throws StorageException, FieldException
    {
        if (assocName == null)
        {
            throw new RuntimeException ("Game over == null!");
        }
        
        else
        {
            super.setSingleAssoc (assocName, newValue);
        }
    }



    /**
     * A list of multi assoc names e.g. list of strings.
     */
    public List<String> getMultiAssocs()
    {
        List result = super.getMultiAssocs ();

        

        return result;
    }


    /**
     * Get the reference instance for the multi assoc name.
     */
    public BaseBusinessClass getMultiAssocReferenceInstance(String attribName)
    {
        

        return super.getMultiAssocReferenceInstance(attribName);
    }


    public String getMultiAssocBackReference(String attribName)
    {
        

        return super.getMultiAssocBackReference(attribName);
    }


    /**
     * Get the assoc count for the multi assoc name.
     */
    public int getMultiAssocCount(String attribName) throws StorageException
    {
        

        return super.getMultiAssocCount(attribName);
    }


    /**
     * Get the assoc at a particular index
     */
    public BaseBusinessClass getMultiAssocAt(String attribName, int index) throws StorageException
    {
        

        return super.getMultiAssocAt(attribName, index);
    }


    /**
     * Add to a multi assoc by attribute name
     */
    public void addToMultiAssoc(String attribName, BaseBusinessClass newElement) throws StorageException
    {
        

        super.addToMultiAssoc(attribName, newElement);
    }

    /**
     * Remove from a multi assoc by attribute name
     */
    public void removeFromMultiAssoc(String attribName, BaseBusinessClass oldElement) throws StorageException
    {
        

        super.removeFromMultiAssoc(attribName, oldElement);
    }


    protected void __loadMultiAssoc (String attribName, BaseBusinessClass[] elements)
    {
        

        super.__loadMultiAssoc(attribName, elements);
    }


    protected boolean __isMultiAssocLoaded (String attribName)
    {
        

        return super.__isMultiAssocLoaded(attribName);
    }

    



    public void onDelete ()
    {
        try 
        {
        }
        catch (Exception e)
        {
            throw NestedException.wrap(e);
        }

        super.onDelete ();
    }


    public Question newInstance ()
    {
        return new Question ();
    }


    public Question referenceInstance ()
    {
        return REFERENCE_Question;
    }


    public Question getInTransaction (ObjectTransaction t) throws StorageException
    {
        return getQuestionByID (t, getObjectID());
    }
    
    
    public BaseBusinessClass dummyInstance ()
    {
        return DUMMY_Question;
    }


    public String getBaseSetName ()
    {
        return "quest_lin";
    }





    /**
     * This is where an object returns the Persistent sets that will
     * store it into the database.
     * The should be entered into allSets
     */
    public void getPersistentSets (PersistentSetCollection allSets)
    {
        ObjectStatus        myStatus = getStatus ();
        PersistentSetStatus myPSetStatus = myStatus.getPSetStatus();
        ObjectID            myID = getID();

        super.getPersistentSets (allSets);

        
        PersistentSet   quest_linPSet = allSets.getPersistentSet (myID, "quest_lin", myPSetStatus);

        quest_linPSet.setAttrib (FIELD_ObjectID, myID);
        quest_linPSet.setAttrib (FIELD_LeftQuestionNo, HELPER_LeftQuestionNo.toObject (_LeftQuestionNo)); //
        quest_linPSet.setAttrib (FIELD_LeftQuestion, HELPER_LeftQuestion.toObject (_LeftQuestion)); //
        quest_linPSet.setAttrib (FIELD_RightQuestionNo, HELPER_RightQuestionNo.toObject (_RightQuestionNo)); //
        quest_linPSet.setAttrib (FIELD_RightQuestion, HELPER_RightQuestion.toObject (_RightQuestion)); //
        
    }


    /**
     * Sets the objects state based on Persistent sets.
     */
    public void setFromPersistentSets (ObjectID objectID, PersistentSetCollection allSets)
    {
        super.setFromPersistentSets (objectID, allSets);

        
        PersistentSet   quest_linPSet = allSets.getPersistentSet (objectID, "quest_lin");

        _LeftQuestionNo = (Integer)(HELPER_LeftQuestionNo.fromObject (_LeftQuestionNo, quest_linPSet.getAttrib (FIELD_LeftQuestionNo))); //
        _LeftQuestion = (String)(HELPER_LeftQuestion.fromObject (_LeftQuestion, quest_linPSet.getAttrib (FIELD_LeftQuestion))); //
        _RightQuestionNo = (Integer)(HELPER_RightQuestionNo.fromObject (_RightQuestionNo, quest_linPSet.getAttrib (FIELD_RightQuestionNo))); //
        _RightQuestion = (String)(HELPER_RightQuestion.fromObject (_RightQuestion, quest_linPSet.getAttrib (FIELD_RightQuestion))); //
        
    }





    public void setAttributesFrom (BaseBusinessClass other, MultiException e)
    {
        super.setAttributesFrom (other, e);

        if (other instanceof Question)
        {
            Question otherQuestion = (Question)other;
            
            try
            {
                setLeftQuestionNo (otherQuestion.getLeftQuestionNo ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
            try
            {
                setLeftQuestion (otherQuestion.getLeftQuestion ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
            try
            {
                setRightQuestionNo (otherQuestion.getRightQuestionNo ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
            try
            {
                setRightQuestion (otherQuestion.getRightQuestion ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
        }
    }


    /**
     * Set the attributes in this to copies of the attributes in source.
     */
    public void copyAttributesFrom (BaseBusinessClass source)
    {
        super.copyAttributesFrom (source);

        if (source instanceof BaseQuestion)
        {
            BaseQuestion sourceQuestion = (BaseQuestion)(source);

            _LeftQuestionNo = sourceQuestion._LeftQuestionNo;
            _LeftQuestion = sourceQuestion._LeftQuestion;
            _RightQuestionNo = sourceQuestion._RightQuestionNo;
            _RightQuestion = sourceQuestion._RightQuestion;
            
        }
    }


    /**
     * Set the associations in this to copies of the attributes in source.
     */
    public void copySingleAssociationsFrom (BaseBusinessClass source, boolean linkToGhosts)
    {
        super.copySingleAssociationsFrom (source, linkToGhosts);

        if (source instanceof BaseQuestion)
        {
            BaseQuestion sourceQuestion = (BaseQuestion)(source);

            
        }
    }


    /**
     * Set the associations in this to copies of the attributes in source.
     */
    public void copyAssociationsFrom (BaseBusinessClass source, boolean linkToGhosts)
    {
        super.copyAssociationsFrom (source, linkToGhosts);

        if (source instanceof BaseQuestion)
        {
            BaseQuestion sourceQuestion = (BaseQuestion)(source);

            
        }
    }


    public void validate (ValidationContext context)
    {
        super.validate (context);

        
    }


    /**
     * Subclasses must override this to read in their attributes
     */
    protected void readExternalData(Map<String, Object> vals) throws IOException, ClassNotFoundException
    {
        super.readExternalData(vals);

        _LeftQuestionNo = (Integer)(HELPER_LeftQuestionNo.readExternal (_LeftQuestionNo, vals.get(FIELD_LeftQuestionNo))); //
        _LeftQuestion = (String)(HELPER_LeftQuestion.readExternal (_LeftQuestion, vals.get(FIELD_LeftQuestion))); //
        _RightQuestionNo = (Integer)(HELPER_RightQuestionNo.readExternal (_RightQuestionNo, vals.get(FIELD_RightQuestionNo))); //
        _RightQuestion = (String)(HELPER_RightQuestion.readExternal (_RightQuestion, vals.get(FIELD_RightQuestion))); //
        
    }


    /**
     * Subclasses must override this to write out their attributes
     */
    protected void writeExternalData(Map<String, Object> vals) throws IOException
    {
        super.writeExternalData(vals);

        vals.put (FIELD_LeftQuestionNo, HELPER_LeftQuestionNo.writeExternal (_LeftQuestionNo));
        vals.put (FIELD_LeftQuestion, HELPER_LeftQuestion.writeExternal (_LeftQuestion));
        vals.put (FIELD_RightQuestionNo, HELPER_RightQuestionNo.writeExternal (_RightQuestionNo));
        vals.put (FIELD_RightQuestion, HELPER_RightQuestion.writeExternal (_RightQuestion));
        
    }


    public void compare (BaseBusinessClass other, AttributeChangeListener listener) throws StorageException
    {
        super.compare (other, listener);

        if (other instanceof BaseQuestion)
        {
            BaseQuestion otherQuestion = (BaseQuestion)(other);

            
            if (!HELPER_LeftQuestionNo.compare(this._LeftQuestionNo, otherQuestion._LeftQuestionNo))
            {
                listener.notifyFieldChange(this, other, FIELD_LeftQuestionNo, HELPER_LeftQuestionNo.toObject(this._LeftQuestionNo), HELPER_LeftQuestionNo.toObject(otherQuestion._LeftQuestionNo));
            }
            if (!HELPER_LeftQuestion.compare(this._LeftQuestion, otherQuestion._LeftQuestion))
            {
                listener.notifyFieldChange(this, other, FIELD_LeftQuestion, HELPER_LeftQuestion.toObject(this._LeftQuestion), HELPER_LeftQuestion.toObject(otherQuestion._LeftQuestion));
            }
            if (!HELPER_RightQuestionNo.compare(this._RightQuestionNo, otherQuestion._RightQuestionNo))
            {
                listener.notifyFieldChange(this, other, FIELD_RightQuestionNo, HELPER_RightQuestionNo.toObject(this._RightQuestionNo), HELPER_RightQuestionNo.toObject(otherQuestion._RightQuestionNo));
            }
            if (!HELPER_RightQuestion.compare(this._RightQuestion, otherQuestion._RightQuestion))
            {
                listener.notifyFieldChange(this, other, FIELD_RightQuestion, HELPER_RightQuestion.toObject(this._RightQuestion), HELPER_RightQuestion.toObject(otherQuestion._RightQuestion));
            }

            // Compare single assocs
            

            // Compare multiple assocs
            
        }
    }


    public void visitTransients (AttributeVisitor visitor) throws StorageException
    {
        super.visitAttributes (visitor);

        
    }


    public void visitAttributes (AttributeVisitor visitor) throws StorageException
    {
        super.visitAttributes (visitor);

        visitor.visitField(this, FIELD_LeftQuestionNo, HELPER_LeftQuestionNo.toObject(getLeftQuestionNo()));
        visitor.visitField(this, FIELD_LeftQuestion, HELPER_LeftQuestion.toObject(getLeftQuestion()));
        visitor.visitField(this, FIELD_RightQuestionNo, HELPER_RightQuestionNo.toObject(getRightQuestionNo()));
        visitor.visitField(this, FIELD_RightQuestion, HELPER_RightQuestion.toObject(getRightQuestion()));
        
    }


    public void visitAssociations (AssociationVisitor visitor, AssociatedScope scope) throws StorageException
    {
        super.visitAssociations (visitor, scope);

        
    }


    public static Question createQuestion (ObjectTransaction transaction) throws StorageException
    {
        Question     result = new Question ();

        result.initialiseNewObject (transaction);

        return result;
    }


    public static Question getQuestionByID (ObjectTransaction transaction, Long objectID) throws StorageException
    {
        return (Question)(transaction.getObjectByID (REFERENCE_Question, objectID));
    }

    public boolean testFilter (String attribName, QueryFilter filter) throws StorageException
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_LeftQuestionNo))
        {
            return filter.matches (getLeftQuestionNo ());
        }
        else if (attribName.equals (FIELD_LeftQuestion))
        {
            return filter.matches (getLeftQuestion ());
        }
        else if (attribName.equals (FIELD_RightQuestionNo))
        {
            return filter.matches (getRightQuestionNo ());
        }
        else if (attribName.equals (FIELD_RightQuestion))
        {
            return filter.matches (getRightQuestion ());
        }
        else
        {
            return super.testFilter (attribName, filter);
        }
    }




    public Object getAttribute (String attribName)
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_LeftQuestionNo))
        {
            return HELPER_LeftQuestionNo.toObject (getLeftQuestionNo ());
        }
        else if (attribName.equals (FIELD_LeftQuestion))
        {
            return HELPER_LeftQuestion.toObject (getLeftQuestion ());
        }
        else if (attribName.equals (FIELD_RightQuestionNo))
        {
            return HELPER_RightQuestionNo.toObject (getRightQuestionNo ());
        }
        else if (attribName.equals (FIELD_RightQuestion))
        {
            return HELPER_RightQuestion.toObject (getRightQuestion ());
        }
        else
        {
            return super.getAttribute (attribName);
        }
    }


    public AttributeHelper getAttributeHelper (String attribName)
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_LeftQuestionNo))
        {
            return HELPER_LeftQuestionNo;
        }
        else if (attribName.equals (FIELD_LeftQuestion))
        {
            return HELPER_LeftQuestion;
        }
        else if (attribName.equals (FIELD_RightQuestionNo))
        {
            return HELPER_RightQuestionNo;
        }
        else if (attribName.equals (FIELD_RightQuestion))
        {
            return HELPER_RightQuestion;
        }
        else
        {
            return super.getAttributeHelper (attribName);
        }
    }


    public void setAttribute (String attribName, Object attribValue) throws FieldException
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_LeftQuestionNo))
        {
            setLeftQuestionNo ((Integer)(HELPER_LeftQuestionNo.fromObject (_LeftQuestionNo, attribValue)));            
        }
        else if (attribName.equals (FIELD_LeftQuestion))
        {
            setLeftQuestion ((String)(HELPER_LeftQuestion.fromObject (_LeftQuestion, attribValue)));            
        }
        else if (attribName.equals (FIELD_RightQuestionNo))
        {
            setRightQuestionNo ((Integer)(HELPER_RightQuestionNo.fromObject (_RightQuestionNo, attribValue)));            
        }
        else if (attribName.equals (FIELD_RightQuestion))
        {
            setRightQuestion ((String)(HELPER_RightQuestion.fromObject (_RightQuestion, attribValue)));            
        }
        else
        {
            super.setAttribute (attribName, attribValue);
        }
    }



    public boolean isWriteable (String fieldName)
    {
        return getWriteable (fieldName) == FieldWriteability.TRUE;
    }


    public FieldWriteability getWriteable (String fieldName)
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (fieldName.equals (FIELD_LeftQuestionNo))
        {
            return getWriteability_LeftQuestionNo ();
        }
        else if (fieldName.equals (FIELD_LeftQuestion))
        {
            return getWriteability_LeftQuestion ();
        }
        else if (fieldName.equals (FIELD_RightQuestionNo))
        {
            return getWriteability_RightQuestionNo ();
        }
        else if (fieldName.equals (FIELD_RightQuestion))
        {
            return getWriteability_RightQuestion ();
        }
        else
        {
            return super.getWriteable (fieldName);
        }
    }


    public void putUnwriteable (Set<String> fields)
    {
        
            if (getWriteability_LeftQuestionNo () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_LeftQuestionNo);
            }
        
            if (getWriteability_LeftQuestion () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_LeftQuestion);
            }
        
            if (getWriteability_RightQuestionNo () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_RightQuestionNo);
            }
        
            if (getWriteability_RightQuestion () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_RightQuestion);
            }
        

        super.putUnwriteable (fields);
    }

    public List<AbstractAttribute> getAttributes ()
    {
        List result = super.getAttributes ();

        
        result.add(HELPER_LeftQuestionNo.getAttribObject (getClass (), _LeftQuestionNo, false, FIELD_LeftQuestionNo));
        result.add(HELPER_LeftQuestion.getAttribObject (getClass (), _LeftQuestion, false, FIELD_LeftQuestion));
        result.add(HELPER_RightQuestionNo.getAttribObject (getClass (), _RightQuestionNo, false, FIELD_RightQuestionNo));
        result.add(HELPER_RightQuestion.getAttribObject (getClass (), _RightQuestion, false, FIELD_RightQuestion));

        return result;
    }


    public Map getAttributeMetadata (String attribute)
    {
        if (ATTRIBUTES_METADATA_Question.containsKey (attribute))
        {
            return (Map)ATTRIBUTES_METADATA_Question.get (attribute);
        }
        else
        {
            return super.getAttributeMetadata (attribute);
        }
    }


    public Object getAttributeMetadata (String attribute, String metadata)
    {
        if (ATTRIBUTES_METADATA_Question.containsKey (attribute))
        {
            return ((Map)ATTRIBUTES_METADATA_Question.get (attribute)).get(metadata);
        }
        else
        {
            return super.getAttributeMetadata (attribute, metadata);
        }
    }

    public void preCommit (boolean willBeStored) throws Exception
    {
        super.preCommit(willBeStored);
        
        if(willBeStored)
        {
        
        }
    }

    public oneit.servlets.objstore.binary.BinaryContentHandler getBinaryContentHandler(String attribName)
    {
        
        
        return super.getBinaryContentHandler(attribName);
    }

    public static class QuestionBehaviourDecorator extends BaseBusinessClass.BBCBehaviourDecorator<Question>
    {

    /**
     * Get the attribute LeftQuestionNo
     */
    public Integer getLeftQuestionNo (Question obj, Integer original)
    {
        return original;
    }

    /**
     * Change the value set for attribute LeftQuestionNo.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public Integer setLeftQuestionNo (Question obj, Integer newLeftQuestionNo) throws FieldException
    {
        return newLeftQuestionNo;
    }

    /**
     * Get the attribute LeftQuestion
     */
    public String getLeftQuestion (Question obj, String original)
    {
        return original;
    }

    /**
     * Change the value set for attribute LeftQuestion.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public String setLeftQuestion (Question obj, String newLeftQuestion) throws FieldException
    {
        return newLeftQuestion;
    }

    /**
     * Get the attribute RightQuestionNo
     */
    public Integer getRightQuestionNo (Question obj, Integer original)
    {
        return original;
    }

    /**
     * Change the value set for attribute RightQuestionNo.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public Integer setRightQuestionNo (Question obj, Integer newRightQuestionNo) throws FieldException
    {
        return newRightQuestionNo;
    }

    /**
     * Get the attribute RightQuestion
     */
    public String getRightQuestion (Question obj, String original)
    {
        return original;
    }

    /**
     * Change the value set for attribute RightQuestion.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public String setRightQuestion (Question obj, String newRightQuestion) throws FieldException
    {
        return newRightQuestion;
    }

    }

    
    public ORMPipeLine pipes()
    {
        return new QuestionPipeLineFactory<Question, Question> ((Question)this);
    }
      
    /**
     * Use this instead of pipes() to get rid of type casting.
     */  
    public QuestionPipeLineFactory<Question, Question> pipelineQuestion()
    {
        return (QuestionPipeLineFactory<Question, Question>) pipes();
    }
    
    public static QuestionPipeLineFactory<Question, Question> pipesQuestion(Collection<Question> items)
    {
        return REFERENCE_Question.new QuestionPipeLineFactory<Question, Question> (items);
    }
    
    public static QuestionPipeLineFactory<Question, Question> pipesQuestion(Question[] _items)
    {
        return pipesQuestion(Arrays.asList (_items));
    }
    
    public static QuestionPipeLineFactory<Question, Question> pipesQuestion()
    {
        return pipesQuestion((Collection)null);
    }
    
    
    public class QuestionPipeLineFactory<From extends BaseBusinessClass, Me extends Question> extends BaseBusinessClass.ORMPipeLine<From, Me>    
    {
        public <Prev> QuestionPipeLineFactory (PipeLine<From, Prev> pipeLine, Pipe<Prev, Me> nextPipe)
        {
            super (pipeLine, nextPipe);
        }
        
        public QuestionPipeLineFactory (From seed)
        {
            super(seed);
        }

        public QuestionPipeLineFactory (Collection<From> seed)
        {
            super(seed);
        }
        
        
        public PipeLine<From, ? extends Object> to(String name)
        {
            if (name.equals ("LeftQuestionNo"))
            {
                return toLeftQuestionNo ();
            }                
            if (name.equals ("LeftQuestion"))
            {
                return toLeftQuestion ();
            }                
            if (name.equals ("RightQuestionNo"))
            {
                return toRightQuestionNo ();
            }                
            if (name.equals ("RightQuestion"))
            {
                return toRightQuestion ();
            }                
            
            
            return super.to(name);
        }
        
        
        public PipeLine<From, Integer> toLeftQuestionNo () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_LeftQuestionNo));  }
        
        public PipeLine<From, String> toLeftQuestion () { return pipe(new ORMAttributePipe<Me, String>(FIELD_LeftQuestion));  }
        
        public PipeLine<From, Integer> toRightQuestionNo () { return pipe(new ORMAttributePipe<Me, Integer>(FIELD_RightQuestionNo));  }
        
        public PipeLine<From, String> toRightQuestion () { return pipe(new ORMAttributePipe<Me, String>(FIELD_RightQuestion));  }
        
    }
    
    public boolean isTransientAttrib(String attribName)
    {
        

        return super.isTransientAttrib(attribName);
    }

    public boolean isTransientSingleReference(String assocName)
    {
        

        return super.isTransientSingleReference(assocName);
    }
}

class DummyQuestion extends Question
{
    // Default constructor primarily to support Externalisable
    public DummyQuestion()
    {
        super();
    }

    public void assertValid ()
    {
    }


}

    
