001
014
015 package com.liferay.portal.dao.orm.hibernate;
016
017 import com.liferay.portal.kernel.util.StringPool;
018 import com.liferay.portal.kernel.util.Validator;
019
020 import java.io.Serializable;
021
022 import java.sql.PreparedStatement;
023 import java.sql.ResultSet;
024 import java.sql.SQLException;
025
026 import org.hibernate.engine.SessionImplementor;
027 import org.hibernate.type.StandardBasicTypes;
028 import org.hibernate.type.Type;
029 import org.hibernate.usertype.CompositeUserType;
030
031
034 public class StringType implements CompositeUserType, Serializable {
035
036 public Object assemble(
037 Serializable cached, SessionImplementor session, Object owner) {
038
039 return cached;
040 }
041
042 public Object deepCopy(Object obj) {
043 return obj;
044 }
045
046 public Serializable disassemble(Object value, SessionImplementor session) {
047 return (Serializable)value;
048 }
049
050 public boolean equals(Object x, Object y) {
051 if (Validator.equals(x, y)) {
052 return true;
053 }
054 else if (((x == null) || x.equals(StringPool.BLANK)) &&
055 ((y == null) || y.equals(StringPool.BLANK))) {
056
057 return true;
058 }
059 else {
060 return false;
061 }
062 }
063
064 public String[] getPropertyNames() {
065 return new String[0];
066 }
067
068 public Type[] getPropertyTypes() {
069 return new Type[] {StandardBasicTypes.STRING};
070 }
071
072 public Object getPropertyValue(Object component, int property) {
073 return component;
074 }
075
076 public int hashCode(Object x) {
077 return x.hashCode();
078 }
079
080 public boolean isMutable() {
081 return false;
082 }
083
084 public Object nullSafeGet(
085 ResultSet rs, String[] names, SessionImplementor session,
086 Object owner)
087 throws SQLException {
088
089 return StandardBasicTypes.STRING.nullSafeGet(rs, names, session, owner);
090 }
091
092 public void nullSafeSet(
093 PreparedStatement ps, Object target, int index,
094 SessionImplementor session)
095 throws SQLException {
096
097 StandardBasicTypes.STRING.nullSafeSet(ps, target, index, session);
098 }
099
100 public Object replace(
101 Object original, Object target, SessionImplementor session,
102 Object owner) {
103
104 return original;
105 }
106
107 public Class<String> returnedClass() {
108 return String.class;
109 }
110
111 public void setPropertyValue(Object component, int property, Object value) {
112 }
113
114 }