KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > daffodilwoods > daffodildb > server > serversystem > dmlvalidation > constraintsystem > ForeignConstraintException


1 package com.daffodilwoods.daffodildb.server.serversystem.dmlvalidation.constraintsystem;
2
3 import com.daffodilwoods.database.general.*;
4 import com.daffodilwoods.database.resource.*;
5
6 /**
7  *
8  * <p>Title: ForeignConstraintException</p>
9 ** <p>Description: Foreign constraint Exception has a super class DException, which helps in
10  * throwing a exception corresponding to sqlCode and the paramaters passed.</p>
11  *
12  */

13
14 public class ForeignConstraintException extends DException{
15    private DException prevException;
16    QualifiedIdentifier referencedTable , referencingTable ;
17    int[] columns ;
18    boolean referencing = false ;
19    String JavaDoc constraintName;
20
21    /**
22     * constructs an instance of foreign constraint exception with the given arguments.
23     * @param sqlCode code of exception in the sql statement.
24     * @param parameters parameters passed to the exception
25     * @param temp previous exception
26     */

27    public ForeignConstraintException(String JavaDoc sqlCode, Object JavaDoc[] parameters, DException temp) {
28       super(sqlCode, parameters);
29       this.prevException = temp;
30    }
31
32    /**
33     * returns Previous Exception if it is not null
34     * @return DException
35     */

36
37    public DException getPreviousException(){
38         return (prevException==null) ? null : prevException;
39    }
40
41
42    /**
43     * set boolean values for referencing i.e true if the column is a referencing one.
44     * @param val boolean value that is passed to the method.
45     */

46
47    public void setForeignExceptionBoolean(boolean val ) {
48         referencing = val;
49    }
50
51    /**
52     * set the values for the referencing table, referenced table and the columns.
53     * @param referencingTab name of the referncing table.
54     * @param referencedTab name of the referenced table.
55     * @param col columns on which the foreign constraint are applied.
56     */

57
58    public void setForeignKeyValues( QualifiedIdentifier referencingTab , QualifiedIdentifier referencedTab , int[] col ) {
59         referencingTable = referencingTab ;
60         referencedTable = referencedTab ;
61         columns = col ;
62    }
63
64
65    /**
66     * returns boolean determining whether the value is referncin or not.
67     * @return true if the column or table is the referencing one.
68     */

69
70    public boolean isErrorReferencing() {
71         return referencing ;
72    }
73
74    /**
75     * returns an array of Object containing referencing table, referenced table and the columns.
76     * @return Object[] array returned by the method.
77     */

78
79    public Object JavaDoc[] getForeignExceptionValues() {
80         return new Object JavaDoc[] { referencingTable , referencedTable , columns };
81    }
82
83    public ForeignConstraintException(String JavaDoc sqlcode, Object JavaDoc[] parameters) {
84       super( sqlcode, parameters );
85    }
86    public void setConstraintName( String JavaDoc csName ){
87      constraintName = csName;
88    }
89
90    public String JavaDoc getConstraintName( ){
91      return constraintName;
92    }
93
94 }
95
Popular Tags