View Javadoc
1 /* 2 * PROJECT : DAR Runtime and Tools 3 * COPYRIGHT : Copyright (C) 1999-2004 tim.stephenson@enableit.org 4 * LICENSE : GNU LESSER GENERAL PUBLIC LICENSE 5 * Version 2.1, February 1999 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 */ 21 package org.enableit.db.beans; 22 23 24 // Java imports 25 import java.util.ArrayList; 26 import java.util.List; 27 28 import org.apache.log4j.Logger; 29 30 31 /*** 32 * Extension or Helper class for <code>Table</code>. 33 * @author Tim Stephenson 34 */ 35 public class TableExt { 36 /* 37 * Properties 38 */ 39 40 /*** 41 * The Log4J <code>Logger</code> doing the logging. 42 */ 43 private static Logger logger = Logger.getLogger(TableExt.class); 44 45 /*** 46 * CVS info ABOUT this class and its current version 47 */ 48 public static final String ABOUT = "$Revision: 1.4 $"; 49 50 /* 51 * Constructors 52 */ 53 54 /*** 55 * Private constructor to ensure not instantiated. 56 */ 57 private TableExt() { 58 } 59 60 /* 61 * Methods 62 */ 63 64 /*** 65 * 66 */ 67 public static int getAutoIncrementCount(Table table) { 68 logger.info("METHOD_ENTRY: getAutoIncrementCount"); 69 70 int autoIncCount = 0; 71 72 for (int i = 0; i < table.getColumnCount(); i++) { 73 if ("autoincrement".equals(table.getColumn(i).getDefault())) { 74 autoIncCount++; 75 } 76 } 77 78 logger.info("METHOD_EXIT: getAutoIncrementCount, autoIncCount=" 79 + autoIncCount); 80 81 return autoIncCount; 82 } 83 84 public static List getPrimaryKeyList(Table table) { 85 List pkList = new ArrayList(); 86 87 for (int i = 0; i < table.getColumnCount(); i++) { 88 Column column = table.getColumn(i); 89 90 if ("true".equalsIgnoreCase(column.getPrimaryKey())) { 91 pkList.add(column); 92 } 93 } 94 95 return pkList; 96 } 97 }

This page was automatically generated by Maven