001/* 002 * HA-JDBC: High-Availability JDBC 003 * Copyright (C) 2012 Paul Ferraro 004 * 005 * This program is free software: you can redistribute it and/or modify 006 * it under the terms of the GNU Lesser General Public License as published by 007 * the Free Software Foundation, either version 3 of the License, or 008 * (at your option) any later version. 009 * 010 * This program is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 013 * GNU Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public License 016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 017 */ 018package net.sf.hajdbc.dialect; 019 020import net.sf.hajdbc.AbstractNamed; 021import net.sf.hajdbc.ColumnProperties; 022import net.sf.hajdbc.ColumnPropertiesFactory; 023import net.sf.hajdbc.IdentifierNormalizer; 024 025public class StandardColumnPropertiesFactory implements ColumnPropertiesFactory 026{ 027 private final IdentifierNormalizer normalizer; 028 029 public StandardColumnPropertiesFactory(IdentifierNormalizer normalizer) 030 { 031 this.normalizer = normalizer; 032 } 033 034 @Override 035 public ColumnProperties createColumnProperties(String name, int type, String nativeType, String defaultValue, final String remarks, final Boolean autoIncrement) 036 { 037 return new StandardColumnProperties(this.normalizer.normalize(name), type, nativeType, autoIncrement); 038 } 039 040 private static class StandardColumnProperties extends AbstractNamed<String, ColumnProperties> implements ColumnProperties 041 { 042 private final int type; 043 private final String nativeType; 044 private final boolean autoIncrement; 045 046 StandardColumnProperties(String name, int type, String nativeType, boolean autoIncrement) 047 { 048 super(name); 049 this.type = type; 050 this.nativeType = nativeType; 051 this.autoIncrement = autoIncrement; 052 } 053 054 @Override 055 public int getType() 056 { 057 return this.type; 058 } 059 060 @Override 061 public String getNativeType() 062 { 063 return this.nativeType; 064 } 065 066 @Override 067 public boolean isAutoIncrement() 068 { 069 return this.autoIncrement; 070 } 071 } 072}