HHH-5283 - Add BasicType handling of java.net.URL
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@20022 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
d10415dafe
commit
c508fd2652
|
@ -63,6 +63,7 @@ public class BasicTypeRegistry implements Serializable {
|
|||
register( BigIntegerType.INSTANCE );
|
||||
|
||||
register( StringType.INSTANCE );
|
||||
register( UrlType.INSTANCE );
|
||||
|
||||
register( DateType.INSTANCE );
|
||||
register( TimeType.INSTANCE );
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.type;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.type.descriptor.java.UrlTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.sql.VarcharTypeDescriptor;
|
||||
|
||||
/**
|
||||
* A type that maps between {@link java.sql.Types#VARCHAR VARCHAR} and {@link URL}
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class UrlType extends AbstractSingleColumnStandardBasicType<URL> implements DiscriminatorType<URL> {
|
||||
public static final UrlType INSTANCE = new UrlType();
|
||||
|
||||
public UrlType() {
|
||||
super( VarcharTypeDescriptor.INSTANCE, UrlTypeDescriptor.INSTANCE );
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "url";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean registerUnderJavaType() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(URL value) {
|
||||
return UrlTypeDescriptor.INSTANCE.toString( value );
|
||||
}
|
||||
|
||||
public String objectToSQLString(URL value, Dialect dialect) throws Exception {
|
||||
return StringType.INSTANCE.objectToSQLString( toString( value ), dialect );
|
||||
}
|
||||
|
||||
public URL stringToObject(String xml) throws Exception {
|
||||
return UrlTypeDescriptor.INSTANCE.fromString( xml );
|
||||
}
|
||||
}
|
|
@ -452,6 +452,23 @@
|
|||
</varlistentry>
|
||||
</variablelist>
|
||||
</section>
|
||||
<section id="types-basic-value-url">
|
||||
<title><classname>java.net.URL</classname></title>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><classname>org.hibernate.type.UrlType</classname></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Maps a <classname>java.net.URL</classname> to a JDBC VARCHAR (using the external form)
|
||||
</para>
|
||||
<para>
|
||||
Registered under <literal>url</literal> and <literal>java.net.URL</literal> in the
|
||||
type registry (see <xref linkend="types-registry"/>).
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</section>
|
||||
<section id="types-basic-value-class">
|
||||
<title><classname>java.lang.Class</classname></title>
|
||||
<variablelist>
|
||||
|
|
Loading…
Reference in New Issue