xref: /AOO41X/test/testuno/source/testlib/uno/HsqlColumnDescriptor.java (revision e6e6073ddaad3a04a985e8f05823629a884eb203)
1*e6e6073dSLiu Zhe /**************************************************************
2*e6e6073dSLiu Zhe  *
3*e6e6073dSLiu Zhe  * Licensed to the Apache Software Foundation (ASF) under one
4*e6e6073dSLiu Zhe  * or more contributor license agreements.  See the NOTICE file
5*e6e6073dSLiu Zhe  * distributed with this work for additional information
6*e6e6073dSLiu Zhe  * regarding copyright ownership.  The ASF licenses this file
7*e6e6073dSLiu Zhe  * to you under the Apache License, Version 2.0 (the
8*e6e6073dSLiu Zhe  * "License"); you may not use this file except in compliance
9*e6e6073dSLiu Zhe  * with the License.  You may obtain a copy of the License at
10*e6e6073dSLiu Zhe  *
11*e6e6073dSLiu Zhe  *   http://www.apache.org/licenses/LICENSE-2.0
12*e6e6073dSLiu Zhe  *
13*e6e6073dSLiu Zhe  * Unless required by applicable law or agreed to in writing,
14*e6e6073dSLiu Zhe  * software distributed under the License is distributed on an
15*e6e6073dSLiu Zhe  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*e6e6073dSLiu Zhe  * KIND, either express or implied.  See the License for the
17*e6e6073dSLiu Zhe  * specific language governing permissions and limitations
18*e6e6073dSLiu Zhe  * under the License.
19*e6e6073dSLiu Zhe  *
20*e6e6073dSLiu Zhe  *************************************************************/
21*e6e6073dSLiu Zhe 
22*e6e6073dSLiu Zhe 
23*e6e6073dSLiu Zhe 
24*e6e6073dSLiu Zhe package testlib.uno;
25*e6e6073dSLiu Zhe 
26*e6e6073dSLiu Zhe /** is a very simply and rudimentary descriptor of table columns, for creating HSQLDB tables
27*e6e6073dSLiu Zhe  */
28*e6e6073dSLiu Zhe public class HsqlColumnDescriptor
29*e6e6073dSLiu Zhe {
30*e6e6073dSLiu Zhe     private String Name;
31*e6e6073dSLiu Zhe     private String TypeName;
32*e6e6073dSLiu Zhe     private boolean Required;
33*e6e6073dSLiu Zhe     private boolean PrimaryKey;
34*e6e6073dSLiu Zhe     private String ForeignTable;
35*e6e6073dSLiu Zhe     private String ForeignColumn;
36*e6e6073dSLiu Zhe 
getName()37*e6e6073dSLiu Zhe     public final String getName() { return Name; }
getTypeName()38*e6e6073dSLiu Zhe     public final String getTypeName() { return TypeName; }
isRequired()39*e6e6073dSLiu Zhe     public final boolean isRequired() { return Required; }
isPrimaryKey()40*e6e6073dSLiu Zhe     public final boolean isPrimaryKey() { return PrimaryKey; }
41*e6e6073dSLiu Zhe 
isForeignKey()42*e6e6073dSLiu Zhe     public final boolean isForeignKey() { return ( ForeignTable.length() != 0 ) && ( ForeignColumn.length() != 0 ); }
getForeignTable()43*e6e6073dSLiu Zhe     public final String getForeignTable() { return ForeignTable; }
getForeignColumn()44*e6e6073dSLiu Zhe     public final String getForeignColumn() { return ForeignColumn; }
45*e6e6073dSLiu Zhe 
46*e6e6073dSLiu Zhe     /// determines that a column is required, i.e. not nullable
47*e6e6073dSLiu Zhe     public final static int REQUIRED    = 1;
48*e6e6073dSLiu Zhe     /// determines that a column is part of the primary key of its table
49*e6e6073dSLiu Zhe     public final static int PRIMARY     = 2;
50*e6e6073dSLiu Zhe 
HsqlColumnDescriptor( String _Name, String _TypeName )51*e6e6073dSLiu Zhe     public HsqlColumnDescriptor( String _Name, String _TypeName )
52*e6e6073dSLiu Zhe     {
53*e6e6073dSLiu Zhe         Name = _Name;
54*e6e6073dSLiu Zhe         TypeName = _TypeName;
55*e6e6073dSLiu Zhe         Required = false;
56*e6e6073dSLiu Zhe         PrimaryKey = false;
57*e6e6073dSLiu Zhe         ForeignTable = "";
58*e6e6073dSLiu Zhe         ForeignColumn = "";
59*e6e6073dSLiu Zhe     }
60*e6e6073dSLiu Zhe 
HsqlColumnDescriptor( String _Name, String _TypeName, int _Flags )61*e6e6073dSLiu Zhe     public HsqlColumnDescriptor( String _Name, String _TypeName, int _Flags )
62*e6e6073dSLiu Zhe     {
63*e6e6073dSLiu Zhe         Name = _Name;
64*e6e6073dSLiu Zhe         TypeName = _TypeName;
65*e6e6073dSLiu Zhe         Required = ( _Flags & REQUIRED ) != 0;
66*e6e6073dSLiu Zhe         PrimaryKey = ( _Flags & PRIMARY ) != 0;
67*e6e6073dSLiu Zhe         ForeignTable = "";
68*e6e6073dSLiu Zhe         ForeignColumn = "";
69*e6e6073dSLiu Zhe     }
70*e6e6073dSLiu Zhe 
HsqlColumnDescriptor( String _Name, String _TypeName, int _Flags, String _ForeignTable, String _ForeignColumn )71*e6e6073dSLiu Zhe     public HsqlColumnDescriptor( String _Name, String _TypeName, int _Flags, String _ForeignTable, String _ForeignColumn )
72*e6e6073dSLiu Zhe     {
73*e6e6073dSLiu Zhe         Name = _Name;
74*e6e6073dSLiu Zhe         TypeName = _TypeName;
75*e6e6073dSLiu Zhe         Required = ( _Flags & REQUIRED ) != 0;
76*e6e6073dSLiu Zhe         PrimaryKey = ( _Flags & PRIMARY ) != 0;
77*e6e6073dSLiu Zhe         ForeignTable = _ForeignTable;
78*e6e6073dSLiu Zhe         ForeignColumn = _ForeignColumn;
79*e6e6073dSLiu Zhe     }
80*e6e6073dSLiu Zhe };
81