KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > webdocwf > util > loader > QueryConstantSet


1
2 /*
3 LoaderGenerator - tool for generated xml, sql and doml file needed for Octopus.
4
5
6     Copyright (C) 2003 Together
7
8     This library is free software; you can redistribute it and/or
9     modify it under the terms of the GNU Lesser General Public
10     License as published by the Free Software Foundation; either
11     version 2.1 of the License, or (at your option) any later version.
12
13     This library is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16     Lesser General Public License for more details.
17
18     You should have received a copy of the GNU Lesser General Public
19     License along with this library; if not, write to the Free Software
20     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */

22
23 package org.webdocwf.util.loader;
24
25 import java.util.*;
26 import java.sql.*;
27
28 /**
29  *
30  * QueryConstantSet class sets the query statement for constant columns
31  * @author unascribed
32  * @version 1.0
33  */

34 public class QueryConstantSet {
35
36   private String JavaDoc strQueryConstant=null;
37   private Vector indexDummyOverwrite=new Vector();
38   private Vector indexDummyNull=new Vector();
39
40   /**
41    * Construct object QueryConstantSet class with associated parameters
42    * @param tableName current table name
43    * @param vecConstantColumns vector of constant column names
44    * @param vecConstantMode vector of constant column modes
45    * @param vecConstantType vector of constant column types
46    */

47   public QueryConstantSet(String JavaDoc tableName,Vector vecConstantColumns,
48                           Vector vecConstantMode, Vector vecConstantType, ConfigReader configReaderTarget) throws LoaderException{
49
50     strQueryConstant="update "+ tableName+ " set ";
51     for(int i=0;i<vecConstantColumns.size();i++){
52       if(vecConstantMode.get(i).toString().equalsIgnoreCase("Overwrite")){
53 //ZK change this 7.5 2004 from CheckType to configReaderTarget
54
try {
55             if(!configReaderTarget.isNumber(vecConstantType.get(i).toString())){
56               strQueryConstant += vecConstantColumns.get(i).toString()
57                         + " = " + "'dummyConstantOver'"+", ";
58             }else{
59               strQueryConstant += vecConstantColumns.get(i).toString()
60                         + " = " + "dummyConstantOver"+", ";
61             }
62         } catch (LoaderException e) {
63            LoaderException le = new LoaderException("Exception:Type not present in conf file for target database, add it into conf file.",(Throwable JavaDoc)e);
64            throw le;
65         }
66         indexDummyOverwrite.add(String.valueOf(i));
67       }else if(vecConstantMode.get(i).toString().equalsIgnoreCase("Update")||
68                vecConstantMode.get(i).toString().equalsIgnoreCase("SetNull")){
69 //ZK change this 7.5 2004 from CheckType to configReaderTarget
70
try {
71             if(!configReaderTarget.isNumber(vecConstantType.get(i).toString())){
72               strQueryConstant += vecConstantColumns.get(i).toString()
73                         + " = " + "'dummyConstantNull'"+", ";
74             }else{
75               strQueryConstant += vecConstantColumns.get(i).toString()
76                         + " = " + "dummyConstantNull"+", ";
77             }
78         } catch (LoaderException e) {
79                     LoaderException le = new LoaderException("Exception:Type not present in conf file for target database, add it into conf file.",(Throwable JavaDoc)e);
80                     throw le;
81         }
82         indexDummyNull.add(String.valueOf(i));
83       }
84     }
85   }
86
87   /**
88    * This method read value of strQueryConstant parameter
89    * @return value of parameter
90    */

91   public String JavaDoc getQueryConstant(){
92     return strQueryConstant;
93   }
94
95   /**
96    * This method read value from indexDummyOverwrite parameter
97    * @return value of parameter
98    */

99   public Vector getIndexDummyOverwrite(){
100     return indexDummyOverwrite;
101   }
102
103   /**
104    * This method read value from indexDummyNull parameter
105    * @return value of parameter
106    */

107   public Vector getIndexDummyNull(){
108       return indexDummyNull;
109   }
110
111
112
113
114 }
Popular Tags