/*! ****************************************************************************** * * Pentaho Data Integration * * Copyright (C) 2002-2016 by Pentaho : http://www.pentaho.com * ******************************************************************************* * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ******************************************************************************/ package org.pentaho.di.trans.steps.accessinput; import org.pentaho.di.core.row.ValueMetaInterface; import org.pentaho.di.core.row.value.ValueMetaFactory; import org.pentaho.di.i18n.BaseMessages; /** * Describes an AccessInput field * * @author Samatar Hassan * @since 24-05-2007 */ public class AccessInputField implements Cloneable { private static Class<?> PKG = AccessInputField.class; // for i18n purposes, needed by Translator2!! public static final int TYPE_TRIM_NONE = 0; public static final int TYPE_TRIM_LEFT = 1; public static final int TYPE_TRIM_RIGHT = 2; public static final int TYPE_TRIM_BOTH = 3; public static final String[] trimTypeCode = { "none", "left", "right", "both" }; public static final String[] trimTypeDesc = { BaseMessages.getString( PKG, "AccessInputField.TrimType.None" ), BaseMessages.getString( PKG, "AccessInputField.TrimType.Left" ), BaseMessages.getString( PKG, "AccessInputField.TrimType.Right" ), BaseMessages.getString( PKG, "AccessInputField.TrimType.Both" ) }; private String name; private String Column; private int type; private int length; private String format; private int trimtype; private int precision; private String currencySymbol; private String decimalSymbol; private String groupSymbol; private boolean repeat; private String[] samples; public AccessInputField( String fieldname ) { this.name = fieldname; this.Column = ""; this.length = -1; this.type = ValueMetaInterface.TYPE_STRING; this.format = ""; this.trimtype = TYPE_TRIM_NONE; this.groupSymbol = ""; this.decimalSymbol = ""; this.currencySymbol = ""; this.precision = -1; this.repeat = false; } public AccessInputField() { this( null ); } public static final int getTrimTypeByCode( String tt ) { if ( tt == null ) { return 0; } for ( int i = 0; i < trimTypeCode.length; i++ ) { if ( trimTypeCode[i].equalsIgnoreCase( tt ) ) { return i; } } return 0; } public static final int getTrimTypeByDesc( String tt ) { if ( tt == null ) { return 0; } for ( int i = 0; i < trimTypeDesc.length; i++ ) { if ( trimTypeDesc[i].equalsIgnoreCase( tt ) ) { return i; } } return 0; } public static final String getTrimTypeCode( int i ) { if ( i < 0 || i >= trimTypeCode.length ) { return trimTypeCode[0]; } return trimTypeCode[i]; } public static final String getTrimTypeDesc( int i ) { if ( i < 0 || i >= trimTypeDesc.length ) { return trimTypeDesc[0]; } return trimTypeDesc[i]; } @Override public Object clone() { try { AccessInputField retval = (AccessInputField) super.clone(); return retval; } catch ( CloneNotSupportedException e ) { return null; } } public int getLength() { return length; } public void setLength( int length ) { this.length = length; } public String getName() { return name; } public String getColumn() { return Column; } public void setColumn( String fieldcolumn ) { this.Column = fieldcolumn; } public void setName( String fieldname ) { this.name = fieldname; } public int getType() { return type; } public String getTypeDesc() { return ValueMetaFactory.getValueMetaName( type ); } public void setType( int type ) { this.type = type; } public String getFormat() { return format; } public void setFormat( String format ) { this.format = format; } public void setSamples( String[] samples ) { this.samples = samples; } public String[] getSamples() { return samples; } public int getTrimType() { return trimtype; } public String getTrimTypeCode() { return getTrimTypeCode( trimtype ); } public String getTrimTypeDesc() { return getTrimTypeDesc( trimtype ); } public void setTrimType( int trimtype ) { this.trimtype = trimtype; } public String getGroupSymbol() { return groupSymbol; } public void setGroupSymbol( String group_symbol ) { this.groupSymbol = group_symbol; } public String getDecimalSymbol() { return decimalSymbol; } public void setDecimalSymbol( String decimal_symbol ) { this.decimalSymbol = decimal_symbol; } public String getCurrencySymbol() { return currencySymbol; } public void setCurrencySymbol( String currency_symbol ) { this.currencySymbol = currency_symbol; } public int getPrecision() { return precision; } public void setPrecision( int precision ) { this.precision = precision; } public boolean isRepeated() { return repeat; } public void setRepeated( boolean repeat ) { this.repeat = repeat; } public void flipRepeated() { repeat = !repeat; } }