Last change
on this file since 5800 was 5798, checked in by cs025, 21 years ago |
Adding gs3build code
|
-
Property svn:keywords
set to
Author Date Id Revision
|
File size:
1.5 KB
|
Line | |
---|
1 | package org.greenstone.gsdl3.gs3build.database;
|
---|
2 |
|
---|
3 | public class GS3SQLField
|
---|
4 | { String name;
|
---|
5 | int length;
|
---|
6 | String type;
|
---|
7 |
|
---|
8 | public final static String VARCHAR_TYPE = "VARCHAR";
|
---|
9 | public final static String INTEGER_TYPE = "INTEGER";
|
---|
10 | public final static String AUTOINTEGER_TYPE = "AUTOINTEGER";
|
---|
11 |
|
---|
12 | public GS3SQLField(String name)
|
---|
13 | { this.name = name;
|
---|
14 | this.length = 1024;
|
---|
15 | this.type = VARCHAR_TYPE;
|
---|
16 | }
|
---|
17 |
|
---|
18 | public GS3SQLField(String name, int length)
|
---|
19 | { this.name = name;
|
---|
20 | this.length = length;
|
---|
21 | this.type = VARCHAR_TYPE;
|
---|
22 | }
|
---|
23 |
|
---|
24 | public GS3SQLField(String name, String type)
|
---|
25 | { this.name = name;
|
---|
26 | this.type = type;
|
---|
27 | this.length = 1024;
|
---|
28 | }
|
---|
29 |
|
---|
30 | public GS3SQLField(String name, String type, int length)
|
---|
31 | { this.name = name;
|
---|
32 | this.length = length;
|
---|
33 | this.type = type;
|
---|
34 | }
|
---|
35 |
|
---|
36 | public String getName()
|
---|
37 | { return this.name;
|
---|
38 | }
|
---|
39 |
|
---|
40 | public int getLength()
|
---|
41 | { return this.length;
|
---|
42 | }
|
---|
43 |
|
---|
44 | public String toString()
|
---|
45 | { StringBuffer reply = new StringBuffer();
|
---|
46 |
|
---|
47 | reply.append(this.name);
|
---|
48 | reply.append(" ");
|
---|
49 | if (this.type.equals(VARCHAR_TYPE))
|
---|
50 | {
|
---|
51 | if (length > 255) {
|
---|
52 | reply.append("TINYTEXT");
|
---|
53 | }
|
---|
54 | else {
|
---|
55 | reply.append("VARCHAR(");
|
---|
56 | reply.append(Integer.toString(this.length));
|
---|
57 | reply.append(")");
|
---|
58 | }
|
---|
59 | }
|
---|
60 | else if (this.type.equals(AUTOINTEGER_TYPE))
|
---|
61 | { reply.append("INTEGER AUTO_INCREMENT");
|
---|
62 | }
|
---|
63 | else
|
---|
64 | {
|
---|
65 | reply.append(this.type);
|
---|
66 | }
|
---|
67 | return reply.toString();
|
---|
68 | }
|
---|
69 |
|
---|
70 | }
|
---|
71 |
|
---|
72 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.