【Java开源代码栏目提醒】:网学会员在Java开源代码频道为大家收集整理了Type.java提供大家参考,希望对大家有所帮助!
//$Id: Type.java 7793 2005-08-10 05:06:40Z oneovthafew $
package org.hibernate.type;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Map;
import org.dom4j.Node;
import org.hibernate.EntityMode;
import org.hibernate.HibernateException;
import org.hibernate.MappingException;
import org.hibernate.engine.Mapping;
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.engine.SessionImplementor;
/**
* Defines a mapping from a Java type to an JDBC datatype. This interface is intended to
* be implemented by applications that need custom types.<br>
* <br>
* Implementors should usually be immutable and <b>must</b> certainly be threadsafe.
*
* @author Gavin King
*/
public interface Type extends Serializable {
/**
* Return true if the implementation is castable to
* <tt>AssociationType</tt>. This does not necessarily imply that
* the type actually represents an association.
* @see AssociationType
* @return boolean
*/
public boolean isAssociationType();
/**
* Is this type a collection type.
*/
public boolean isCollectionType();
/**
* Is this type a component type. If so, the implementation
* must be castable to <tt>AbstractComponentType</tt>. A component
* type may own collections or associations and hence must provide
* certain extra functionality.
* @see AbstractComponentType
* @return boolean
*/
public boolean isComponentType();
/**
* Is this type an entity type?
* @return boolean
*/
public boolean isEntityType();
/**
* Is this an "any" type.
*
* i.e. a reference to a persistent entity
* that is not modelled as a (foreign key) association.
*/
public boolean isAnyType();
public boolean isXMLElement();
/**
* Return the SQL type codes for the columns mapped by this type. The codes
* are defined on <tt>java.
sql.Types</tt>.
* @see java.sql.Types
* @return the typecodes
* @throws MappingException
*/
public int[] sqlTypes(Mapping mapping) throws MappingException;
/**
* How many columns are used to persist this type.
*/
public int getColumnSpan(Mapping mapping) throws MappingException;
/**
* The class returned by <tt>nullSafeGet()</tt> methods. This is used to
* establish the class of an array of this type.
*
* @return Class
*/
public Class getReturnedClass();
/**
* Compare two instances of the class mapped by this type for persistence
* "equality" - equality of persistent state - taking a shortcut for
* entity references.
* @param x
* @param y
* @param entityMode
*
* @return boolean
* @throws HibernateException
*/
public boolean isSame(Object x, Object y, EntityMode entityMode) throws HibernateException;
/**
* Compare two instances of the class mapped by this type for persistence
* "equality" - equality of persistent state.
* @param x
* @param y
* @param entityMode
*
* @return boolean
* @throws HibernateException
*/
public boolean isEqual(Object x, Object y, EntityMode entityMode) throws HibernateException;
/**
* Compare two instances of the class mapped by this type for persistence
* "equality" - equality of persistent state.
* @param x
* @param y
* @param entityMode
*
* @return boolean
* @throws HibernateException
*/
public boolean isEqual(Object x, Object y, EntityMode entityMode, SessionFactoryImplementor factory)
throws HibernateException;
/**
* Get a hashcode, consistent with persistence "equality"
* @param x
* @param entityMode
*/
public int getHashCode(Object x, EntityMode entityMode) throws HibernateException;
/**
* Get a hashcode, consistent with persistence "equality"
* @param x
* @param entityMode
* @param factory
*/
public int getHashCode(Object x, EntityMode entityMode, SessionFactoryImplementor factory)
throws HibernateException;
/**
* compare two instances of the type
* @param entityMode
*/
public int compare(Object x, Object y, EntityMode entityMode);
/**
* Should the parent be considered dirty, given both the old and current field or
* element value?
*
* @param old the old value
* @param current the current value
* @param session
* @return true if the field is dirty
*/
public boolean isDirty(Object old, Object current, SessionImplementor session)
throws HibernateException;
/**
* Should the parent be considered dirty, given both the old and current field or
* element value?
*
* @param old the old value
* @p