Moved Convert class to org.jooq.tools
This commit is contained in:
parent
a153f8c25f
commit
e61c97aa7a
@ -47,7 +47,7 @@ import javax.persistence.Column;
|
||||
|
||||
import org.jooq.exception.DataTypeException;
|
||||
import org.jooq.exception.MappingException;
|
||||
import org.jooq.impl.Convert;
|
||||
import org.jooq.tools.Convert;
|
||||
|
||||
/**
|
||||
* A wrapper for database result records returned by
|
||||
|
||||
@ -44,7 +44,7 @@ import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
|
||||
import org.jooq.exception.MappingException;
|
||||
import org.jooq.impl.Convert;
|
||||
import org.jooq.tools.Convert;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
|
||||
@ -42,7 +42,7 @@ import java.sql.Time;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
import org.jooq.exception.DataTypeException;
|
||||
import org.jooq.impl.Convert;
|
||||
import org.jooq.tools.Convert;
|
||||
|
||||
/**
|
||||
* A common base type for {@link Record} and {@link ArrayRecord} providing
|
||||
|
||||
@ -56,6 +56,7 @@ import org.jooq.Result;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.UDTRecord;
|
||||
import org.jooq.exception.SQLDialectNotSupportedException;
|
||||
import org.jooq.tools.Convert;
|
||||
|
||||
/**
|
||||
* A common base class for data types.
|
||||
|
||||
@ -64,6 +64,7 @@ import org.jooq.RenderContext;
|
||||
import org.jooq.Select;
|
||||
import org.jooq.SortField;
|
||||
import org.jooq.SortOrder;
|
||||
import org.jooq.tools.Convert;
|
||||
|
||||
abstract class AbstractField<T> extends AbstractNamedTypeProviderQueryPart<T> implements Field<T> {
|
||||
|
||||
|
||||
@ -64,6 +64,7 @@ import org.jooq.Record;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.TableRecord;
|
||||
import org.jooq.exception.MappingException;
|
||||
import org.jooq.tools.Convert;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
|
||||
@ -66,6 +66,7 @@ import org.jooq.Table;
|
||||
import org.jooq.TableRecord;
|
||||
import org.jooq.exception.DataAccessException;
|
||||
import org.jooq.exception.InvalidResultException;
|
||||
import org.jooq.tools.Convert;
|
||||
|
||||
/**
|
||||
* A query that returns a {@link Result}
|
||||
|
||||
@ -64,6 +64,7 @@ import org.jooq.SQLDialect;
|
||||
import org.jooq.Schema;
|
||||
import org.jooq.UDTField;
|
||||
import org.jooq.UDTRecord;
|
||||
import org.jooq.tools.Convert;
|
||||
import org.jooq.tools.JooqLogger;
|
||||
import org.jooq.tools.StopWatch;
|
||||
|
||||
|
||||
@ -44,6 +44,7 @@ import java.sql.Timestamp;
|
||||
import org.jooq.AttachableInternal;
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Store;
|
||||
import org.jooq.tools.Convert;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
|
||||
@ -49,6 +49,7 @@ import org.jooq.Configuration;
|
||||
import org.jooq.DataType;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.exception.SQLDialectNotSupportedException;
|
||||
import org.jooq.tools.Convert;
|
||||
import org.jooq.util.oracle.OracleUtils;
|
||||
|
||||
/**
|
||||
|
||||
@ -72,6 +72,7 @@ import org.jooq.Result;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.UDTRecord;
|
||||
import org.jooq.exception.SQLDialectNotSupportedException;
|
||||
import org.jooq.tools.Convert;
|
||||
import org.jooq.tools.JooqLogger;
|
||||
import org.jooq.util.ase.ASEDataType;
|
||||
import org.jooq.util.db2.DB2DataType;
|
||||
|
||||
@ -73,6 +73,7 @@ import org.jooq.Result;
|
||||
import org.jooq.Store;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.TableRecord;
|
||||
import org.jooq.tools.Convert;
|
||||
import org.jooq.tools.StringUtils;
|
||||
import org.jooq.tools.json.JSONObject;
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
package org.jooq.tools;
|
||||
|
||||
import static org.joou.Unsigned.ubyte;
|
||||
import static org.joou.Unsigned.uint;
|
||||
@ -49,6 +49,7 @@ import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@ -67,40 +68,58 @@ import org.joou.UShort;
|
||||
*/
|
||||
public final class Convert {
|
||||
|
||||
static final Set<String> TRUE_VALUES;
|
||||
static final Set<String> FALSE_VALUES;
|
||||
public static final Set<String> TRUE_VALUES;
|
||||
public static final Set<String> FALSE_VALUES;
|
||||
|
||||
static {
|
||||
TRUE_VALUES = new HashSet<String>();
|
||||
FALSE_VALUES = new HashSet<String>();
|
||||
Set<String> trueValues = new HashSet<String>();
|
||||
Set<String> falseValues = new HashSet<String>();
|
||||
|
||||
TRUE_VALUES.add("1");
|
||||
TRUE_VALUES.add("y");
|
||||
TRUE_VALUES.add("Y");
|
||||
TRUE_VALUES.add("yes");
|
||||
TRUE_VALUES.add("YES");
|
||||
TRUE_VALUES.add("true");
|
||||
TRUE_VALUES.add("TRUE");
|
||||
TRUE_VALUES.add("on");
|
||||
TRUE_VALUES.add("ON");
|
||||
TRUE_VALUES.add("enabled");
|
||||
TRUE_VALUES.add("ENABLED");
|
||||
trueValues.add("1");
|
||||
trueValues.add("y");
|
||||
trueValues.add("Y");
|
||||
trueValues.add("yes");
|
||||
trueValues.add("YES");
|
||||
trueValues.add("true");
|
||||
trueValues.add("TRUE");
|
||||
trueValues.add("on");
|
||||
trueValues.add("ON");
|
||||
trueValues.add("enabled");
|
||||
trueValues.add("ENABLED");
|
||||
|
||||
FALSE_VALUES.add("0");
|
||||
FALSE_VALUES.add("n");
|
||||
FALSE_VALUES.add("N");
|
||||
FALSE_VALUES.add("no");
|
||||
FALSE_VALUES.add("NO");
|
||||
FALSE_VALUES.add("false");
|
||||
FALSE_VALUES.add("FALSE");
|
||||
FALSE_VALUES.add("off");
|
||||
FALSE_VALUES.add("OFF");
|
||||
FALSE_VALUES.add("disabled");
|
||||
FALSE_VALUES.add("DISABLED");
|
||||
falseValues.add("0");
|
||||
falseValues.add("n");
|
||||
falseValues.add("N");
|
||||
falseValues.add("no");
|
||||
falseValues.add("NO");
|
||||
falseValues.add("false");
|
||||
falseValues.add("FALSE");
|
||||
falseValues.add("off");
|
||||
falseValues.add("OFF");
|
||||
falseValues.add("disabled");
|
||||
falseValues.add("DISABLED");
|
||||
|
||||
TRUE_VALUES = Collections.unmodifiableSet(trueValues);
|
||||
FALSE_VALUES = Collections.unmodifiableSet(falseValues);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an array into another one by these rules
|
||||
* <p>
|
||||
* <ul>
|
||||
* <li>If <code>toClass</code> is not an array class, then make it an array
|
||||
* class first</li>
|
||||
* <li>If <code>toClass</code> is an array class, then create an instance
|
||||
* from it, and convert all elements in the <code>from</code> array one by
|
||||
* one, using {@link #convert(Object, Class)}</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param from The array to convert
|
||||
* @param toClass The target array type
|
||||
* @return A converted array
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
static Object[] convertArray(Object[] from, Class<?> toClass) {
|
||||
public static Object[] convertArray(Object[] from, Class<?> toClass) {
|
||||
if (from == null) {
|
||||
return null;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user