01: /*
02: * Copyright 2004-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.apache.lucene.store.jdbc.support;
18:
19: import org.apache.lucene.store.jdbc.dialect.Dialect;
20:
21: /**
22: * An internal representation of a database column used to store the {@link org.apache.lucene.store.jdbc.JdbcDirectory}
23: * settings.
24: *
25: * @author kimchy
26: */
27: public class JdbcColumn {
28:
29: private Dialect dialect;
30:
31: private String name;
32:
33: private int index;
34:
35: private String type;
36:
37: private boolean quoted = false;
38:
39: public JdbcColumn(Dialect dialect, String name, int index,
40: String type) {
41: this .dialect = dialect;
42: setName(name);
43: this .index = index;
44: this .type = type;
45: }
46:
47: public String getName() {
48: return this .name;
49: }
50:
51: public int getIndex() {
52: return this .index;
53: }
54:
55: public String getType() {
56: return this .type;
57: }
58:
59: public void setName(String name) {
60: if (name.charAt(0) == dialect.openQuote()) {
61: quoted = true;
62: this .name = name.substring(1, name.length() - 1);
63: } else {
64: this .name = name;
65: }
66: }
67:
68: public String getQuotedName() {
69: return quoted ? dialect.openQuote() + name
70: + dialect.closeQuote() : name;
71: }
72: }
|