KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xquark > extractor > sql > SqlTable


1 /*
2  * This file belongs to the XQuark distribution.
3  * Copyright (C) 2003 Universite de Versailles Saint-Quentin.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307.
18  * You can also get it at http://www.gnu.org/licenses/lgpl.html
19  *
20  * For more information on this software, see http://www.xquark.org.
21  */

22
23 package org.xquark.extractor.sql;
24
25
26 public class SqlTable extends SqlExpression
27 {
28
29     private static final String JavaDoc RCSRevision = "$Revision: 1.4 $";
30     private static final String JavaDoc RCSName = "$Name: $";
31
32
33     protected String JavaDoc _catalogName = null;
34     protected String JavaDoc _schemaName = null;
35     protected String JavaDoc _name = null;;
36
37
38     /**
39     @roseuid 3BD17801037E
40      */

41     public SqlTable()
42     {
43
44     }
45
46     /**
47     @param name
48     @roseuid 3BD1780103B0
49      */

50     public SqlTable(String JavaDoc name)
51     {
52         setName ( name ) ;
53     }
54
55     public SqlTable(String JavaDoc catalogName, String JavaDoc schemaName, String JavaDoc tableName)
56     {
57         setCatalogName(catalogName);
58         setSchemaName(schemaName);
59         setName(tableName);
60     }
61
62     public void setSchemaName(String JavaDoc schemaName) {
63         _schemaName = schemaName;
64     }
65
66     public String JavaDoc getSchemaName()
67     {
68         return _schemaName;
69     }
70
71
72     public void setCatalogName(String JavaDoc catalogName) {
73         _catalogName = catalogName;
74     }
75
76     public String JavaDoc getCatalogName()
77     {
78         return _catalogName;
79     }
80
81     /**
82     Access method for the _name property.
83     @return the current value of the _name property
84     @roseuid 3BD17802004A
85      */

86     public String JavaDoc getName()
87     {
88       return _name;
89     }
90
91     /**
92     Sets the value of the _name property.
93     @param aName the new value of the _name property
94     @roseuid 3BD178020086
95      */

96     public void setName(String JavaDoc aName)
97     {
98       //name = aName;
99
_name = aName;
100     }
101
102     public String JavaDoc toSql(Context context) {
103         return toSql(context,true);
104     }
105     
106     public String JavaDoc toSql(Context context, boolean putQuotes)
107     {
108         StringBuffer JavaDoc retVal = new StringBuffer JavaDoc();
109
110         String JavaDoc step = null;
111         step = getCatalogName();
112         if (null != step) {
113             if (putQuotes) retVal.append('"');
114             retVal.append(step);
115             if (putQuotes) retVal.append('"');
116             retVal.append('.');
117         }
118
119         step = getSchemaName();
120         if (null != step) {
121             if (putQuotes) retVal.append('"');
122             retVal.append(step);
123             if (putQuotes) retVal.append('"');
124             retVal.append('.');
125         }
126
127         step = getName();
128         if (putQuotes) retVal.append('"');
129         retVal.append(step);
130         if (putQuotes) retVal.append('"');
131
132         return retVal.toString();
133     }
134 }
135
Popular Tags