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