FieldType.java :  » Database-ORM » Ammentos » it » biobytes » ammentos » Java Open Source

Java Open Source » Database ORM » Ammentos 
Ammentos » it » biobytes » ammentos » FieldType.java
/*
 *   Copyright 2006 Davide Deidda
 *
 *  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.
 */

/*
 * DataType.java
 *
 * Created on 29 novembre 2003, 12.24
 */

package it.biobytes.ammentos;

import java.sql.*;

/**
 * Describes a valid type of data for a Field
 * @author  davide
 */
public interface FieldType
{
  public void setParamValue( Object fieldValue, PreparedStatement pstmt, int paramIndex ) 
    throws SQLException;
  
  public Object loadValue( java.sql.ResultSet rs, Field field )
    throws SQLException;
  
  public Object parseValue( String str )
    throws PersistenceException;
  
  public String formatValue( Object value );
  
  public Object generateValue() throws PersistenceException;
  
  public boolean isNumeric();
  
  public Object[] getPossibleValues();
  
  /**
   * Gets the underlying mapped Java class represented from elements of this
   * type
   *
   * @return the Java class mapped from this FieldType
   */
  public Class getMappedClass();
  
  /**
   * Returns the SQL type (as enumerated in java.sql.Types) of this field type.
   * @see java.sql.Types
   */
  public int getSqlType();
  
  /**
   * Returns the sum of the provided values, or null if summing is not possible
   *
   * @param value1  First value to add
   * @param value2  Second value to add
   */
  public Object addValues( Object value1, Object value2 );
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.