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