Change JavaTypeDescriptor#fromString to accept a CharSequence instead of String and introduce CharSequence utilities to avoid creating intermediate strings
This commit is contained in:
parent
40ccad1db2
commit
9e83129fc3
|
@ -41,9 +41,9 @@ public class CommaDelimitedStringsJavaTypeDescriptor extends AbstractClassTypeDe
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List fromString(String string) {
|
public List fromString(CharSequence string) {
|
||||||
List<String> values = new ArrayList<>();
|
List<String> values = new ArrayList<>();
|
||||||
Collections.addAll( values, string.split( DELIMITER ) );
|
Collections.addAll( values, string.toString().split( DELIMITER ) );
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ public class CommaDelimitedStringsJavaTypeDescriptor extends AbstractClassTypeDe
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <X> List wrap(X value, WrapperOptions options) {
|
public <X> List wrap(X value, WrapperOptions options) {
|
||||||
return fromString( (String) value );
|
return fromString( (CharSequence) value );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//end::collections-comma-delimited-collection-example[]
|
//end::collections-comma-delimited-collection-example[]
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class TimestampEpochType
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Date fromStringValue(
|
public Date fromStringValue(
|
||||||
String xml) throws HibernateException {
|
CharSequence xml) throws HibernateException {
|
||||||
return fromString( xml );
|
return fromString( xml );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,8 +38,8 @@ public class BitSetJavaType extends AbstractClassTypeDescriptor<BitSet> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BitSet fromString(String string) {
|
public BitSet fromString(CharSequence string) {
|
||||||
return BitSetHelper.stringToBitSet( string );
|
return BitSetHelper.stringToBitSet( string.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({"unchecked"})
|
@SuppressWarnings({"unchecked"})
|
||||||
|
@ -65,8 +65,8 @@ public class BitSetJavaType extends AbstractClassTypeDescriptor<BitSet> {
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ( value instanceof String ) {
|
if ( value instanceof CharSequence ) {
|
||||||
return fromString( (String) value );
|
return fromString( (CharSequence) value );
|
||||||
}
|
}
|
||||||
if ( value instanceof BitSet ) {
|
if ( value instanceof BitSet ) {
|
||||||
return (BitSet) value;
|
return (BitSet) value;
|
||||||
|
|
|
@ -22,8 +22,8 @@ public class BitSetType
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BitSet stringToObject(String xml) throws Exception {
|
public BitSet stringToObject(CharSequence sequence) throws Exception {
|
||||||
return fromString( xml );
|
return fromString( sequence );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -21,8 +21,8 @@ public class GenderJavaTypeDescriptor extends AbstractClassTypeDescriptor<Gender
|
||||||
return value == null ? null : value.name();
|
return value == null ? null : value.name();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Gender fromString(String string) {
|
public Gender fromString(CharSequence string) {
|
||||||
return string == null ? null : Gender.valueOf( string );
|
return string == null ? null : Gender.valueOf( string.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public <X> X unwrap(Gender value, Class<X> type, WrapperOptions options) {
|
public <X> X unwrap(Gender value, Class<X> type, WrapperOptions options) {
|
||||||
|
|
|
@ -0,0 +1,105 @@
|
||||||
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/
|
||||||
|
package org.hibernate.internal.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Christian Beikov
|
||||||
|
*/
|
||||||
|
public final class CharSequenceHelper {
|
||||||
|
|
||||||
|
private CharSequenceHelper() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CharSequence subSequence(CharSequence sequence, int start, int end) {
|
||||||
|
if ( sequence instanceof SubSequence ) {
|
||||||
|
return sequence.subSequence( start, end );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return new SubSequence( sequence, start, end );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isEmpty(CharSequence string) {
|
||||||
|
return string == null || string.length() == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int lastIndexOf(CharSequence charSequence, char c) {
|
||||||
|
return lastIndexOf( charSequence, c, 0, charSequence.length() - 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int lastIndexOf(CharSequence charSequence, char c, int fromIndex, int endIndex) {
|
||||||
|
if ( charSequence instanceof String ) {
|
||||||
|
int idx = ( (String) charSequence ).lastIndexOf( c, endIndex );
|
||||||
|
if ( idx < fromIndex ) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return idx;
|
||||||
|
}
|
||||||
|
else if ( charSequence instanceof SubSequence ) {
|
||||||
|
int idx = ( (SubSequence) charSequence ).lastIndexOf( c, fromIndex, endIndex );
|
||||||
|
if ( idx == -1 ) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return idx;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return lastIndexOf( charSequence.toString(), c, fromIndex, endIndex );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int indexOf(CharSequence charSequence, char c) {
|
||||||
|
return indexOf( charSequence, c, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int indexOf(CharSequence charSequence, char c, int fromIndex) {
|
||||||
|
return indexOf( charSequence, c, fromIndex, charSequence.length() - 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int indexOf(CharSequence charSequence, char c, int fromIndex, int endIndex) {
|
||||||
|
if ( charSequence instanceof String ) {
|
||||||
|
int idx = ( (String) charSequence ).indexOf( c, fromIndex );
|
||||||
|
if ( idx > endIndex ) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return idx;
|
||||||
|
}
|
||||||
|
else if ( charSequence instanceof SubSequence ) {
|
||||||
|
int idx = ( (SubSequence) charSequence ).indexOf( c, fromIndex, endIndex );
|
||||||
|
if ( idx == -1 ) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return idx;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return indexOf( charSequence.toString(), c, fromIndex, endIndex );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int indexOf(CharSequence charSequence, String target, int fromIndex) {
|
||||||
|
return indexOf( charSequence, target, fromIndex, charSequence.length() - 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int indexOf(CharSequence charSequence, String target, int fromIndex, int endIndex) {
|
||||||
|
if ( charSequence instanceof String ) {
|
||||||
|
int idx = ( (String) charSequence ).indexOf( target, fromIndex );
|
||||||
|
if ( idx > endIndex ) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return idx;
|
||||||
|
}
|
||||||
|
else if ( charSequence instanceof SubSequence ) {
|
||||||
|
int idx = ( (SubSequence) charSequence ).indexOf( target, fromIndex, endIndex );
|
||||||
|
if ( idx == -1 ) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return idx;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return indexOf( charSequence.toString(), target, fromIndex, endIndex );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,75 @@
|
||||||
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/
|
||||||
|
package org.hibernate.internal.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Christian Beikov
|
||||||
|
*/
|
||||||
|
public final class SubSequence implements CharSequence {
|
||||||
|
private final CharSequence sequence;
|
||||||
|
private final int start;
|
||||||
|
private final int length;
|
||||||
|
|
||||||
|
public SubSequence(CharSequence sequence, int start, int end) {
|
||||||
|
this.sequence = sequence;
|
||||||
|
this.start = start;
|
||||||
|
this.length = end - start;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int length() {
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public char charAt(int index) {
|
||||||
|
if ( index < 0 || index >= length ) {
|
||||||
|
throw new StringIndexOutOfBoundsException( index );
|
||||||
|
}
|
||||||
|
return sequence.charAt( index + start );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CharSequence subSequence(int start, int end) {
|
||||||
|
if ( start < 0 || start >= length ) {
|
||||||
|
throw new StringIndexOutOfBoundsException( start );
|
||||||
|
}
|
||||||
|
if ( end > length ) {
|
||||||
|
throw new StringIndexOutOfBoundsException( end );
|
||||||
|
}
|
||||||
|
return sequence.subSequence( this.start + start, this.start + end );
|
||||||
|
}
|
||||||
|
|
||||||
|
public int lastIndexOf(char c, int fromIndex, int endIndex) {
|
||||||
|
int idx = CharSequenceHelper.lastIndexOf( sequence, c, start + fromIndex, this.start + endIndex );
|
||||||
|
if ( idx == -1 ) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return idx - this.start;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int indexOf(char c, int fromIndex, int endIndex) {
|
||||||
|
int idx = CharSequenceHelper.indexOf( sequence, c, this.start + fromIndex, this.start + endIndex );
|
||||||
|
if ( idx == -1 ) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return idx - this.start;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int indexOf(String s, int fromIndex, int endIndex) {
|
||||||
|
int idx = CharSequenceHelper.indexOf( sequence, s, this.start + fromIndex, this.start + endIndex );
|
||||||
|
if ( idx == -1 ) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return idx - this.start;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return sequence.subSequence( start, start + length ).toString();
|
||||||
|
}
|
||||||
|
}
|
|
@ -232,8 +232,8 @@ public class DiscriminatorType<T> extends AbstractType implements org.hibernate.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T stringToObject(String xml) throws Exception {
|
public T stringToObject(CharSequence sequence) throws Exception {
|
||||||
return ( (org.hibernate.type.DiscriminatorType<T>) underlyingType ).stringToObject( xml );
|
return ( (org.hibernate.type.DiscriminatorType<T>) underlyingType ).stringToObject( sequence );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -40,6 +40,8 @@ import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
|
||||||
import org.hibernate.grammars.hql.HqlLexer;
|
import org.hibernate.grammars.hql.HqlLexer;
|
||||||
import org.hibernate.grammars.hql.HqlParser;
|
import org.hibernate.grammars.hql.HqlParser;
|
||||||
import org.hibernate.grammars.hql.HqlParserBaseVisitor;
|
import org.hibernate.grammars.hql.HqlParserBaseVisitor;
|
||||||
|
import org.hibernate.internal.util.CharSequenceHelper;
|
||||||
|
import org.hibernate.internal.util.StringHelper;
|
||||||
import org.hibernate.internal.util.collections.Stack;
|
import org.hibernate.internal.util.collections.Stack;
|
||||||
import org.hibernate.internal.util.collections.StandardStack;
|
import org.hibernate.internal.util.collections.StandardStack;
|
||||||
import org.hibernate.metamodel.CollectionClassification;
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
|
@ -2967,7 +2969,7 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
|
|
||||||
private SqmLiteral<byte[]> binaryLiteral(String text) {
|
private SqmLiteral<byte[]> binaryLiteral(String text) {
|
||||||
return new SqmLiteral<>(
|
return new SqmLiteral<>(
|
||||||
StandardBasicTypes.BINARY.fromStringValue( text.substring( 2, text.length()-1 ) ),
|
StandardBasicTypes.BINARY.fromStringValue( CharSequenceHelper.subSequence( text, 2, text.length() - 1 ) ),
|
||||||
resolveExpressableTypeBasic( byte[].class ),
|
resolveExpressableTypeBasic( byte[].class ),
|
||||||
creationContext.getNodeBuilder()
|
creationContext.getNodeBuilder()
|
||||||
);
|
);
|
||||||
|
|
|
@ -2773,8 +2773,8 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
if ( javaTypeDescriptor.getJavaTypeClass().isInstance( literalValue ) ) {
|
if ( javaTypeDescriptor.getJavaTypeClass().isInstance( literalValue ) ) {
|
||||||
discriminatorValue = literalValue;
|
discriminatorValue = literalValue;
|
||||||
}
|
}
|
||||||
else if ( literalValue instanceof String ) {
|
else if ( literalValue instanceof CharSequence ) {
|
||||||
discriminatorValue = javaTypeDescriptor.fromString( (String) literalValue );
|
discriminatorValue = javaTypeDescriptor.fromString( (CharSequence) literalValue );
|
||||||
}
|
}
|
||||||
else if ( creationContext.getSessionFactory().getJpaMetamodel().getJpaCompliance().isLoadByIdComplianceEnabled() ) {
|
else if ( creationContext.getSessionFactory().getJpaMetamodel().getJpaCompliance().isLoadByIdComplianceEnabled() ) {
|
||||||
discriminatorValue = literalValue;
|
discriminatorValue = literalValue;
|
||||||
|
|
|
@ -16,7 +16,6 @@ import java.util.Map;
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
import org.hibernate.NotYetImplementedFor6Exception;
|
|
||||||
import org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer;
|
import org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer;
|
||||||
import org.hibernate.engine.jdbc.Size;
|
import org.hibernate.engine.jdbc.Size;
|
||||||
import org.hibernate.engine.spi.Mapping;
|
import org.hibernate.engine.spi.Mapping;
|
||||||
|
@ -86,7 +85,7 @@ public abstract class AbstractStandardBasicType<T>
|
||||||
return getExpressableJavaTypeDescriptor().getJavaTypeClass();
|
return getExpressableJavaTypeDescriptor().getJavaTypeClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
public T fromString(String string) {
|
public T fromString(CharSequence string) {
|
||||||
return javaTypeDescriptor.fromString( string );
|
return javaTypeDescriptor.fromString( string );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +95,7 @@ public abstract class AbstractStandardBasicType<T>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T fromStringValue(String xml) throws HibernateException {
|
public T fromStringValue(CharSequence xml) throws HibernateException {
|
||||||
return fromString( xml );
|
return fromString( xml );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class BigIntegerType
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BigInteger stringToObject(String string) {
|
public BigInteger stringToObject(CharSequence string) {
|
||||||
return BigIntegerTypeDescriptor.INSTANCE.fromString( string );
|
return BigIntegerTypeDescriptor.INSTANCE.fromString( string );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class BooleanType
|
||||||
return Boolean.FALSE;
|
return Boolean.FALSE;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public Boolean stringToObject(String string) {
|
public Boolean stringToObject(CharSequence string) {
|
||||||
return fromString( string );
|
return fromString( string );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,12 +58,12 @@ public class ByteType
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Byte stringToObject(String xml) {
|
public Byte stringToObject(CharSequence sequence) {
|
||||||
return fromString( xml );
|
return fromString( sequence );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Byte fromStringValue(String xml) {
|
public Byte fromStringValue(CharSequence xml) {
|
||||||
return fromString( xml );
|
return fromString( xml );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,8 +50,8 @@ public class CharacterNCharType
|
||||||
return new String( chars );
|
return new String( chars );
|
||||||
}
|
}
|
||||||
|
|
||||||
public Character stringToObject(String xml) {
|
public Character stringToObject(CharSequence sequence) {
|
||||||
return fromString( xml );
|
return fromString( sequence );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,8 +61,8 @@ public class CharacterType
|
||||||
return new String( chars );
|
return new String( chars );
|
||||||
}
|
}
|
||||||
|
|
||||||
public Character stringToObject(String xml) {
|
public Character stringToObject(CharSequence sequence) {
|
||||||
return fromString( xml );
|
return fromString( sequence );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -252,8 +252,8 @@ public class CustomType
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object stringToObject(String xml) {
|
public Object stringToObject(CharSequence sequence) {
|
||||||
return fromStringValue( xml );
|
return fromStringValue( sequence );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -318,13 +318,13 @@ public class CustomType
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object fromStringValue(String string) throws HibernateException {
|
public Object fromStringValue(CharSequence sequence) throws HibernateException {
|
||||||
if ( getUserType() instanceof StringRepresentableType ) {
|
if ( getUserType() instanceof StringRepresentableType ) {
|
||||||
return ( (StringRepresentableType) getUserType() ).fromStringValue( string );
|
return ( (StringRepresentableType) getUserType() ).fromStringValue( sequence );
|
||||||
}
|
}
|
||||||
if ( getUserType() instanceof EnhancedUserType ) {
|
if ( getUserType() instanceof EnhancedUserType ) {
|
||||||
//noinspection deprecation
|
//noinspection deprecation
|
||||||
return ( (EnhancedUserType) getUserType() ).fromXMLString( string );
|
return ( (EnhancedUserType) getUserType() ).fromXMLString( sequence );
|
||||||
}
|
}
|
||||||
throw new HibernateException(
|
throw new HibernateException(
|
||||||
String.format(
|
String.format(
|
||||||
|
|
|
@ -57,8 +57,8 @@ public class DateType
|
||||||
return StringType.INSTANCE.objectToSQLString( jdbcDate.toString(), dialect );
|
return StringType.INSTANCE.objectToSQLString( jdbcDate.toString(), dialect );
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date stringToObject(String xml) {
|
public Date stringToObject(CharSequence sequence) {
|
||||||
return fromString( xml );
|
return fromString( sequence );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -432,7 +432,7 @@ public class EnumType<T extends Enum<T>>
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("RedundantCast")
|
@SuppressWarnings("RedundantCast")
|
||||||
public Object fromXMLString(String xmlValue) {
|
public Object fromXMLString(CharSequence xmlValue) {
|
||||||
verifyConfigured();
|
verifyConfigured();
|
||||||
return (T) enumValueConverter.getDomainJavaDescriptor().wrap( xmlValue, null );
|
return (T) enumValueConverter.getDomainJavaDescriptor().wrap( xmlValue, null );
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,11 +18,11 @@ public interface IdentifierType<T> extends Type {
|
||||||
/**
|
/**
|
||||||
* Convert the value from the mapping file to a Java object.
|
* Convert the value from the mapping file to a Java object.
|
||||||
*
|
*
|
||||||
* @param xml the value of <tt>discriminator-value</tt> or <tt>unsaved-value</tt> attribute
|
* @param sequence the value of <tt>discriminator-value</tt> or <tt>unsaved-value</tt> attribute
|
||||||
* @return The converted value of the string representation.
|
* @return The converted value of the string representation.
|
||||||
*
|
*
|
||||||
* @throws Exception Indicates a problem converting from the string
|
* @throws Exception Indicates a problem converting from the string
|
||||||
*/
|
*/
|
||||||
public T stringToObject(String xml) throws Exception;
|
public T stringToObject(CharSequence sequence) throws Exception;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,8 +56,8 @@ public class IntegerType extends AbstractSingleColumnStandardBasicType<Integer>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer stringToObject(String xml) {
|
public Integer stringToObject(CharSequence sequence) {
|
||||||
return fromString( xml );
|
return fromString( sequence );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -53,8 +53,8 @@ public class LongType
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long stringToObject(String xml) throws Exception {
|
public Long stringToObject(CharSequence sequence) throws Exception {
|
||||||
return Long.valueOf( xml );
|
return Long.valueOf( sequence.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class NumericBooleanType
|
||||||
return Boolean.FALSE;
|
return Boolean.FALSE;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public Boolean stringToObject(String string) {
|
public Boolean stringToObject(CharSequence string) {
|
||||||
return fromString( string );
|
return fromString( string );
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -58,8 +58,8 @@ public class ShortType
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Short stringToObject(String xml) {
|
public Short stringToObject(CharSequence sequence) {
|
||||||
return Short.valueOf( xml );
|
return Short.valueOf( sequence.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -24,7 +24,7 @@ public interface SingleColumnType<T> extends Type {
|
||||||
|
|
||||||
String toString(T value) throws HibernateException;
|
String toString(T value) throws HibernateException;
|
||||||
|
|
||||||
T fromStringValue(String xml) throws HibernateException;
|
T fromStringValue(CharSequence sequence) throws HibernateException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a column value from a result set by name.
|
* Get a column value from a result set by name.
|
||||||
|
|
|
@ -40,8 +40,8 @@ public class StringNVarcharType
|
||||||
return QueryLiteralHelper.toStringLiteral( value );
|
return QueryLiteralHelper.toStringLiteral( value );
|
||||||
}
|
}
|
||||||
|
|
||||||
public String stringToObject(String xml) throws Exception {
|
public String stringToObject(CharSequence sequence) throws Exception {
|
||||||
return xml;
|
return sequence.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString(String value) {
|
public String toString(String value) {
|
||||||
|
|
|
@ -28,11 +28,11 @@ public interface StringRepresentableType<T> {
|
||||||
/**
|
/**
|
||||||
* Consume the given string representation back into this types java form.
|
* Consume the given string representation back into this types java form.
|
||||||
*
|
*
|
||||||
* @param string The string representation to be consumed.
|
* @param sequence The string representation to be consumed.
|
||||||
*
|
*
|
||||||
* @return The java type representation
|
* @return The java type representation
|
||||||
*
|
*
|
||||||
* @throws HibernateException Problem consuming
|
* @throws HibernateException Problem consuming
|
||||||
*/
|
*/
|
||||||
T fromStringValue(String string) throws HibernateException;
|
T fromStringValue(CharSequence sequence) throws HibernateException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,8 +45,8 @@ public class StringType
|
||||||
return QueryLiteralHelper.toStringLiteral( value );
|
return QueryLiteralHelper.toStringLiteral( value );
|
||||||
}
|
}
|
||||||
|
|
||||||
public String stringToObject(String xml) throws Exception {
|
public String stringToObject(CharSequence sequence) throws Exception {
|
||||||
return xml;
|
return sequence.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString(String value) {
|
public String toString(String value) {
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class TimestampType
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Date fromStringValue(String xml) throws HibernateException {
|
public Date fromStringValue(CharSequence xml) throws HibernateException {
|
||||||
return fromString( xml );
|
return fromString( xml );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,8 @@ public class TrueFalseType
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean stringToObject(String xml) throws Exception {
|
public Boolean stringToObject(CharSequence sequence) throws Exception {
|
||||||
return fromString( xml );
|
return fromString( sequence );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class UrlType extends AbstractSingleColumnStandardBasicType<URL> implemen
|
||||||
return StringType.INSTANCE.objectToSQLString( toString( value ), dialect );
|
return StringType.INSTANCE.objectToSQLString( toString( value ), dialect );
|
||||||
}
|
}
|
||||||
|
|
||||||
public URL stringToObject(String xml) throws Exception {
|
public URL stringToObject(CharSequence sequence) throws Exception {
|
||||||
return UrlTypeDescriptor.INSTANCE.fromString( xml );
|
return UrlTypeDescriptor.INSTANCE.fromString( sequence );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,8 +45,8 @@ public class YesNoType
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean stringToObject(String xml) throws Exception {
|
public Boolean stringToObject(CharSequence sequence) throws Exception {
|
||||||
return fromString( xml );
|
return fromString( sequence );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -35,7 +35,7 @@ public interface BasicJavaDescriptor<T> extends JavaTypeDescriptor<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default T fromString(String string) {
|
default T fromString(CharSequence string) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,8 @@ public class BigDecimalTypeDescriptor extends AbstractClassTypeDescriptor<BigDec
|
||||||
return value.toString();
|
return value.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal fromString(String string) {
|
public BigDecimal fromString(CharSequence string) {
|
||||||
return new BigDecimal( string );
|
return new BigDecimal( string.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -31,8 +31,8 @@ public class BigIntegerTypeDescriptor extends AbstractClassTypeDescriptor<BigInt
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BigInteger fromString(String string) {
|
public BigInteger fromString(CharSequence string) {
|
||||||
return new BigInteger( string );
|
return new BigInteger( string.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class BlobTypeDescriptor extends AbstractClassTypeDescriptor<Blob> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Blob fromString(String string) {
|
public Blob fromString(CharSequence string) {
|
||||||
return BlobProxy.generateProxy( PrimitiveByteArrayTypeDescriptor.INSTANCE.fromString( string ) );
|
return BlobProxy.generateProxy( PrimitiveByteArrayTypeDescriptor.INSTANCE.fromString( string ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,8 +46,8 @@ public class BooleanTypeDescriptor extends AbstractClassTypeDescriptor<Boolean>
|
||||||
return value == null ? null : value.toString();
|
return value == null ? null : value.toString();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public Boolean fromString(String string) {
|
public Boolean fromString(CharSequence string) {
|
||||||
return Boolean.valueOf( string );
|
return Boolean.valueOf( string.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked" })
|
@SuppressWarnings({ "unchecked" })
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class ByteArrayTypeDescriptor extends AbstractClassTypeDescriptor<Byte[]>
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public Byte[] fromString(String string) {
|
public Byte[] fromString(CharSequence string) {
|
||||||
if ( string == null ) {
|
if ( string == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ public class ByteArrayTypeDescriptor extends AbstractClassTypeDescriptor<Byte[]>
|
||||||
}
|
}
|
||||||
Byte[] bytes = new Byte[string.length() / 2];
|
Byte[] bytes = new Byte[string.length() / 2];
|
||||||
for ( int i = 0; i < bytes.length; i++ ) {
|
for ( int i = 0; i < bytes.length; i++ ) {
|
||||||
final String hexStr = string.substring( i * 2, (i + 1) * 2 );
|
final String hexStr = string.subSequence( i * 2, (i + 1) * 2 ).toString();
|
||||||
bytes[i] = (byte) Integer.parseInt( hexStr, 16 );
|
bytes[i] = (byte) Integer.parseInt( hexStr, 16 );
|
||||||
}
|
}
|
||||||
return bytes;
|
return bytes;
|
||||||
|
|
|
@ -31,8 +31,8 @@ public class ByteTypeDescriptor extends AbstractClassTypeDescriptor<Byte> implem
|
||||||
return value == null ? null : value.toString();
|
return value == null ? null : value.toString();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public Byte fromString(String string) {
|
public Byte fromString(CharSequence string) {
|
||||||
return Byte.valueOf( string );
|
return Byte.valueOf( string.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked" })
|
@SuppressWarnings({ "unchecked" })
|
||||||
|
|
|
@ -68,9 +68,9 @@ public class CalendarDateTypeDescriptor extends AbstractTemporalTypeDescriptor<C
|
||||||
return DateTypeDescriptor.INSTANCE.toString( value.getTime() );
|
return DateTypeDescriptor.INSTANCE.toString( value.getTime() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public Calendar fromString(String string) {
|
public Calendar fromString(CharSequence string) {
|
||||||
Calendar result = new GregorianCalendar();
|
Calendar result = new GregorianCalendar();
|
||||||
result.setTime( DateTypeDescriptor.INSTANCE.fromString( string ) );
|
result.setTime( DateTypeDescriptor.INSTANCE.fromString( string.toString() ) );
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,9 +65,9 @@ public class CalendarTimeTypeDescriptor extends AbstractTemporalTypeDescriptor<C
|
||||||
return DateTypeDescriptor.INSTANCE.toString( value.getTime() );
|
return DateTypeDescriptor.INSTANCE.toString( value.getTime() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public Calendar fromString(String string) {
|
public Calendar fromString(CharSequence string) {
|
||||||
Calendar result = new GregorianCalendar();
|
Calendar result = new GregorianCalendar();
|
||||||
result.setTime( DateTypeDescriptor.INSTANCE.fromString( string ) );
|
result.setTime( DateTypeDescriptor.INSTANCE.fromString( string.toString() ) );
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,9 +72,9 @@ public class CalendarTypeDescriptor extends AbstractTemporalTypeDescriptor<Calen
|
||||||
return DateTypeDescriptor.INSTANCE.toString( value.getTime() );
|
return DateTypeDescriptor.INSTANCE.toString( value.getTime() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public Calendar fromString(String string) {
|
public Calendar fromString(CharSequence string) {
|
||||||
Calendar result = new GregorianCalendar();
|
Calendar result = new GregorianCalendar();
|
||||||
result.setTime( DateTypeDescriptor.INSTANCE.fromString( string ) );
|
result.setTime( DateTypeDescriptor.INSTANCE.fromString( string.toString() ) );
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,8 @@ public class CharacterArrayTypeDescriptor extends AbstractClassTypeDescriptor<Ch
|
||||||
return new String( unwrapChars( value ) );
|
return new String( unwrapChars( value ) );
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public Character[] fromString(String string) {
|
public Character[] fromString(CharSequence string) {
|
||||||
return wrapChars( string.toCharArray() );
|
return wrapChars( string.toString().toCharArray() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class CharacterTypeDescriptor extends AbstractClassTypeDescriptor<Charact
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Character fromString(String string) {
|
public Character fromString(CharSequence string) {
|
||||||
if ( string.length() != 1 ) {
|
if ( string.length() != 1 ) {
|
||||||
throw new HibernateException( "multiple or zero characters found parsing string" );
|
throw new HibernateException( "multiple or zero characters found parsing string" );
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,13 +25,13 @@ public class ClassTypeDescriptor extends AbstractClassTypeDescriptor<Class> {
|
||||||
return value.getName();
|
return value.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Class fromString(String string) {
|
public Class fromString(CharSequence string) {
|
||||||
if ( string == null ) {
|
if ( string == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return ReflectHelper.classForName( string );
|
return ReflectHelper.classForName( string.toString() );
|
||||||
}
|
}
|
||||||
catch ( ClassNotFoundException e ) {
|
catch ( ClassNotFoundException e ) {
|
||||||
throw new HibernateException( "Unable to locate named class " + string );
|
throw new HibernateException( "Unable to locate named class " + string );
|
||||||
|
@ -59,8 +59,8 @@ public class ClassTypeDescriptor extends AbstractClassTypeDescriptor<Class> {
|
||||||
if ( Class.class.isInstance( value ) ) {
|
if ( Class.class.isInstance( value ) ) {
|
||||||
return (Class) value;
|
return (Class) value;
|
||||||
}
|
}
|
||||||
if ( String.class.isInstance( value ) ) {
|
if ( CharSequence.class.isInstance( value ) ) {
|
||||||
return fromString( (String)value );
|
return fromString( (CharSequence) value );
|
||||||
}
|
}
|
||||||
throw unknownWrap( value.getClass() );
|
throw unknownWrap( value.getClass() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,8 +60,8 @@ public class ClobTypeDescriptor extends AbstractClassTypeDescriptor<Clob> {
|
||||||
return DataHelper.extractString( value );
|
return DataHelper.extractString( value );
|
||||||
}
|
}
|
||||||
|
|
||||||
public Clob fromString(String string) {
|
public Clob fromString(CharSequence string) {
|
||||||
return ClobProxy.generateProxy( string );
|
return ClobProxy.generateProxy( string.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -28,8 +28,8 @@ public class CurrencyTypeDescriptor extends AbstractClassTypeDescriptor<Currency
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Currency fromString(String string) {
|
public Currency fromString(CharSequence string) {
|
||||||
return Currency.getInstance( string );
|
return Currency.getInstance( string.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked" })
|
@SuppressWarnings({ "unchecked" })
|
||||||
|
|
|
@ -83,9 +83,9 @@ public class DateTypeDescriptor extends AbstractTemporalTypeDescriptor<Date> {
|
||||||
return new SimpleDateFormat( DATE_FORMAT ).format( value );
|
return new SimpleDateFormat( DATE_FORMAT ).format( value );
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public Date fromString(String string) {
|
public Date fromString(CharSequence string) {
|
||||||
try {
|
try {
|
||||||
return new SimpleDateFormat(DATE_FORMAT).parse( string );
|
return new SimpleDateFormat(DATE_FORMAT).parse( string.toString() );
|
||||||
}
|
}
|
||||||
catch ( ParseException pe) {
|
catch ( ParseException pe) {
|
||||||
throw new HibernateException( "could not parse date string" + string, pe );
|
throw new HibernateException( "could not parse date string" + string, pe );
|
||||||
|
|
|
@ -39,8 +39,8 @@ public class DoubleTypeDescriptor extends AbstractClassTypeDescriptor<Double> im
|
||||||
return value == null ? null : value.toString();
|
return value == null ? null : value.toString();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public Double fromString(String string) {
|
public Double fromString(CharSequence string) {
|
||||||
return Double.valueOf( string );
|
return Double.valueOf( string.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked" })
|
@SuppressWarnings({ "unchecked" })
|
||||||
|
|
|
@ -60,14 +60,14 @@ public class DurationJavaDescriptor extends AbstractClassTypeDescriptor<Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Duration fromString(String string) {
|
public Duration fromString(CharSequence string) {
|
||||||
if ( string == null ) {
|
if ( string == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
int cutoff = string.length() - 9;
|
int cutoff = string.length() - 9;
|
||||||
return Duration.ofSeconds(
|
return Duration.ofSeconds(
|
||||||
Long.parseLong( string.substring( 0, cutoff ) ),
|
Long.parseLong( string.subSequence( 0, cutoff ).toString() ),
|
||||||
Long.parseLong( string.substring( cutoff ) )
|
Long.parseLong( string.subSequence( cutoff, string.length() ).toString() )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,8 +49,8 @@ public class EnumJavaTypeDescriptor<T extends Enum<T>> extends AbstractClassType
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T fromString(String string) {
|
public T fromString(CharSequence string) {
|
||||||
return string == null ? null : Enum.valueOf( getJavaTypeClass(), string );
|
return string == null ? null : Enum.valueOf( getJavaTypeClass(), string.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -38,8 +38,8 @@ public class FloatTypeDescriptor extends AbstractClassTypeDescriptor<Float> impl
|
||||||
return value == null ? null : value.toString();
|
return value == null ? null : value.toString();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public Float fromString(String string) {
|
public Float fromString(CharSequence string) {
|
||||||
return Float.valueOf( string );
|
return Float.valueOf( string.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked" })
|
@SuppressWarnings({ "unchecked" })
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class InstantJavaDescriptor extends AbstractTemporalTypeDescriptor<Instan
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Instant fromString(String string) {
|
public Instant fromString(CharSequence string) {
|
||||||
return Instant.from( DateTimeFormatter.ISO_INSTANT.parse( string ) );
|
return Instant.from( DateTimeFormatter.ISO_INSTANT.parse( string ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,8 @@ public class IntegerTypeDescriptor extends AbstractClassTypeDescriptor<Integer>
|
||||||
return value == null ? null : value.toString();
|
return value == null ? null : value.toString();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public Integer fromString(String string) {
|
public Integer fromString(CharSequence string) {
|
||||||
return string == null ? null : Integer.valueOf( string );
|
return string == null ? null : Integer.valueOf( string.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked" })
|
@SuppressWarnings({ "unchecked" })
|
||||||
|
|
|
@ -15,6 +15,7 @@ import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.engine.jdbc.Size;
|
import org.hibernate.engine.jdbc.Size;
|
||||||
import org.hibernate.internal.util.ReflectHelper;
|
import org.hibernate.internal.util.ReflectHelper;
|
||||||
import org.hibernate.internal.util.compare.ComparableComparator;
|
import org.hibernate.internal.util.compare.ComparableComparator;
|
||||||
|
import org.hibernate.sql.ast.spi.SqlAppender;
|
||||||
import org.hibernate.type.descriptor.WrapperOptions;
|
import org.hibernate.type.descriptor.WrapperOptions;
|
||||||
import org.hibernate.type.descriptor.jdbc.JdbcTypeDescriptor;
|
import org.hibernate.type.descriptor.jdbc.JdbcTypeDescriptor;
|
||||||
import org.hibernate.type.descriptor.jdbc.JdbcTypeDescriptorIndicators;
|
import org.hibernate.type.descriptor.jdbc.JdbcTypeDescriptorIndicators;
|
||||||
|
@ -147,7 +148,7 @@ public interface JavaTypeDescriptor<T> extends Serializable {
|
||||||
return value == null ? "null" : value.toString();
|
return value == null ? "null" : value.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
T fromString(String string);
|
T fromString(CharSequence string);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unwrap an instance of our handled Java type into the requested type.
|
* Unwrap an instance of our handled Java type into the requested type.
|
||||||
|
|
|
@ -88,9 +88,9 @@ public class JdbcDateTypeDescriptor extends AbstractTemporalTypeDescriptor<Date>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Date fromString(String string) {
|
public Date fromString(CharSequence string) {
|
||||||
try {
|
try {
|
||||||
return new Date( new SimpleDateFormat(DATE_FORMAT).parse( string ).getTime() );
|
return new Date( new SimpleDateFormat(DATE_FORMAT).parse( string.toString() ).getTime() );
|
||||||
}
|
}
|
||||||
catch ( ParseException pe) {
|
catch ( ParseException pe) {
|
||||||
throw new HibernateException( "could not parse date string" + string, pe );
|
throw new HibernateException( "could not parse date string" + string, pe );
|
||||||
|
|
|
@ -84,9 +84,9 @@ public class JdbcTimeTypeDescriptor extends AbstractTemporalTypeDescriptor<Date>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Date fromString(String string) {
|
public Date fromString(CharSequence string) {
|
||||||
try {
|
try {
|
||||||
return new Time( new SimpleDateFormat( TIME_FORMAT ).parse( string ).getTime() );
|
return new Time( new SimpleDateFormat( TIME_FORMAT ).parse( string.toString() ).getTime() );
|
||||||
}
|
}
|
||||||
catch ( ParseException pe ) {
|
catch ( ParseException pe ) {
|
||||||
throw new HibernateException( "could not parse time string" + string, pe );
|
throw new HibernateException( "could not parse time string" + string, pe );
|
||||||
|
|
|
@ -90,7 +90,7 @@ public class JdbcTimestampTypeDescriptor extends AbstractTemporalTypeDescriptor<
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Date fromString(String string) {
|
public Date fromString(CharSequence string) {
|
||||||
try {
|
try {
|
||||||
final TemporalAccessor accessor = LITERAL_FORMATTER.parse( string );
|
final TemporalAccessor accessor = LITERAL_FORMATTER.parse( string );
|
||||||
return new Timestamp(
|
return new Timestamp(
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class LocalDateJavaDescriptor extends AbstractTemporalTypeDescriptor<Loca
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LocalDate fromString(String string) {
|
public LocalDate fromString(CharSequence string) {
|
||||||
return LocalDate.from( DateTimeFormatter.ISO_LOCAL_DATE.parse( string ) );
|
return LocalDate.from( DateTimeFormatter.ISO_LOCAL_DATE.parse( string ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class LocalDateTimeJavaDescriptor extends AbstractTemporalTypeDescriptor<
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LocalDateTime fromString(String string) {
|
public LocalDateTime fromString(CharSequence string) {
|
||||||
return LocalDateTime.from( DateTimeFormatter.ISO_DATE_TIME.parse( string ) );
|
return LocalDateTime.from( DateTimeFormatter.ISO_DATE_TIME.parse( string ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class LocalTimeJavaDescriptor extends AbstractTemporalTypeDescriptor<Loca
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LocalTime fromString(String string) {
|
public LocalTime fromString(CharSequence string) {
|
||||||
return LocalTime.from( DateTimeFormatter.ISO_LOCAL_TIME.parse( string ) );
|
return LocalTime.from( DateTimeFormatter.ISO_LOCAL_TIME.parse( string ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,13 +40,14 @@ public class LocaleTypeDescriptor extends AbstractClassTypeDescriptor<Locale> {
|
||||||
return value.toString();
|
return value.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Locale fromString(String string) {
|
public Locale fromString(CharSequence sequence) {
|
||||||
// TODO : Ultimately switch to Locale.Builder for this. However, Locale.Builder is Java 7
|
// TODO : Ultimately switch to Locale.Builder for this. However, Locale.Builder is Java 7
|
||||||
|
|
||||||
if ( string == null ) {
|
if ( sequence == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String string = sequence.toString();
|
||||||
if( string.isEmpty() ) {
|
if( string.isEmpty() ) {
|
||||||
return Locale.ROOT;
|
return Locale.ROOT;
|
||||||
}
|
}
|
||||||
|
@ -105,8 +106,8 @@ public class LocaleTypeDescriptor extends AbstractClassTypeDescriptor<Locale> {
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ( String.class.isInstance( value ) ) {
|
if ( CharSequence.class.isInstance( value ) ) {
|
||||||
return fromString( (String) value );
|
return fromString( (CharSequence) value );
|
||||||
}
|
}
|
||||||
throw unknownWrap( value.getClass() );
|
throw unknownWrap( value.getClass() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,8 @@ public class LongTypeDescriptor extends AbstractClassTypeDescriptor<Long> implem
|
||||||
return value == null ? null : value.toString();
|
return value == null ? null : value.toString();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public Long fromString(String string) {
|
public Long fromString(CharSequence string) {
|
||||||
return Long.valueOf( string );
|
return Long.valueOf( string.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked" })
|
@SuppressWarnings({ "unchecked" })
|
||||||
|
|
|
@ -65,8 +65,8 @@ public class NClobTypeDescriptor extends AbstractClassTypeDescriptor<NClob> {
|
||||||
return DataHelper.extractString( value );
|
return DataHelper.extractString( value );
|
||||||
}
|
}
|
||||||
|
|
||||||
public NClob fromString(String string) {
|
public NClob fromString(CharSequence string) {
|
||||||
return NClobProxy.generateProxy( string );
|
return NClobProxy.generateProxy( string.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class OffsetDateTimeJavaDescriptor extends AbstractTemporalTypeDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OffsetDateTime fromString(String string) {
|
public OffsetDateTime fromString(CharSequence string) {
|
||||||
return OffsetDateTime.from( DateTimeFormatter.ISO_OFFSET_DATE_TIME.parse( string ) );
|
return OffsetDateTime.from( DateTimeFormatter.ISO_OFFSET_DATE_TIME.parse( string ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class OffsetTimeJavaDescriptor extends AbstractTemporalTypeDescriptor<Off
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OffsetTime fromString(String string) {
|
public OffsetTime fromString(CharSequence string) {
|
||||||
return OffsetTime.from( DateTimeFormatter.ISO_OFFSET_TIME.parse( string ) );
|
return OffsetTime.from( DateTimeFormatter.ISO_OFFSET_TIME.parse( string ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,8 @@ public class PrimitiveByteArrayTypeDescriptor extends AbstractClassTypeDescripto
|
||||||
return value == null ? super.extractLoggableRepresentation( null ) : Arrays.toString( value );
|
return value == null ? super.extractLoggableRepresentation( null ) : Arrays.toString( value );
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] fromString(String string) {
|
@Override
|
||||||
|
public byte[] fromString(CharSequence string) {
|
||||||
if ( string == null ) {
|
if ( string == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -77,7 +78,7 @@ public class PrimitiveByteArrayTypeDescriptor extends AbstractClassTypeDescripto
|
||||||
}
|
}
|
||||||
byte[] bytes = new byte[string.length() / 2];
|
byte[] bytes = new byte[string.length() / 2];
|
||||||
for ( int i = 0; i < bytes.length; i++ ) {
|
for ( int i = 0; i < bytes.length; i++ ) {
|
||||||
final String hexStr = string.substring( i * 2, (i + 1) * 2 );
|
final String hexStr = string.subSequence( i * 2, (i + 1) * 2 ).toString();
|
||||||
bytes[i] = (byte) Integer.parseInt( hexStr, 16 );
|
bytes[i] = (byte) Integer.parseInt( hexStr, 16 );
|
||||||
}
|
}
|
||||||
return bytes;
|
return bytes;
|
||||||
|
|
|
@ -33,8 +33,8 @@ public class PrimitiveCharacterArrayTypeDescriptor extends AbstractClassTypeDesc
|
||||||
return new String( value );
|
return new String( value );
|
||||||
}
|
}
|
||||||
|
|
||||||
public char[] fromString(String string) {
|
public char[] fromString(CharSequence string) {
|
||||||
return string.toCharArray();
|
return string.toString().toCharArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class RowVersionTypeDescriptor extends AbstractClassTypeDescriptor<byte[]
|
||||||
return (value == null) ? super.extractLoggableRepresentation( null ) : Arrays.toString( value );
|
return (value == null) ? super.extractLoggableRepresentation( null ) : Arrays.toString( value );
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] fromString(String string) {
|
public byte[] fromString(CharSequence string) {
|
||||||
if ( string == null ) {
|
if ( string == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ public class RowVersionTypeDescriptor extends AbstractClassTypeDescriptor<byte[]
|
||||||
}
|
}
|
||||||
byte[] bytes = new byte[string.length() / 2];
|
byte[] bytes = new byte[string.length() / 2];
|
||||||
for ( int i = 0; i < bytes.length; i++ ) {
|
for ( int i = 0; i < bytes.length; i++ ) {
|
||||||
final String hexStr = string.substring( i * 2, (i + 1) * 2 );
|
final String hexStr = string.subSequence( i * 2, (i + 1) * 2 ).toString();
|
||||||
bytes[i] = (byte) (Integer.parseInt(hexStr, 16) + Byte.MIN_VALUE);
|
bytes[i] = (byte) (Integer.parseInt(hexStr, 16) + Byte.MIN_VALUE);
|
||||||
}
|
}
|
||||||
return bytes;
|
return bytes;
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class SerializableTypeDescriptor<T extends Serializable> extends Abstract
|
||||||
return PrimitiveByteArrayTypeDescriptor.INSTANCE.toString( toBytes( value ) );
|
return PrimitiveByteArrayTypeDescriptor.INSTANCE.toString( toBytes( value ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public T fromString(String string) {
|
public T fromString(CharSequence string) {
|
||||||
return fromBytes( PrimitiveByteArrayTypeDescriptor.INSTANCE.fromString( string ) );
|
return fromBytes( PrimitiveByteArrayTypeDescriptor.INSTANCE.fromString( string ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,8 @@ public class ShortTypeDescriptor extends AbstractClassTypeDescriptor<Short> impl
|
||||||
return value == null ? null : value.toString();
|
return value == null ? null : value.toString();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public Short fromString(String string) {
|
public Short fromString(CharSequence string) {
|
||||||
return Short.valueOf( string );
|
return Short.valueOf( string.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked" })
|
@SuppressWarnings({ "unchecked" })
|
||||||
|
|
|
@ -35,8 +35,8 @@ public class StringTypeDescriptor extends AbstractClassTypeDescriptor<String> {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String fromString(String string) {
|
public String fromString(CharSequence string) {
|
||||||
return string;
|
return string.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -35,8 +35,8 @@ public class TimeZoneTypeDescriptor extends AbstractClassTypeDescriptor<TimeZone
|
||||||
return value.getID();
|
return value.getID();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimeZone fromString(String string) {
|
public TimeZone fromString(CharSequence string) {
|
||||||
return TimeZone.getTimeZone( string );
|
return TimeZone.getTimeZone( string.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -59,8 +59,8 @@ public class TimeZoneTypeDescriptor extends AbstractClassTypeDescriptor<TimeZone
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ( String.class.isInstance( value ) ) {
|
if ( CharSequence.class.isInstance( value ) ) {
|
||||||
return fromString( (String) value );
|
return fromString( (CharSequence) value );
|
||||||
}
|
}
|
||||||
throw unknownWrap( value.getClass() );
|
throw unknownWrap( value.getClass() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,8 +36,8 @@ public class UUIDTypeDescriptor extends AbstractClassTypeDescriptor<UUID> {
|
||||||
return ToStringTransformer.INSTANCE.transform( value );
|
return ToStringTransformer.INSTANCE.transform( value );
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID fromString(String string) {
|
public UUID fromString(CharSequence string) {
|
||||||
return ToStringTransformer.INSTANCE.parse( string );
|
return ToStringTransformer.INSTANCE.parse( string.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked" })
|
@SuppressWarnings({ "unchecked" })
|
||||||
|
|
|
@ -36,9 +36,9 @@ public class UrlTypeDescriptor extends AbstractClassTypeDescriptor<URL> {
|
||||||
return value.toExternalForm();
|
return value.toExternalForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
public URL fromString(String string) {
|
public URL fromString(CharSequence string) {
|
||||||
try {
|
try {
|
||||||
return new URL( string );
|
return new URL( string.toString() );
|
||||||
}
|
}
|
||||||
catch ( MalformedURLException e ) {
|
catch ( MalformedURLException e ) {
|
||||||
throw new HibernateException( "Unable to convert string [" + string + "] to URL : " + e );
|
throw new HibernateException( "Unable to convert string [" + string + "] to URL : " + e );
|
||||||
|
@ -60,8 +60,8 @@ public class UrlTypeDescriptor extends AbstractClassTypeDescriptor<URL> {
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ( String.class.isInstance( value ) ) {
|
if ( CharSequence.class.isInstance( value ) ) {
|
||||||
return fromString( (String) value );
|
return fromString( (CharSequence) value );
|
||||||
}
|
}
|
||||||
throw unknownWrap( value.getClass() );
|
throw unknownWrap( value.getClass() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,8 +38,8 @@ public class ZoneOffsetJavaDescriptor extends AbstractClassTypeDescriptor<ZoneOf
|
||||||
return value.getId();
|
return value.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZoneOffset fromString(String string) {
|
public ZoneOffset fromString(CharSequence string) {
|
||||||
return ZoneOffset.of( string );
|
return ZoneOffset.of( string.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -69,8 +69,8 @@ public class ZoneOffsetJavaDescriptor extends AbstractClassTypeDescriptor<ZoneOf
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ( String.class.isInstance( value ) ) {
|
if ( CharSequence.class.isInstance( value ) ) {
|
||||||
return fromString( (String) value );
|
return fromString( (CharSequence) value );
|
||||||
}
|
}
|
||||||
throw unknownWrap( value.getClass() );
|
throw unknownWrap( value.getClass() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ public class ZonedDateTimeJavaDescriptor extends AbstractTemporalTypeDescriptor<
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ZonedDateTime fromString(String string) {
|
public ZonedDateTime fromString(CharSequence string) {
|
||||||
return ZonedDateTime.from( DateTimeFormatter.ISO_ZONED_DATE_TIME.parse( string ) );
|
return ZonedDateTime.from( DateTimeFormatter.ISO_ZONED_DATE_TIME.parse( string ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class CollectionJavaTypeDescriptor<C> extends AbstractClassTypeDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public C fromString(String string) {
|
public C fromString(CharSequence string) {
|
||||||
throw new UnsupportedOperationException( );
|
throw new UnsupportedOperationException( );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class DynamicModelJtd implements JavaTypeDescriptor<Map<?,?>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<?,?> fromString(String string) {
|
public Map<?,?> fromString(CharSequence string) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class JavaTypeDescriptorBasicAdaptor<T> extends AbstractClassTypeDescript
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T fromString(String string) {
|
public T fromString(CharSequence string) {
|
||||||
throw new UnsupportedOperationException(
|
throw new UnsupportedOperationException(
|
||||||
"Conversion from String strategy not known for this Java type : " + getJavaType().getTypeName()
|
"Conversion from String strategy not known for this Java type : " + getJavaType().getTypeName()
|
||||||
);
|
);
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class MapEntryJavaDescriptor extends AbstractClassTypeDescriptor<Map.Entr
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map.Entry fromString(String string) {
|
public Map.Entry fromString(CharSequence string) {
|
||||||
throw new UnsupportedOperationException( "Unsupported attempt create Map.Entry from String" );
|
throw new UnsupportedOperationException( "Unsupported attempt create Map.Entry from String" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,7 +133,7 @@ public class UserTypeJavaTypeWrapper<J> implements BasicJavaDescriptor<J> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public J fromString(String string) {
|
public J fromString(CharSequence string) {
|
||||||
throw new UnsupportedOperationException( "No support for parsing UserType values from String: " + userType );
|
throw new UnsupportedOperationException( "No support for parsing UserType values from String: " + userType );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,9 +30,10 @@ public interface EnhancedUserType extends UserType {
|
||||||
* Parse a string representation of this value, as it appears in an XML document
|
* Parse a string representation of this value, as it appears in an XML document
|
||||||
*
|
*
|
||||||
* @deprecated To be removed in 5. Implement
|
* @deprecated To be removed in 5. Implement
|
||||||
* {@link org.hibernate.type.StringRepresentableType#fromStringValue(String)} instead.
|
* {@link org.hibernate.type.StringRepresentableType#fromStringValue(CharSequence)} instead.
|
||||||
* See <a href="https://hibernate.onjira.com/browse/HHH-7776">HHH-7776</a> for details
|
* See <a href="https://hibernate.onjira.com/browse/HHH-7776">HHH-7776</a> for details
|
||||||
|
* @param xmlValue
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
Object fromXMLString(String xmlValue);
|
Object fromXMLString(CharSequence xmlValue);
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,7 @@ public class CollectionAsBasicTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set fromString(String string) {
|
public Set fromString(CharSequence string) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -277,15 +277,15 @@ public class CustomTypeResolutionTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Gender fromString(String string) {
|
public Gender fromString(CharSequence string) {
|
||||||
if ( StringHelper.isEmpty( string ) ) {
|
if ( string == null || string.length() == 0 ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( "M".equalsIgnoreCase( string ) ) {
|
if ( "M".equalsIgnoreCase( string.toString() ) ) {
|
||||||
return Gender.MALE;
|
return Gender.MALE;
|
||||||
}
|
}
|
||||||
else if ( "F".equalsIgnoreCase( string ) ) {
|
else if ( "F".equalsIgnoreCase( string.toString() ) ) {
|
||||||
return Gender.FEMALE;
|
return Gender.FEMALE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -330,8 +330,8 @@ public class ExplicitJavaTypeDescriptorTest extends BaseNonConfigCoreFunctionalT
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PseudoMutableState fromString(String string) {
|
public PseudoMutableState fromString(CharSequence string) {
|
||||||
return string == null ? null : new PseudoMutableState( string );
|
return string == null ? null : new PseudoMutableState( string.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.orm.test.mapping.converted.converter.custom;
|
package org.hibernate.orm.test.mapping.converted.converter.custom;
|
||||||
|
|
||||||
import org.hibernate.internal.util.StringHelper;
|
import org.hibernate.internal.util.CharSequenceHelper;
|
||||||
import org.hibernate.type.descriptor.WrapperOptions;
|
import org.hibernate.type.descriptor.WrapperOptions;
|
||||||
import org.hibernate.type.descriptor.java.BasicJavaDescriptor;
|
import org.hibernate.type.descriptor.java.BasicJavaDescriptor;
|
||||||
import org.hibernate.type.descriptor.java.MutabilityPlan;
|
import org.hibernate.type.descriptor.java.MutabilityPlan;
|
||||||
|
@ -49,8 +49,8 @@ public class MyCustomJavaTypeDescriptor implements BasicJavaDescriptor<MyCustomJ
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MyCustomJavaType fromString(String string) {
|
public MyCustomJavaType fromString(CharSequence string) {
|
||||||
return StringHelper.isEmpty( string ) ? null : new MyCustomJavaType( string );
|
return CharSequenceHelper.isEmpty( string ) ? null : new MyCustomJavaType( string.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -93,7 +93,7 @@ public class JavaTypeDescriptorRegistryTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CustomType fromString(String string) {
|
public CustomType fromString(CharSequence string) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -168,7 +168,7 @@ public class QueryParametersValidationArrayTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] fromString(String string) {
|
public String[] fromString(CharSequence string) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,8 @@ public class ArrayType
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Array stringToObject(String xml) throws Exception {
|
public Array stringToObject(CharSequence sequence) throws Exception {
|
||||||
return fromString( xml );
|
return fromString( sequence );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -31,11 +31,11 @@ public class ArrayTypeDescriptor extends AbstractClassTypeDescriptor<Array> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Array fromString(String string) {
|
public Array fromString(CharSequence string) {
|
||||||
if ( string == null || string.isEmpty() ) {
|
if ( string == null || string.length() == 0 ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String[] tokens = string.split( DELIMITER );
|
String[] tokens = string.toString().split( DELIMITER );
|
||||||
Array array = new Array();
|
Array array = new Array();
|
||||||
array.addAll( Arrays.asList(tokens) );
|
array.addAll( Arrays.asList(tokens) );
|
||||||
return array;
|
return array;
|
||||||
|
|
|
@ -107,8 +107,8 @@ public class StoredPrefixedStringType
|
||||||
return StringType.INSTANCE.objectToSQLString( value, dialect );
|
return StringType.INSTANCE.objectToSQLString( value, dialect );
|
||||||
}
|
}
|
||||||
|
|
||||||
public String stringToObject(String xml) throws Exception {
|
public String stringToObject(CharSequence sequence) throws Exception {
|
||||||
return StringType.INSTANCE.stringToObject( xml );
|
return StringType.INSTANCE.stringToObject( sequence );
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString(String value) {
|
public String toString(String value) {
|
||||||
|
|
|
@ -15,7 +15,6 @@ import java.sql.Types;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.type.IntegerType;
|
|
||||||
import org.hibernate.type.StandardBasicTypes;
|
import org.hibernate.type.StandardBasicTypes;
|
||||||
import org.hibernate.type.descriptor.ValueExtractor;
|
import org.hibernate.type.descriptor.ValueExtractor;
|
||||||
import org.hibernate.type.descriptor.WrapperOptions;
|
import org.hibernate.type.descriptor.WrapperOptions;
|
||||||
|
@ -108,8 +107,8 @@ public class ClassificationType implements EnhancedUserType, ValueExtractor<Clas
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object fromXMLString(String xmlValue) {
|
public Object fromXMLString(CharSequence xmlValue) {
|
||||||
return Classification.valueOf( xmlValue );
|
return Classification.valueOf( xmlValue.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
private String extractName(Object obj) {
|
private String extractName(Object obj) {
|
||||||
|
|
|
@ -24,8 +24,8 @@ public class InetJavaTypeDescriptor extends AbstractClassTypeDescriptor<Inet> {
|
||||||
return value.toString();
|
return value.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Inet fromString(String string) {
|
public Inet fromString(CharSequence string) {
|
||||||
return new Inet( string );
|
return new Inet( string.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -24,8 +24,8 @@ public class JsonJavaTypeDescriptor extends AbstractClassTypeDescriptor<Json> {
|
||||||
return value.toString();
|
return value.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Json fromString(String string) {
|
public Json fromString(CharSequence string) {
|
||||||
return new Json( string );
|
return new Json( string.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -201,8 +201,12 @@ public class LongListTypeContributorTest extends BaseEntityManagerFunctionalTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LongList fromString(String string) {
|
public LongList fromString(CharSequence sequence) {
|
||||||
if ( string == null || "null".equals( string ) ) {
|
if ( sequence == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
final String string = sequence.toString();
|
||||||
|
if ( "null".equals( string ) ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,8 +54,8 @@ public class StandardBasicTypeTemplateTest extends BaseUnitTestCase {
|
||||||
public static final ValidatingUrlJavaTypeDescriptor INSTANCE = new ValidatingUrlJavaTypeDescriptor();
|
public static final ValidatingUrlJavaTypeDescriptor INSTANCE = new ValidatingUrlJavaTypeDescriptor();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URL fromString(String string) {
|
public URL fromString(CharSequence string) {
|
||||||
if ( "invalid".equals( string ) ) {
|
if ( "invalid".equals( string.toString() ) ) {
|
||||||
throw new IllegalStateException( "Invalid url" );
|
throw new IllegalStateException( "Invalid url" );
|
||||||
}
|
}
|
||||||
return super.fromString( string );
|
return super.fromString( string );
|
||||||
|
|
|
@ -45,8 +45,8 @@ public class GeolatteGeometryJavaTypeDescriptor extends AbstractTypeDescriptor<G
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Geometry fromString(String string) {
|
public Geometry fromString(CharSequence string) {
|
||||||
return Wkt.fromWkt( string );
|
return Wkt.fromWkt( string.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -77,8 +77,8 @@ public class GeolatteGeometryJavaTypeDescriptor extends AbstractTypeDescriptor<G
|
||||||
if ( Geometry.class.isInstance( value ) ) {
|
if ( Geometry.class.isInstance( value ) ) {
|
||||||
return (Geometry) value;
|
return (Geometry) value;
|
||||||
}
|
}
|
||||||
if ( String.class.isInstance( value ) ) {
|
if ( CharSequence.class.isInstance( value ) ) {
|
||||||
return fromString( (String) value );
|
return fromString( (CharSequence) value );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( org.locationtech.jts.geom.Geometry.class.isInstance( value ) ) {
|
if ( org.locationtech.jts.geom.Geometry.class.isInstance( value ) ) {
|
||||||
|
|
|
@ -45,10 +45,10 @@ public class JTSGeometryJavaTypeDescriptor extends AbstractTypeDescriptor<Geomet
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Geometry fromString(String string) {
|
public Geometry fromString(CharSequence string) {
|
||||||
final WKTReader reader = new WKTReader();
|
final WKTReader reader = new WKTReader();
|
||||||
try {
|
try {
|
||||||
return reader.read( string );
|
return reader.read( string.toString() );
|
||||||
}
|
}
|
||||||
catch (ParseException e) {
|
catch (ParseException e) {
|
||||||
throw new RuntimeException( String.format( Locale.ENGLISH, "Can't parse string %s as WKT", string ) );
|
throw new RuntimeException( String.format( Locale.ENGLISH, "Can't parse string %s as WKT", string ) );
|
||||||
|
@ -88,8 +88,8 @@ public class JTSGeometryJavaTypeDescriptor extends AbstractTypeDescriptor<Geomet
|
||||||
if ( org.geolatte.geom.Geometry.class.isInstance( value ) ) {
|
if ( org.geolatte.geom.Geometry.class.isInstance( value ) ) {
|
||||||
return JTS.to( (org.geolatte.geom.Geometry) value );
|
return JTS.to( (org.geolatte.geom.Geometry) value );
|
||||||
}
|
}
|
||||||
if ( String.class.isInstance( value ) ) {
|
if ( CharSequence.class.isInstance( value ) ) {
|
||||||
return fromString( (String) value );
|
return fromString( (CharSequence) value );
|
||||||
}
|
}
|
||||||
throw unknownWrap( value.getClass() );
|
throw unknownWrap( value.getClass() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class CommaDelimitedStringMapJavaTypeDescriptor extends AbstractClassType
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map fromString(String string) {
|
public Map fromString(CharSequence string) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue