package com.j256.ormlite.stmt;

import com.j256.ormlite.field.FieldType;
import com.j256.ormlite.field.SqlType;
import java.sql.SQLException;

public abstract class BaseArgumentHolder
  implements ArgumentHolder
{
  private String columnName = null;
  private FieldType fieldType = null;
  private SqlType sqlType = null;

  public BaseArgumentHolder()
  {
  }

  public BaseArgumentHolder(SqlType paramSqlType)
  {
    this.sqlType = paramSqlType;
  }

  public BaseArgumentHolder(String paramString)
  {
    this.columnName = paramString;
  }

  public String getColumnName()
  {
    return this.columnName;
  }

  public FieldType getFieldType()
  {
    return this.fieldType;
  }

  public Object getSqlArgValue()
  {
    if (!isValueSet())
      throw new SQLException("Column value has not been set for " + this.columnName);
    Object localObject = getValue();
    if (localObject == null)
      return null;
    if (this.fieldType == null)
      return localObject;
    if ((this.fieldType.isForeign()) && (this.fieldType.getType() == localObject.getClass()))
      return this.fieldType.getForeignIdField().extractJavaFieldValue(localObject);
    return this.fieldType.convertJavaFieldToSqlArgValue(localObject);
  }

  public SqlType getSqlType()
  {
    return this.sqlType;
  }

  protected abstract Object getValue();

  protected abstract boolean isValueSet();

  public void setMetaInfo(FieldType paramFieldType)
  {
    if ((this.fieldType != null) && (this.fieldType != paramFieldType))
      throw new IllegalArgumentException("FieldType name cannot be set twice from " + this.fieldType + " to " + paramFieldType + ".  Using a SelectArg twice in query with different columns?");
    this.fieldType = paramFieldType;
  }

  public void setMetaInfo(String paramString)
  {
    if ((this.columnName != null) && (!this.columnName.equals(paramString)))
      throw new IllegalArgumentException("Column name cannot be set twice from " + this.columnName + " to " + paramString + ".  Using a SelectArg twice in query with different columns?");
    this.columnName = paramString;
  }

  public void setMetaInfo(String paramString, FieldType paramFieldType)
  {
    setMetaInfo(paramString);
    setMetaInfo(paramFieldType);
  }

  public abstract void setValue(Object paramObject);

  public String toString()
  {
    if (!isValueSet())
      return "[unset]";
    try
    {
      Object localObject = getSqlArgValue();
      if (localObject == null)
        return "[null]";
      String str = localObject.toString();
      return str;
    }
    catch (SQLException localSQLException)
    {
      return "[could not get value: " + localSQLException + "]";
    }
  }
}

/* Location:           /Users/vikas/Documents/Mhacks_Real_app/classes-dex2jar.jar
 * Qualified Name:     com.j256.ormlite.stmt.BaseArgumentHolder
 * JD-Core Version:    0.6.2
 */