Author: shawkins
Date: 2009-08-25 15:40:43 -0400 (Tue, 25 Aug 2009)
New Revision: 1278
Added:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FixedNumberToBigDecimalTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FixedNumberToBigIntegerTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatingNumberToBigDecimalTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatingNumberToBigIntegerTransform.java
Removed:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/BigDecimalToStringTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/BigIntegerToStringTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/BooleanToStringTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ByteToBigDecimalTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ByteToBigIntegerTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ByteToStringTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/CharacterToStringTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/DateToStringTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/DoubleToBigDecimalTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/DoubleToBigIntegerTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/DoubleToStringTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatToBigDecimalTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatToBigIntegerTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatToStringTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/IntegerToBigDecimalTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/IntegerToBigIntegerTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/IntegerToStringTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/LongToBigDecimalTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/LongToBigIntegerTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/LongToStringTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ShortToBigDecimalTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ShortToBigIntegerTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ShortToStringTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/TimeToStringTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/TimestampToStringTransform.java
Modified:
trunk/common-core/src/main/java/com/metamatrix/common/types/DataTypeManager.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/AnyToStringTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ClobToStringTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/SQLXMLToStringTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToBooleanTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToCharacterTransform.java
trunk/common-core/src/main/resources/com/metamatrix/core/i18n.properties
trunk/common-core/src/test/java/com/metamatrix/common/types/basic/TestTransforms.java
trunk/documentation/reference/src/main/docbook/en-US/content/datatypes.xml
trunk/documentation/reference/src/main/docbook/en-US/content/grammar.xml
trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMethods.java
trunk/engine/src/main/java/com/metamatrix/query/parser/QueryParser.java
trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/SQLStringVisitor.java
trunk/engine/src/main/javacc/com/metamatrix/query/parser/SQLParser.jj
trunk/engine/src/test/java/com/metamatrix/query/function/TestFunction.java
trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionDescriptorImpl.java
trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java
Log:
TEIID-800 TEIID-799 TEIID-798 TEIID-797 updating the parser and conversion to support
unknown keyword for booleans, adding better handling of char/boolean types, and changing
the parser to use use common conversion logic for escaped literals.
Modified:
trunk/common-core/src/main/java/com/metamatrix/common/types/DataTypeManager.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/DataTypeManager.java 2009-08-25
19:38:18 UTC (rev 1277)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/DataTypeManager.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -42,7 +42,12 @@
import javax.xml.transform.stream.StreamSource;
import com.metamatrix.common.types.basic.AnyToObjectTransform;
+import com.metamatrix.common.types.basic.AnyToStringTransform;
import com.metamatrix.common.types.basic.BooleanToNumberTransform;
+import com.metamatrix.common.types.basic.FloatingNumberToBigDecimalTransform;
+import com.metamatrix.common.types.basic.FloatingNumberToBigIntegerTransform;
+import com.metamatrix.common.types.basic.FixedNumberToBigDecimalTransform;
+import com.metamatrix.common.types.basic.FixedNumberToBigIntegerTransform;
import com.metamatrix.common.types.basic.NullToAnyTransform;
import com.metamatrix.common.types.basic.NumberToBooleanTransform;
import com.metamatrix.common.types.basic.NumberToByteTransform;
@@ -587,8 +592,7 @@
DefaultDataClasses.BIG_DECIMAL, true));
DataTypeManager.addTransform(new NumberToShortTransform(
DefaultDataClasses.BIG_DECIMAL, true));
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.BigDecimalToStringTransform());
+ DataTypeManager.addTransform(new
AnyToStringTransform(DefaultDataClasses.BIG_DECIMAL));
DataTypeManager
.addTransform(new
com.metamatrix.common.types.basic.BigIntegerToBigDecimalTransform());
@@ -605,8 +609,7 @@
DefaultDataClasses.BIG_INTEGER, true));
DataTypeManager.addTransform(new NumberToShortTransform(
DefaultDataClasses.BIG_INTEGER, true));
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.BigIntegerToStringTransform());
+ DataTypeManager.addTransform(new
AnyToStringTransform(DefaultDataClasses.BIG_INTEGER));
DataTypeManager
.addTransform(new BooleanToNumberTransform(BigDecimal.valueOf(1),
BigDecimal.valueOf(0)));
@@ -624,13 +627,10 @@
.addTransform(new BooleanToNumberTransform(Short.valueOf((short)1),
Short.valueOf((short)0)));
DataTypeManager
.addTransform(new BooleanToNumberTransform(Byte.valueOf((byte)1),
Byte.valueOf((byte)0)));
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.BooleanToStringTransform());
+ DataTypeManager.addTransform(new AnyToStringTransform(DefaultDataClasses.BOOLEAN));
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.ByteToBigDecimalTransform());
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.ByteToBigIntegerTransform());
+ DataTypeManager.addTransform(new
FixedNumberToBigDecimalTransform(DefaultDataClasses.BYTE));
+ DataTypeManager.addTransform(new
FixedNumberToBigIntegerTransform(DefaultDataClasses.BYTE));
DataTypeManager.addTransform(new NumberToBooleanTransform(Byte.valueOf((byte)1),
Byte.valueOf((byte)0)));
DataTypeManager.addTransform(new NumberToDoubleTransform(
DefaultDataClasses.BYTE, false));
@@ -642,24 +642,19 @@
DefaultDataClasses.BYTE, false));
DataTypeManager.addTransform(new NumberToShortTransform(
DefaultDataClasses.BYTE, false));
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.ByteToStringTransform());
+ DataTypeManager.addTransform(new AnyToStringTransform(DefaultDataClasses.BYTE));
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.CharacterToStringTransform());
+ DataTypeManager.addTransform(new AnyToStringTransform(DefaultDataClasses.CHAR));
DataTypeManager
.addTransform(new com.metamatrix.common.types.basic.ClobToStringTransform());
+ DataTypeManager.addTransform(new AnyToStringTransform(DefaultDataClasses.DATE));
DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.DateToStringTransform());
- DataTypeManager
.addTransform(new com.metamatrix.common.types.basic.DateToTimestampTransform());
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.DoubleToBigDecimalTransform());
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.DoubleToBigIntegerTransform());
+ DataTypeManager.addTransform(new
FloatingNumberToBigDecimalTransform(DefaultDataClasses.DOUBLE));
+ DataTypeManager.addTransform(new
FloatingNumberToBigIntegerTransform(DefaultDataClasses.DOUBLE));
DataTypeManager.addTransform(new NumberToBooleanTransform(Double.valueOf(1),
Double.valueOf(0)));
DataTypeManager.addTransform(new NumberToByteTransform(
DefaultDataClasses.DOUBLE));
@@ -671,13 +666,10 @@
DefaultDataClasses.DOUBLE, true));
DataTypeManager.addTransform(new NumberToShortTransform(
DefaultDataClasses.DOUBLE, true));
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.DoubleToStringTransform());
+ DataTypeManager.addTransform(new AnyToStringTransform(DefaultDataClasses.DOUBLE));
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.FloatToBigDecimalTransform());
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.FloatToBigIntegerTransform());
+ DataTypeManager.addTransform(new
FloatingNumberToBigDecimalTransform(DefaultDataClasses.FLOAT));
+ DataTypeManager.addTransform(new
FloatingNumberToBigIntegerTransform(DefaultDataClasses.FLOAT));
DataTypeManager.addTransform(new NumberToBooleanTransform(Float.valueOf(1),
Float.valueOf(0)));
DataTypeManager.addTransform(new NumberToByteTransform(
DefaultDataClasses.FLOAT));
@@ -689,13 +681,10 @@
DefaultDataClasses.FLOAT, true));
DataTypeManager.addTransform(new NumberToShortTransform(
DefaultDataClasses.FLOAT, true));
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.FloatToStringTransform());
+ DataTypeManager.addTransform(new AnyToStringTransform(DefaultDataClasses.FLOAT));
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.IntegerToBigDecimalTransform());
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.IntegerToBigIntegerTransform());
+ DataTypeManager.addTransform(new
FixedNumberToBigDecimalTransform(DefaultDataClasses.INTEGER));
+ DataTypeManager.addTransform(new
FixedNumberToBigIntegerTransform(DefaultDataClasses.INTEGER));
DataTypeManager.addTransform(new NumberToBooleanTransform(Integer.valueOf(1),
Integer.valueOf(0)));
DataTypeManager.addTransform(new NumberToByteTransform(
DefaultDataClasses.INTEGER));
@@ -707,13 +696,10 @@
DefaultDataClasses.INTEGER, false));
DataTypeManager.addTransform(new NumberToShortTransform(
DefaultDataClasses.INTEGER, true));
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.IntegerToStringTransform());
+ DataTypeManager.addTransform(new AnyToStringTransform(DefaultDataClasses.INTEGER));
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.LongToBigDecimalTransform());
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.LongToBigIntegerTransform());
+ DataTypeManager.addTransform(new
FixedNumberToBigDecimalTransform(DefaultDataClasses.LONG));
+ DataTypeManager.addTransform(new
FixedNumberToBigIntegerTransform(DefaultDataClasses.LONG));
DataTypeManager.addTransform(new NumberToBooleanTransform(Long.valueOf(1),
Long.valueOf(0)));
DataTypeManager.addTransform(new NumberToByteTransform(
DefaultDataClasses.LONG));
@@ -725,13 +711,10 @@
DefaultDataClasses.LONG, true));
DataTypeManager.addTransform(new NumberToShortTransform(
DefaultDataClasses.LONG, true));
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.LongToStringTransform());
+ DataTypeManager.addTransform(new AnyToStringTransform(DefaultDataClasses.LONG));
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.ShortToBigDecimalTransform());
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.ShortToBigIntegerTransform());
+ DataTypeManager.addTransform(new
FixedNumberToBigDecimalTransform(DefaultDataClasses.SHORT));
+ DataTypeManager.addTransform(new
FixedNumberToBigIntegerTransform(DefaultDataClasses.SHORT));
DataTypeManager.addTransform(new NumberToBooleanTransform(Short.valueOf((short)1),
Short.valueOf((short)0)));
DataTypeManager.addTransform(new NumberToByteTransform(
DefaultDataClasses.SHORT));
@@ -743,8 +726,7 @@
DefaultDataClasses.SHORT, false));
DataTypeManager.addTransform(new NumberToLongTransform(
DefaultDataClasses.SHORT, false));
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.ShortToStringTransform());
+ DataTypeManager.addTransform(new AnyToStringTransform(DefaultDataClasses.SHORT));
DataTypeManager
.addTransform(new com.metamatrix.common.types.basic.StringToBigDecimalTransform());
@@ -782,15 +764,13 @@
DataTypeManager
.addTransform(new com.metamatrix.common.types.basic.TimestampToDateTransform());
+ DataTypeManager.addTransform(new AnyToStringTransform(DefaultDataClasses.TIMESTAMP));
DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.TimestampToStringTransform());
- DataTypeManager
.addTransform(new com.metamatrix.common.types.basic.TimestampToTimeTransform());
DataTypeManager
.addTransform(new com.metamatrix.common.types.basic.TimeToTimestampTransform());
- DataTypeManager
- .addTransform(new com.metamatrix.common.types.basic.TimeToStringTransform());
+ DataTypeManager.addTransform(new AnyToStringTransform(DefaultDataClasses.TIME));
for (Class<?> type : getAllDataTypeClasses()) {
if (type != DefaultDataClasses.OBJECT) {
Modified:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/AnyToStringTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/AnyToStringTransform.java 2009-08-25
19:38:18 UTC (rev 1277)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/AnyToStringTransform.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -28,19 +28,27 @@
* This class can be subclassed to do a simple anything-->String by
* just calling toString(). Just extend and implement getSouceType().
*/
-public abstract class AnyToStringTransform extends AbstractTransform {
+public class AnyToStringTransform extends AbstractTransform {
+ private Class<?> sourceType;
+
+ public AnyToStringTransform(Class<?> sourceType) {
+ this.sourceType = sourceType;
+ }
+
/**
* Type of the incoming value.
* @return Source type
*/
- public abstract Class getSourceType();
+ public Class<?> getSourceType() {
+ return sourceType;
+ }
/**
* Type of the outgoing value.
* @return Target type
*/
- public Class getTargetType() {
+ public Class<?> getTargetType() {
return String.class;
}
Deleted:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/BigDecimalToStringTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/BigDecimalToStringTransform.java 2009-08-25
19:38:18 UTC (rev 1277)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/BigDecimalToStringTransform.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-import java.math.BigDecimal;
-
-public class BigDecimalToStringTransform extends AnyToStringTransform {
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return BigDecimal.class;
- }
-}
Deleted:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/BigIntegerToStringTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/BigIntegerToStringTransform.java 2009-08-25
19:38:18 UTC (rev 1277)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/BigIntegerToStringTransform.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-import java.math.BigInteger;
-
-public class BigIntegerToStringTransform extends AnyToStringTransform {
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return BigInteger.class;
- }
-}
Deleted:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/BooleanToStringTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/BooleanToStringTransform.java 2009-08-25
19:38:18 UTC (rev 1277)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/BooleanToStringTransform.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-
-
-public class BooleanToStringTransform extends AnyToStringTransform {
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Boolean.class;
- }
-}
Deleted:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ByteToBigDecimalTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ByteToBigDecimalTransform.java 2009-08-25
19:38:18 UTC (rev 1277)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ByteToBigDecimalTransform.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-import java.math.BigDecimal;
-
-import com.metamatrix.common.types.AbstractTransform;
-import com.metamatrix.common.types.TransformationException;
-
-public class ByteToBigDecimalTransform extends AbstractTransform {
-
- /**
- * This method transforms a value of the source type into a value
- * of the target type.
- * @param value Incoming value of source type
- * @return Outgoing value of target type
- * @throws TransformationException if value is an incorrect input type or
- * the transformation fails
- */
- public Object transform(Object value) throws TransformationException {
- if(value == null) {
- return value;
- }
-
- return BigDecimal.valueOf((Byte) value);
- }
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Byte.class;
- }
-
- /**
- * Type of the outgoing value.
- * @return Target type
- */
- public Class getTargetType() {
- return BigDecimal.class;
- }
-
-}
Deleted:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ByteToBigIntegerTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ByteToBigIntegerTransform.java 2009-08-25
19:38:18 UTC (rev 1277)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ByteToBigIntegerTransform.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-import java.math.BigInteger;
-
-import com.metamatrix.common.types.AbstractTransform;
-import com.metamatrix.common.types.TransformationException;
-
-public class ByteToBigIntegerTransform extends AbstractTransform {
-
- /**
- * This method transforms a value of the source type into a value
- * of the target type.
- * @param value Incoming value of source type
- * @return Outgoing value of target type
- * @throws TransformationException if value is an incorrect input type or
- * the transformation fails
- */
- public Object transform(Object value) throws TransformationException {
- if(value == null) {
- return value;
- }
-
- return BigInteger.valueOf((Byte)value);
- }
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Byte.class;
- }
-
- /**
- * Type of the outgoing value.
- * @return Target type
- */
- public Class getTargetType() {
- return BigInteger.class;
- }
-
-}
Deleted:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ByteToStringTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ByteToStringTransform.java 2009-08-25
19:38:18 UTC (rev 1277)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ByteToStringTransform.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-
-
-public class ByteToStringTransform extends AnyToStringTransform {
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Byte.class;
- }
-}
Deleted:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/CharacterToStringTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/CharacterToStringTransform.java 2009-08-25
19:38:18 UTC (rev 1277)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/CharacterToStringTransform.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-
-
-public class CharacterToStringTransform extends AnyToStringTransform {
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Character.class;
- }
-}
Modified:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ClobToStringTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ClobToStringTransform.java 2009-08-25
19:38:18 UTC (rev 1277)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ClobToStringTransform.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -29,10 +29,15 @@
import com.metamatrix.common.types.ClobType;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.common.types.TransformationException;
+import com.metamatrix.common.types.DataTypeManager.DefaultDataClasses;
import com.metamatrix.core.CorePlugin;
public class ClobToStringTransform extends AnyToStringTransform {
+ public ClobToStringTransform() {
+ super(DefaultDataClasses.CLOB);
+ }
+
/**
* This method transforms a value of the source type into a value
* of the target type.
@@ -67,14 +72,6 @@
}
}
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return ClobType.class;
- }
-
/**
* @see com.metamatrix.common.types.AbstractTransform#isNarrowing()
*/
Deleted:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/DateToStringTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/DateToStringTransform.java 2009-08-25
19:38:18 UTC (rev 1277)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/DateToStringTransform.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-import java.sql.Date;
-
-public class DateToStringTransform extends AnyToStringTransform {
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Date.class;
- }
-}
Deleted:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/DoubleToBigDecimalTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/DoubleToBigDecimalTransform.java 2009-08-25
19:38:18 UTC (rev 1277)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/DoubleToBigDecimalTransform.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-import java.math.BigDecimal;
-
-import com.metamatrix.common.types.AbstractTransform;
-import com.metamatrix.common.types.TransformationException;
-
-public class DoubleToBigDecimalTransform extends AbstractTransform {
-
- /**
- * This method transforms a value of the source type into a value
- * of the target type.
- * @param value Incoming value of source type
- * @return Outgoing value of target type
- * @throws TransformationException if value is an incorrect input type or
- * the transformation fails
- */
- public Object transform(Object value) throws TransformationException {
- if(value == null) {
- return value;
- }
-
- return BigDecimal.valueOf((Double)value);
- }
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Double.class;
- }
-
- /**
- * Type of the outgoing value.
- * @return Target type
- */
- public Class getTargetType() {
- return BigDecimal.class;
- }
-
-}
Deleted:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/DoubleToBigIntegerTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/DoubleToBigIntegerTransform.java 2009-08-25
19:38:18 UTC (rev 1277)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/DoubleToBigIntegerTransform.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -1,78 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-import java.math.BigInteger;
-
-import com.metamatrix.common.types.AbstractTransform;
-import com.metamatrix.common.types.TransformationException;
-
-public class DoubleToBigIntegerTransform extends AbstractTransform {
-
- /**
- * This method transforms a value of the source type into a value
- * of the target type.
- * @param value Incoming value of source type
- * @return Outgoing value of target type
- * @throws TransformationException if value is an incorrect input type or
- * the transformation fails
- */
- public Object transform(Object value) throws TransformationException {
- if(value == null) {
- return value;
- }
-
- String doubleString = value.toString();
- int index = doubleString.lastIndexOf("."); //$NON-NLS-1$
- if(index >= 0) {
- return new BigInteger(doubleString.substring(0, index));
- }
- return new BigInteger(doubleString);
- }
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Double.class;
- }
-
- /**
- * Type of the outgoing value.
- * @return Target type
- */
- public Class getTargetType() {
- return BigInteger.class;
- }
-
- /**
- * Flag if the transformation from source to target is
- * a narrowing transformation that may lose information.
- * @return True - this transformation is narrowing
- */
- public boolean isNarrowing() {
- return true;
- }
-
-}
Deleted:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/DoubleToStringTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/DoubleToStringTransform.java 2009-08-25
19:38:18 UTC (rev 1277)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/DoubleToStringTransform.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-
-
-public class DoubleToStringTransform extends AnyToStringTransform {
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Double.class;
- }
-}
Copied:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FixedNumberToBigDecimalTransform.java
(from rev 1276,
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ShortToBigDecimalTransform.java)
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FixedNumberToBigDecimalTransform.java
(rev 0)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FixedNumberToBigDecimalTransform.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.common.types.basic;
+
+import java.math.BigDecimal;
+
+import com.metamatrix.common.types.AbstractTransform;
+import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.common.types.TransformationException;
+
+public class FixedNumberToBigDecimalTransform extends AbstractTransform {
+
+ private Class<?> sourceType;
+
+ public FixedNumberToBigDecimalTransform(Class<?> sourceType) {
+ this.sourceType = sourceType;
+ }
+
+ /**
+ * This method transforms a value of the source type into a value
+ * of the target type.
+ * @param value Incoming value of source type
+ * @return Outgoing value of target type
+ * @throws TransformationException if value is an incorrect input type or
+ * the transformation fails
+ */
+ public Object transform(Object value) throws TransformationException {
+ if(value == null) {
+ return value;
+ }
+
+ return BigDecimal.valueOf(((Number)value).longValue());
+ }
+
+ /**
+ * Type of the incoming value.
+ * @return Source type
+ */
+ public Class<?> getSourceType() {
+ return sourceType;
+ }
+
+ /**
+ * Type of the outgoing value.
+ * @return Target type
+ */
+ public Class<?> getTargetType() {
+ return DataTypeManager.DefaultDataClasses.BIG_DECIMAL;
+ }
+
+}
Copied:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FixedNumberToBigIntegerTransform.java
(from rev 1276,
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ShortToBigIntegerTransform.java)
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FixedNumberToBigIntegerTransform.java
(rev 0)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FixedNumberToBigIntegerTransform.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.common.types.basic;
+
+import java.math.BigInteger;
+
+import com.metamatrix.common.types.AbstractTransform;
+import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.common.types.TransformationException;
+
+public class FixedNumberToBigIntegerTransform extends AbstractTransform {
+
+ private Class<?> sourceType;
+
+ public FixedNumberToBigIntegerTransform(Class<?> sourceType) {
+ this.sourceType = sourceType;
+ }
+
+ /**
+ * This method transforms a value of the source type into a value
+ * of the target type.
+ * @param value Incoming value of source type
+ * @return Outgoing value of target type
+ * @throws TransformationException if value is an incorrect input type or
+ * the transformation fails
+ */
+ public Object transform(Object value) throws TransformationException {
+ if(value == null) {
+ return value;
+ }
+
+ return BigInteger.valueOf(((Number)value).longValue());
+ }
+
+ /**
+ * Type of the incoming value.
+ * @return Source type
+ */
+ public Class<?> getSourceType() {
+ return sourceType;
+ }
+
+ /**
+ * Type of the outgoing value.
+ * @return Target type
+ */
+ public Class<?> getTargetType() {
+ return DataTypeManager.DefaultDataClasses.BIG_INTEGER;
+ }
+
+}
Deleted:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatToBigDecimalTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatToBigDecimalTransform.java 2009-08-25
19:38:18 UTC (rev 1277)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatToBigDecimalTransform.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-import java.math.BigDecimal;
-
-import com.metamatrix.common.types.AbstractTransform;
-import com.metamatrix.common.types.TransformationException;
-
-public class FloatToBigDecimalTransform extends AbstractTransform {
-
- /**
- * This method transforms a value of the source type into a value
- * of the target type.
- * @param value Incoming value of source type
- * @return Outgoing value of target type
- * @throws TransformationException if value is an incorrect input type or
- * the transformation fails
- */
- public Object transform(Object value) throws TransformationException {
- if(value == null) {
- return value;
- }
-
- return BigDecimal.valueOf((Float)value);
- }
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Float.class;
- }
-
- /**
- * Type of the outgoing value.
- * @return Target type
- */
- public Class getTargetType() {
- return BigDecimal.class;
- }
-
-}
Deleted:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatToBigIntegerTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatToBigIntegerTransform.java 2009-08-25
19:38:18 UTC (rev 1277)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatToBigIntegerTransform.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -1,78 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-import java.math.BigInteger;
-
-import com.metamatrix.common.types.AbstractTransform;
-import com.metamatrix.common.types.TransformationException;
-
-public class FloatToBigIntegerTransform extends AbstractTransform {
-
- /**
- * This method transforms a value of the source type into a value
- * of the target type.
- * @param value Incoming value of source type
- * @return Outgoing value of target type
- * @throws TransformationException if value is an incorrect input type or
- * the transformation fails
- */
- public Object transform(Object value) throws TransformationException {
- if(value == null) {
- return value;
- }
-
- String floatString = value.toString();
- int index = floatString.lastIndexOf("."); //$NON-NLS-1$
- if(index >= 0) {
- return new BigInteger(floatString.substring(0, index));
- }
- return new BigInteger(floatString);
- }
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Float.class;
- }
-
- /**
- * Type of the outgoing value.
- * @return Target type
- */
- public Class getTargetType() {
- return BigInteger.class;
- }
-
- /**
- * Flag if the transformation from source to target is
- * a narrowing transformation that may lose information.
- * @return True - this transformation is narrowing
- */
- public boolean isNarrowing() {
- return true;
- }
-
-}
Deleted:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatToStringTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatToStringTransform.java 2009-08-25
19:38:18 UTC (rev 1277)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatToStringTransform.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-
-
-public class FloatToStringTransform extends AnyToStringTransform {
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Float.class;
- }
-}
Copied:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatingNumberToBigDecimalTransform.java
(from rev 1276,
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/DoubleToBigDecimalTransform.java)
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatingNumberToBigDecimalTransform.java
(rev 0)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatingNumberToBigDecimalTransform.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.common.types.basic;
+
+import java.math.BigDecimal;
+
+import com.metamatrix.common.types.AbstractTransform;
+import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.common.types.TransformationException;
+
+public class FloatingNumberToBigDecimalTransform extends AbstractTransform {
+
+ private Class<?> sourceType;
+
+ public FloatingNumberToBigDecimalTransform(Class<?> sourceType) {
+ this.sourceType = sourceType;
+ }
+
+ /**
+ * This method transforms a value of the source type into a value
+ * of the target type.
+ * @param value Incoming value of source type
+ * @return Outgoing value of target type
+ * @throws TransformationException if value is an incorrect input type or
+ * the transformation fails
+ */
+ public Object transform(Object value) throws TransformationException {
+ if(value == null) {
+ return value;
+ }
+
+ return BigDecimal.valueOf(((Number)value).doubleValue());
+ }
+
+ /**
+ * Type of the incoming value.
+ * @return Source type
+ */
+ public Class<?> getSourceType() {
+ return sourceType;
+ }
+
+ /**
+ * Type of the outgoing value.
+ * @return Target type
+ */
+ public Class<?> getTargetType() {
+ return DataTypeManager.DefaultDataClasses.BIG_DECIMAL;
+ }
+
+}
Copied:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatingNumberToBigIntegerTransform.java
(from rev 1276,
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/DoubleToBigIntegerTransform.java)
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatingNumberToBigIntegerTransform.java
(rev 0)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/FloatingNumberToBigIntegerTransform.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.common.types.basic;
+
+import java.math.BigInteger;
+
+import com.metamatrix.common.types.AbstractTransform;
+import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.common.types.TransformationException;
+
+public class FloatingNumberToBigIntegerTransform extends AbstractTransform {
+
+ private Class<?> sourceType;
+
+ public FloatingNumberToBigIntegerTransform(Class<?> sourceType) {
+ this.sourceType = sourceType;
+ }
+
+ /**
+ * This method transforms a value of the source type into a value
+ * of the target type.
+ * @param value Incoming value of source type
+ * @return Outgoing value of target type
+ * @throws TransformationException if value is an incorrect input type or
+ * the transformation fails
+ */
+ public Object transform(Object value) throws TransformationException {
+ if(value == null) {
+ return value;
+ }
+
+ String doubleString = String.valueOf(value);
+ int index = doubleString.lastIndexOf("."); //$NON-NLS-1$
+ if(index >= 0) {
+ return new BigInteger(doubleString.substring(0, index));
+ }
+ return new BigInteger(doubleString);
+ }
+
+ /**
+ * Type of the incoming value.
+ * @return Source type
+ */
+ public Class getSourceType() {
+ return sourceType;
+ }
+
+ /**
+ * Type of the outgoing value.
+ * @return Target type
+ */
+ public Class getTargetType() {
+ return DataTypeManager.DefaultDataClasses.BIG_INTEGER;
+ }
+
+ /**
+ * Flag if the transformation from source to target is
+ * a narrowing transformation that may lose information.
+ * @return True - this transformation is narrowing
+ */
+ public boolean isNarrowing() {
+ return true;
+ }
+
+}
Deleted:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/IntegerToBigDecimalTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/IntegerToBigDecimalTransform.java 2009-08-25
19:38:18 UTC (rev 1277)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/IntegerToBigDecimalTransform.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-import java.math.BigDecimal;
-
-import com.metamatrix.common.types.AbstractTransform;
-import com.metamatrix.common.types.TransformationException;
-
-public class IntegerToBigDecimalTransform extends AbstractTransform {
-
- /**
- * This method transforms a value of the source type into a value
- * of the target type.
- * @param value Incoming value of source type
- * @return Outgoing value of target type
- * @throws TransformationException if value is an incorrect input type or
- * the transformation fails
- */
- public Object transform(Object value) throws TransformationException {
- if(value == null) {
- return value;
- }
-
- return BigDecimal.valueOf((Integer)value);
- }
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Integer.class;
- }
-
- /**
- * Type of the outgoing value.
- * @return Target type
- */
- public Class getTargetType() {
- return BigDecimal.class;
- }
-
-}
Deleted:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/IntegerToBigIntegerTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/IntegerToBigIntegerTransform.java 2009-08-25
19:38:18 UTC (rev 1277)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/IntegerToBigIntegerTransform.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-import java.math.BigInteger;
-
-import com.metamatrix.common.types.AbstractTransform;
-import com.metamatrix.common.types.TransformationException;
-
-public class IntegerToBigIntegerTransform extends AbstractTransform {
-
- /**
- * This method transforms a value of the source type into a value
- * of the target type.
- * @param value Incoming value of source type
- * @return Outgoing value of target type
- * @throws TransformationException if value is an incorrect input type or
- * the transformation fails
- */
- public Object transform(Object value) throws TransformationException {
- if(value == null) {
- return value;
- }
-
- return new BigInteger(String.valueOf(value));
- }
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Integer.class;
- }
-
- /**
- * Type of the outgoing value.
- * @return Target type
- */
- public Class getTargetType() {
- return BigInteger.class;
- }
-
-}
Deleted:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/IntegerToStringTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/IntegerToStringTransform.java 2009-08-25
19:38:18 UTC (rev 1277)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/IntegerToStringTransform.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-
-
-public class IntegerToStringTransform extends AnyToStringTransform {
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Integer.class;
- }
-}
Deleted:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/LongToBigDecimalTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/LongToBigDecimalTransform.java 2009-08-25
19:38:18 UTC (rev 1277)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/LongToBigDecimalTransform.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-import java.math.BigDecimal;
-
-import com.metamatrix.common.types.AbstractTransform;
-import com.metamatrix.common.types.TransformationException;
-
-public class LongToBigDecimalTransform extends AbstractTransform {
-
- /**
- * This method transforms a value of the source type into a value
- * of the target type.
- * @param value Incoming value of source type
- * @return Outgoing value of target type
- * @throws TransformationException if value is an incorrect input type or
- * the transformation fails
- */
- public Object transform(Object value) throws TransformationException {
- if(value == null) {
- return value;
- }
-
- return new BigDecimal((Long)value);
- }
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Long.class;
- }
-
- /**
- * Type of the outgoing value.
- * @return Target type
- */
- public Class getTargetType() {
- return BigDecimal.class;
- }
-
-}
Deleted:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/LongToBigIntegerTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/LongToBigIntegerTransform.java 2009-08-25
19:38:18 UTC (rev 1277)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/LongToBigIntegerTransform.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-import java.math.BigInteger;
-
-import com.metamatrix.common.types.AbstractTransform;
-import com.metamatrix.common.types.TransformationException;
-
-public class LongToBigIntegerTransform extends AbstractTransform {
-
- /**
- * This method transforms a value of the source type into a value
- * of the target type.
- * @param value Incoming value of source type
- * @return Outgoing value of target type
- * @throws TransformationException if value is an incorrect input type or
- * the transformation fails
- */
- public Object transform(Object value) throws TransformationException {
- if(value == null) {
- return value;
- }
-
- return new BigInteger(String.valueOf(value));
- }
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Long.class;
- }
-
- /**
- * Type of the outgoing value.
- * @return Target type
- */
- public Class getTargetType() {
- return BigInteger.class;
- }
-
-}
Deleted:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/LongToStringTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/LongToStringTransform.java 2009-08-25
19:38:18 UTC (rev 1277)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/LongToStringTransform.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-
-
-public class LongToStringTransform extends AnyToStringTransform {
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Long.class;
- }
-}
Modified:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/SQLXMLToStringTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/SQLXMLToStringTransform.java 2009-08-25
19:38:18 UTC (rev 1277)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/SQLXMLToStringTransform.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -28,10 +28,15 @@
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.common.types.TransformationException;
import com.metamatrix.common.types.XMLType;
+import com.metamatrix.common.types.DataTypeManager.DefaultDataClasses;
import com.metamatrix.core.CorePlugin;
public class SQLXMLToStringTransform extends AnyToStringTransform {
+ public SQLXMLToStringTransform() {
+ super(DefaultDataClasses.XML);
+ }
+
/**
* This method transforms a value of the source type into a value
* of the target type.
@@ -58,14 +63,6 @@
}
}
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return XMLType.class;
- }
-
/**
* @see com.metamatrix.common.types.AbstractTransform#isNarrowing()
*/
Deleted:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ShortToBigDecimalTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ShortToBigDecimalTransform.java 2009-08-25
19:38:18 UTC (rev 1277)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ShortToBigDecimalTransform.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-import java.math.BigDecimal;
-
-import com.metamatrix.common.types.AbstractTransform;
-import com.metamatrix.common.types.TransformationException;
-
-public class ShortToBigDecimalTransform extends AbstractTransform {
-
- /**
- * This method transforms a value of the source type into a value
- * of the target type.
- * @param value Incoming value of source type
- * @return Outgoing value of target type
- * @throws TransformationException if value is an incorrect input type or
- * the transformation fails
- */
- public Object transform(Object value) throws TransformationException {
- if(value == null) {
- return value;
- }
-
- return new BigDecimal((Short)value);
- }
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Short.class;
- }
-
- /**
- * Type of the outgoing value.
- * @return Target type
- */
- public Class getTargetType() {
- return BigDecimal.class;
- }
-
-}
Deleted:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ShortToBigIntegerTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ShortToBigIntegerTransform.java 2009-08-25
19:38:18 UTC (rev 1277)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ShortToBigIntegerTransform.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-import java.math.BigInteger;
-
-import com.metamatrix.common.types.AbstractTransform;
-import com.metamatrix.common.types.TransformationException;
-
-public class ShortToBigIntegerTransform extends AbstractTransform {
-
- /**
- * This method transforms a value of the source type into a value
- * of the target type.
- * @param value Incoming value of source type
- * @return Outgoing value of target type
- * @throws TransformationException if value is an incorrect input type or
- * the transformation fails
- */
- public Object transform(Object value) throws TransformationException {
- if(value == null) {
- return value;
- }
-
- return new BigInteger(String.valueOf(value));
- }
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Short.class;
- }
-
- /**
- * Type of the outgoing value.
- * @return Target type
- */
- public Class getTargetType() {
- return BigInteger.class;
- }
-
-}
Deleted:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ShortToStringTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ShortToStringTransform.java 2009-08-25
19:38:18 UTC (rev 1277)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/ShortToStringTransform.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-
-
-public class ShortToStringTransform extends AnyToStringTransform {
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Short.class;
- }
-}
Modified:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToBooleanTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToBooleanTransform.java 2009-08-25
19:38:18 UTC (rev 1277)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToBooleanTransform.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -22,14 +22,21 @@
package com.metamatrix.common.types.basic;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
import com.metamatrix.common.types.AbstractTransform;
import com.metamatrix.common.types.TransformationException;
+import com.metamatrix.common.types.DataTypeManager.DefaultDataClasses;
+import com.metamatrix.core.CorePlugin;
+import com.metamatrix.core.ErrorMessageKeys;
public class StringToBooleanTransform extends AbstractTransform {
- private static final String TRUE = "1"; //$NON-NLS-1$
- private static final String FALSE = "0"; //$NON-NLS-1$
-
+ private static final Set<String> TRUE = new
HashSet<String>(Arrays.asList("1", "TRUE")); //$NON-NLS-1$
//$NON-NLS-2$
+ private static final Set<String> FALSE = new
HashSet<String>(Arrays.asList("0", "FALSE")); //$NON-NLS-1$
//$NON-NLS-2$
+
/**
* This method transforms a value of the source type into a value
* of the target type.
@@ -42,30 +49,33 @@
if(value == null) {
return value;
}
- String str = ((String)value).trim();
- if (TRUE.equals(str)) {
+ String str = ((String)value).trim().toUpperCase();
+ if (TRUE.contains(str)) {
return Boolean.TRUE;
}
- else if (FALSE.equals(str)) {
+ if (FALSE.contains(str)) {
return Boolean.FALSE;
}
- return Boolean.valueOf((String)value);
+ if ("UNKNOWN".equals(str)) { //$NON-NLS-1$
+ return null;
+ }
+ throw new TransformationException(ErrorMessageKeys.TYPES_ERR_0013,
CorePlugin.Util.getString(ErrorMessageKeys.TYPES_ERR_0013,
getSourceType().getSimpleName(), value));
}
/**
* Type of the incoming value.
* @return Source type
*/
- public Class getSourceType() {
- return String.class;
+ public Class<?> getSourceType() {
+ return DefaultDataClasses.STRING;
}
/**
* Type of the outgoing value.
* @return Target type
*/
- public Class getTargetType() {
- return Boolean.class;
+ public Class<?> getTargetType() {
+ return DefaultDataClasses.BOOLEAN;
}
-
+
}
Modified:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToCharacterTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToCharacterTransform.java 2009-08-25
19:38:18 UTC (rev 1277)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToCharacterTransform.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -24,8 +24,6 @@
import com.metamatrix.common.types.AbstractTransform;
import com.metamatrix.common.types.TransformationException;
-import com.metamatrix.core.CorePlugin;
-import com.metamatrix.core.ErrorMessageKeys;
public class StringToCharacterTransform extends AbstractTransform {
@@ -41,21 +39,21 @@
if(value == null) {
return value;
}
-
+
String s = (String) value;
- switch(s.length()) {
- case 0: return null;
- case 1: return new Character( s.charAt(0) );
- default:
- throw new TransformationException(ErrorMessageKeys.TYPES_ERR_0017,
CorePlugin.Util.getString(ErrorMessageKeys.TYPES_ERR_0017, value));
+
+ if (s.length() == 0) {
+ return new Character(' ');
}
+
+ return new Character( s.charAt(0) );
}
/**
* Type of the incoming value.
* @return Source type
*/
- public Class getSourceType() {
+ public Class<?> getSourceType() {
return String.class;
}
@@ -63,8 +61,13 @@
* Type of the outgoing value.
* @return Target type
*/
- public Class getTargetType() {
+ public Class<?> getTargetType() {
return Character.class;
}
+
+ @Override
+ public boolean isNarrowing() {
+ return true;
+ }
}
Deleted:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/TimeToStringTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/TimeToStringTransform.java 2009-08-25
19:38:18 UTC (rev 1277)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/TimeToStringTransform.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-import java.sql.Time;
-
-public class TimeToStringTransform extends AnyToStringTransform {
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Time.class;
- }
-}
Deleted:
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/TimestampToStringTransform.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/TimestampToStringTransform.java 2009-08-25
19:38:18 UTC (rev 1277)
+++
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/TimestampToStringTransform.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types.basic;
-
-import java.sql.Timestamp;
-
-public class TimestampToStringTransform extends AnyToStringTransform {
-
- /**
- * Type of the incoming value.
- * @return Source type
- */
- public Class getSourceType() {
- return Timestamp.class;
- }
-}
Modified: trunk/common-core/src/main/resources/com/metamatrix/core/i18n.properties
===================================================================
--- trunk/common-core/src/main/resources/com/metamatrix/core/i18n.properties 2009-08-25
19:38:18 UTC (rev 1277)
+++ trunk/common-core/src/main/resources/com/metamatrix/core/i18n.properties 2009-08-25
19:40:43 UTC (rev 1278)
@@ -344,7 +344,7 @@
ERR.003.029.0004=Transform cannot be null.
ERR.003.029.0005=Transform source name cannot be null: {0}
ERR.003.029.0006=Transform target name cannot be null: {0}
-ERR.003.029.0013=Failed to transform {0} to Boolean. Expected 0 or 1 for {1}
+ERR.003.029.0013=Failed to transform {0} to Boolean. Expected 0, 1,
''TRUE'', ''FALSE'', or ''UNKNOWN'' for
''{1}''
ERR.003.029.0014=Invalid BigDecimal format in String: {0}
ERR.003.029.0015=Invalid BigInteger format in String: {0}
ERR.003.029.0016=Invalid Byte format in String: {0}
@@ -400,4 +400,4 @@
ExceptionHolder.converted_exception=Remote exception: {0} ... Original type hierarchy
{1}.
PropertiesUtils.failed_to_resolve_property=failed to completely resolve the property
value for key {0}
-transform.invalid_string_for_date=The string representation ''{0}'' of a
{1} value is out of range.
\ No newline at end of file
+transform.invalid_string_for_date=The string representation ''{0}'' of a
{1} value is not valid.
\ No newline at end of file
Modified:
trunk/common-core/src/test/java/com/metamatrix/common/types/basic/TestTransforms.java
===================================================================
---
trunk/common-core/src/test/java/com/metamatrix/common/types/basic/TestTransforms.java 2009-08-25
19:38:18 UTC (rev 1277)
+++
trunk/common-core/src/test/java/com/metamatrix/common/types/basic/TestTransforms.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -92,7 +92,7 @@
helpTestTransform(new String("0"), Boolean.FALSE); //$NON-NLS-1$
helpTestTransform(new String("true"), Boolean.TRUE); //$NON-NLS-1$
helpTestTransform(new String("false"), Boolean.FALSE); //$NON-NLS-1$
- helpTestTransform(new String("foo"), Boolean.FALSE); //$NON-NLS-1$
+ helpTransformException(new String("foo"),
DataTypeManager.DefaultDataClasses.BOOLEAN); //$NON-NLS-1$
}
@Test public void testByte2Boolean() throws TransformationException {
@@ -149,7 +149,8 @@
private String[] dataTypes = TestDataTypeManager.dataTypes;
private char[][] conversions = TestDataTypeManager.conversions;
private static boolean isException(String src, String tgt, Object source) {
- return (src.equals(DataTypeManager.DefaultDataTypes.STRING) &&
tgt.equals(DataTypeManager.DefaultDataTypes.XML))
+ return (src.equals(DataTypeManager.DefaultDataTypes.STRING) &&
tgt.equals(DataTypeManager.DefaultDataTypes.BOOLEAN) && source == testData[0][2])
+ || (src.equals(DataTypeManager.DefaultDataTypes.STRING) &&
tgt.equals(DataTypeManager.DefaultDataTypes.XML))
|| (src.equals(DataTypeManager.DefaultDataTypes.STRING) &&
tgt.equals(DataTypeManager.DefaultDataTypes.CHAR))
|| (src.equals(DataTypeManager.DefaultDataTypes.STRING) &&
tgt.equals(DataTypeManager.DefaultDataTypes.TIME))
|| (src.equals(DataTypeManager.DefaultDataTypes.STRING) &&
tgt.equals(DataTypeManager.DefaultDataTypes.TIMESTAMP))
@@ -228,7 +229,7 @@
}
@Test public void testStringToTimestampOutOfRange() throws Exception {
- helpTransformException("2005-13-01 11:13:01",
DefaultDataClasses.TIMESTAMP, "The string representation '2005-13-01
11:13:01' of a Timestamp value is out of range."); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTransformException("2005-13-01 11:13:01",
DefaultDataClasses.TIMESTAMP, "The string representation '2005-13-01
11:13:01' of a Timestamp value is not valid."); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testStringToTimeTimestampWithWS() throws Exception {
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/datatypes.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/datatypes.xml 2009-08-25
19:38:18 UTC (rev 1277)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/datatypes.xml 2009-08-25
19:40:43 UTC (rev 1278)
@@ -381,8 +381,14 @@
<entry>false</entry>
</row>
<row>
+ <entry>'unknown'</entry>
+ <entry>unknown</entry>
+ </row>
+ <row>
<entry>other</entry>
- <entry>false</entry>
+ <entry>
+ <emphasis>error</emphasis>
+ </entry>
</row>
<row>
<entry morerows="2">Numeric</entry>
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/grammar.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/grammar.xml 2009-08-25
19:38:18 UTC (rev 1277)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/grammar.xml 2009-08-25
19:40:43 UTC (rev 1278)
@@ -413,7 +413,7 @@
</row>
<row>
<entry valign="top"><anchor id="prod82"/>literal ::=
</entry>
-<entry valign="top">( <STRINGVAL> |
<INTEGERVAL> | <FLOATVAL> | <FALSE> |
<TRUE> | <NULL> | ( <BOOLEANTYPE>
<STRINGVAL> <RBRACE> ) | ( <TIMESTAMPTYPE>
<STRINGVAL> <RBRACE> ) | ( <DATETYPE>
<STRINGVAL> <RBRACE> ) | ( <TIMETYPE>
<STRINGVAL> <RBRACE> ) )</entry>
+<entry valign="top">( <STRINGVAL> |
<INTEGERVAL> | <FLOATVAL> | <FALSE> |
<TRUE> | <UNKNOWN> | <NULL> | (
<BOOLEANTYPE> <STRINGVAL> <RBRACE> ) | (
<TIMESTAMPTYPE> <STRINGVAL> <RBRACE> ) | (
<DATETYPE> <STRINGVAL> <RBRACE> ) | (
<TIMETYPE> <STRINGVAL> <RBRACE> )
)</entry>
</row>
</tbody>
</tgroup>
Modified:
trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
===================================================================
---
trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml 2009-08-25
19:38:18 UTC (rev 1277)
+++
trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml 2009-08-25
19:40:43 UTC (rev 1278)
@@ -756,7 +756,7 @@
<para>ASCII(x)</para>
</entry>
<entry>
- <para>Provide ASCII value of character x</para>
+ <para>Provide ASCII value of the left most character in x. The empty
string will as input will return null.</para>
</entry>
<entry>
<para>return type is integer</para>
@@ -782,7 +782,7 @@
x and/or y is null, returns null.</para>
</entry>
<entry>
- <para>x, y, is string</para>
+ <para>x, y in {string}</para>
</entry>
</row>
<row>
@@ -795,7 +795,7 @@
is null, returns the other value.</para>
</entry>
<entry>
- <para>x, y, is string</para>
+ <para>x, y in {string}</para>
</entry>
</row>
<row>
Modified: trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMethods.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMethods.java 2009-08-25
19:38:18 UTC (rev 1277)
+++
trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMethods.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -50,131 +50,107 @@
// ================== Function = plus =====================
- public static Object plus(Object x, Object y) throws FunctionExecutionException {
- if(x instanceof Integer) {
- if(y instanceof Integer) {
- return new Integer(((Integer)x).intValue() + ((Integer)y).intValue());
- }
- } else if(x instanceof Long) {
- if(y instanceof Long) {
- return new Long(((Long)x).longValue() + ((Long)y).longValue());
- }
- } else if(x instanceof Float) {
- if(y instanceof Float) {
- return new Float(((Float)x).floatValue() + ((Float)y).floatValue());
- }
- } else if(x instanceof Double) {
- if(y instanceof Double) {
- return new Double(((Double)x).doubleValue() + ((Double)y).doubleValue());
- }
- } else if(x instanceof BigInteger) {
- if(y instanceof BigInteger) {
- return ((BigInteger)x).add((BigInteger) y);
- }
- } else if(x instanceof BigDecimal) {
- if(y instanceof BigDecimal) {
- return ((BigDecimal)x).add((BigDecimal) y);
- }
- }
-
- throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0007,
QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0007, new Object[]{"plus",
x.getClass().getName(), y.getClass().getName()})); //$NON-NLS-1$
+ public static int plus(int x, int y) {
+ return x + y;
}
+
+ public static long plus(long x, long y) {
+ return x + y;
+ }
+
+ public static float plus(float x, float y) {
+ return x + y;
+ }
+
+ public static double plus(double x, double y) {
+ return x + y;
+ }
+
+ public static Object plus(BigInteger x, BigInteger y) {
+ return x.add(y);
+ }
+
+ public static Object plus(BigDecimal x, BigDecimal y) {
+ return x.add(y);
+ }
// ================== Function = minus =====================
- public static Object minus(Object x, Object y) throws FunctionExecutionException {
- if(x instanceof Integer) {
- if(y instanceof Integer) {
- return new Integer(((Integer)x).intValue() - ((Integer)y).intValue());
- }
- } else if(x instanceof Long) {
- if(y instanceof Long) {
- return new Long(((Long)x).longValue() - ((Long)y).longValue());
- }
- } else if(x instanceof Float) {
- if(y instanceof Float) {
- return new Float(((Float)x).floatValue() - ((Float)y).floatValue());
- }
- } else if(x instanceof Double) {
- if(y instanceof Double) {
- return new Double(((Double)x).doubleValue() - ((Double)y).doubleValue());
- }
- } else if(x instanceof BigInteger) {
- if(y instanceof BigInteger) {
- return ((BigInteger)x).subtract((BigInteger) y);
- }
- } else if(x instanceof BigDecimal) {
- if(y instanceof BigDecimal) {
- return ((BigDecimal)x).subtract((BigDecimal) y);
- }
- }
-
- throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0007,
QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0007, new Object[]{"minus",
x.getClass().getName(), y.getClass().getName()})); //$NON-NLS-1$
+ public static int minus(int x, int y) {
+ return x - y;
}
+
+ public static long minus(long x, long y) {
+ return x - y;
+ }
+
+ public static float minus(float x, float y) {
+ return x - y;
+ }
+
+ public static double minus(double x, double y) {
+ return x - y;
+ }
+
+ public static Object minus(BigInteger x, BigInteger y) {
+ return x.subtract(y);
+ }
+
+ public static Object minus(BigDecimal x, BigDecimal y) {
+ return x.subtract(y);
+ }
// ================== Function = multiply =====================
- public static Object multiply(Object x, Object y) throws FunctionExecutionException {
- if(x instanceof Integer) {
- if(y instanceof Integer) {
- return new Integer(((Integer)x).intValue() * ((Integer)y).intValue());
- }
- } else if(x instanceof Long) {
- if(y instanceof Long) {
- return new Long(((Long)x).longValue() * ((Long)y).longValue());
- }
- } else if(x instanceof Float) {
- if(y instanceof Float) {
- return new Float(((Float)x).floatValue() * ((Float)y).floatValue());
- }
- } else if(x instanceof Double) {
- if(y instanceof Double) {
- return new Double(((Double)x).doubleValue() * ((Double)y).doubleValue());
- }
- } else if(x instanceof BigInteger) {
- if(y instanceof BigInteger) {
- return ((BigInteger)x).multiply((BigInteger) y);
- }
- } else if(x instanceof BigDecimal) {
- if(y instanceof BigDecimal) {
- return ((BigDecimal)x).multiply((BigDecimal) y);
- }
- }
-
- throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0007,
QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0007, new
Object[]{"multiply", x.getClass().getName(), y.getClass().getName()}));
//$NON-NLS-1$
+ public static int multiply(int x, int y) {
+ return x * y;
}
+
+ public static long multiply(long x, long y) {
+ return x * y;
+ }
+
+ public static float multiply(float x, float y) {
+ return x * y;
+ }
+
+ public static double multiply(double x, double y) {
+ return x * y;
+ }
+
+ public static Object multiply(BigInteger x, BigInteger y) {
+ return x.multiply(y);
+ }
+
+ public static Object multiply(BigDecimal x, BigDecimal y) {
+ return x.multiply(y);
+ }
// ================== Function = divide =====================
- public static Object divide(Object x, Object y) throws FunctionExecutionException {
- if(x instanceof Integer) {
- if(y instanceof Integer) {
- return new Integer(((Integer)x).intValue() / ((Integer)y).intValue());
- }
- } else if(x instanceof Long) {
- if(y instanceof Long) {
- return new Long(((Long)x).longValue() / ((Long)y).longValue());
- }
- } else if(x instanceof Float) {
- if(y instanceof Float) {
- return new Float(((Float)x).floatValue() / ((Float)y).floatValue());
- }
- } else if(x instanceof Double) {
- if(y instanceof Double) {
- return new Double(((Double)x).doubleValue() / ((Double)y).doubleValue());
- }
- } else if(x instanceof BigInteger) {
- if(y instanceof BigInteger) {
- return ((BigInteger)x).divide((BigInteger) y);
- }
- } else if(x instanceof BigDecimal) {
- if(y instanceof BigDecimal) {
- return ((BigDecimal)x).divide((BigDecimal) y, BigDecimal.ROUND_HALF_UP);
- }
- }
-
- throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0007,
QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0007, new
Object[]{"divide", x.getClass().getName(), y.getClass().getName()}));
//$NON-NLS-1$
+ public static int divide(int x, int y) {
+ return x / y;
}
+
+ public static long divide(long x, long y) {
+ return x / y;
+ }
+
+ public static float divide(float x, float y) {
+ return x / y;
+ }
+
+ public static double divide(double x, double y) {
+ return x / y;
+ }
+
+ public static Object divide(BigInteger x, BigInteger y) {
+ return x.divide(y);
+ }
+
+ public static Object divide(BigDecimal x, BigDecimal y) {
+ return x.divide(y, BigDecimal.ROUND_HALF_UP);
+ }
// ================== Function = abs =====================
@@ -322,49 +298,29 @@
// ================== Function = sign =====================
- public static Object sign(Object x) throws FunctionExecutionException {
- if(x == null) {
- return null;
- } else if(x instanceof Integer) {
- int xVal = ((Integer)x).intValue();
- if(xVal > 0) {
- return new Integer(1);
- } else if(xVal == 0) {
- return new Integer(0);
- }
- return new Integer(-1);
- } else if(x instanceof Long) {
- long xVal = ((Long)x).longValue();
- if(xVal > 0) {
- return new Integer(1);
- } else if(xVal == 0) {
- return new Integer(0);
- }
- return new Integer(-1);
- } else if(x instanceof Float) {
- float xVal = ((Float)x).floatValue();
- if(xVal > 0) {
- return new Integer(1);
- } else if(xVal == 0) {
- return new Integer(0);
- }
- return new Integer(-1);
- } else if(x instanceof Double) {
- double xVal = ((Double)x).doubleValue();
- if(xVal > 0) {
- return new Integer(1);
- } else if(xVal == 0) {
- return new Integer(0);
- }
- return new Integer(-1);
- } else if(x instanceof BigInteger) {
- return new Integer(((BigInteger)x).signum());
- } else if(x instanceof BigDecimal) {
- return new Integer(((BigDecimal)x).signum());
- }
+ public static Object sign(int x) {
+ return Integer.signum(x);
+ }
+
+ public static Object sign(long x) {
+ return Long.signum(x);
+ }
- throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015,
QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "sign",
x.getClass().getName())); //$NON-NLS-1$
+ public static Object sign(float x) {
+ return Math.signum(x);
}
+
+ public static Object sign(double x) {
+ return Math.signum(x);
+ }
+
+ public static Object sign(BigInteger x) {
+ return new Integer(x.signum());
+ }
+
+ public static Object sign(BigDecimal x) {
+ return new Integer(x.signum());
+ }
// ================== Function = sqrt =====================
@@ -853,25 +809,16 @@
// ================== Function = ascii =====================
- public static Object ascii(Object ch)
- throws FunctionExecutionException {
-
- char c = 0;
- if(ch instanceof Character) {
- c = ((Character) ch).charValue();
- } else if(ch instanceof String) {
- String s = (String) ch;
- if(s.length() >= 1) {
- c = s.charAt(0);
- } else if(s.length() == 0) {
- throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0021,
QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0021));
- }
- } else {
- throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0015,
QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0015, "ascii",
ch.getClass().getName())); //$NON-NLS-1$
- }
-
- return new Integer(c);
+ public static Integer ascii(String ch) {
+ if(ch.length() == 0) {
+ return null;
+ }
+ return (int)ch.charAt(0);
}
+
+ public static Integer ascii(Character ch) {
+ return (int)ch.charValue();
+ }
// ================== Function = chr =====================
Modified: trunk/engine/src/main/java/com/metamatrix/query/parser/QueryParser.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/parser/QueryParser.java 2009-08-25
19:38:18 UTC (rev 1277)
+++ trunk/engine/src/main/java/com/metamatrix/query/parser/QueryParser.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -269,11 +269,7 @@
}
private QueryParserException convertParserException(ParseException pe) {
- QueryParserException qpe = null;
-
- qpe = new
QueryParserException(QueryPlugin.Util.getString("QueryParser.parsingError",
pe.getMessage())); //$NON-NLS-1$
-
- return qpe;
+ return new
QueryParserException(QueryPlugin.Util.getString("QueryParser.parsingError",
pe.getMessage())); //$NON-NLS-1$
}
/**
Modified:
trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/SQLStringVisitor.java
===================================================================
---
trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/SQLStringVisitor.java 2009-08-25
19:38:18 UTC (rev 1277)
+++
trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/SQLStringVisitor.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -30,8 +30,6 @@
import java.util.List;
import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.query.QueryPlugin;
import com.metamatrix.query.sql.LanguageObject;
import com.metamatrix.query.sql.LanguageVisitor;
import com.metamatrix.query.sql.ReservedWords;
@@ -105,7 +103,6 @@
import com.metamatrix.query.sql.symbol.SearchedCaseExpression;
import com.metamatrix.query.sql.symbol.SelectSymbol;
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.util.ErrorMessageKeys;
/**
* <p>The SQLStringVisitor will visit a set of language objects and return the
@@ -1131,34 +1128,32 @@
}
public void visit(Constant obj) {
+ Class<?> type = obj.getType();
Object[] constantParts = null;
if (obj.isMultiValued()) {
constantParts = new Object[] {"?"}; //$NON-NLS-1$
} else if(obj.isNull()) {
- constantParts = new Object[] {"null"}; //$NON-NLS-1$
+ if(type.equals(DataTypeManager.DefaultDataClasses.BOOLEAN)) {
+ constantParts = new Object[] {ReservedWords.UNKNOWN};
+ } else {
+ constantParts = new Object[] {"null"}; //$NON-NLS-1$
+ }
} else {
- try {
- Class type = obj.getType();
- if(type.equals(DataTypeManager.DefaultDataClasses.STRING)) {
- String strValue = (String) obj.getValue();
- strValue = escapeStringValue(strValue);
- constantParts = new Object[] { getStringQuoteBegin(), strValue,
getStringQuoteEnd() };
- } else if(Number.class.isAssignableFrom(type)) {
- constantParts = new Object[] { obj.getValue().toString() };
- } else if(type.equals(DataTypeManager.DefaultDataClasses.BOOLEAN)) {
- constantParts = new Object[] { obj.getValue().equals(Boolean.TRUE) ?
ReservedWords.TRUE : ReservedWords.FALSE};
- } else if(type.equals(DataTypeManager.DefaultDataClasses.TIMESTAMP)) {
- constantParts = new Object[] { "{ts'",
obj.getValue().toString(), "'}" }; //$NON-NLS-1$ //$NON-NLS-2$
- } else if(type.equals(DataTypeManager.DefaultDataClasses.TIME)) {
- constantParts = new Object[] { "{t'",
obj.getValue().toString(), "'}" }; //$NON-NLS-1$ //$NON-NLS-2$
- } else if(type.equals(DataTypeManager.DefaultDataClasses.DATE)) {
- constantParts = new Object[] { "{d'",
obj.getValue().toString(), "'}" }; //$NON-NLS-1$ //$NON-NLS-2$
- } else {
- constantParts = new Object[] { getStringQuoteBegin(),
obj.getValue().toString(), getStringQuoteEnd() };
- }
- } catch(RuntimeException e) {
- Assertion.failed(QueryPlugin.Util.getString(ErrorMessageKeys.SQL_0026,
e.getMessage()));
- }
+ if(Number.class.isAssignableFrom(type)) {
+ constantParts = new Object[] { obj.getValue().toString() };
+ } else if(type.equals(DataTypeManager.DefaultDataClasses.BOOLEAN)) {
+ constantParts = new Object[] { obj.getValue().equals(Boolean.TRUE) ?
ReservedWords.TRUE : ReservedWords.FALSE};
+ } else if(type.equals(DataTypeManager.DefaultDataClasses.TIMESTAMP)) {
+ constantParts = new Object[] { "{ts'",
obj.getValue().toString(), "'}" }; //$NON-NLS-1$ //$NON-NLS-2$
+ } else if(type.equals(DataTypeManager.DefaultDataClasses.TIME)) {
+ constantParts = new Object[] { "{t'",
obj.getValue().toString(), "'}" }; //$NON-NLS-1$ //$NON-NLS-2$
+ } else if(type.equals(DataTypeManager.DefaultDataClasses.DATE)) {
+ constantParts = new Object[] { "{d'",
obj.getValue().toString(), "'}" }; //$NON-NLS-1$ //$NON-NLS-2$
+ } else {
+ String strValue = obj.getValue().toString();
+ strValue = escapeStringValue(strValue);
+ constantParts = new Object[] { getStringQuoteBegin(), strValue,
getStringQuoteEnd() };
+ }
}
replaceStringParts(constantParts);
Modified: trunk/engine/src/main/javacc/com/metamatrix/query/parser/SQLParser.jj
===================================================================
--- trunk/engine/src/main/javacc/com/metamatrix/query/parser/SQLParser.jj 2009-08-25
19:38:18 UTC (rev 1277)
+++ trunk/engine/src/main/javacc/com/metamatrix/query/parser/SQLParser.jj 2009-08-25
19:40:43 UTC (rev 1278)
@@ -15,7 +15,7 @@
import java.math.BigInteger;
import java.util.*;
-import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.common.types.*;
import com.metamatrix.core.util.StringUtil;
import com.metamatrix.query.QueryPlugin;
import com.metamatrix.query.sql.LanguageObject;
@@ -2949,7 +2949,7 @@
Token t = null;
String strVal = null;
char tickChar = '\'';
-
+ Class escapeType = null;
Constant constant = null;
}
{
@@ -2995,52 +2995,23 @@
}
} |
- t=<FALSE> { constant = new Constant(Boolean.FALSE,
DataTypeManager.DefaultDataClasses.BOOLEAN); } |
- t=<TRUE> { constant = new Constant(Boolean.TRUE,
DataTypeManager.DefaultDataClasses.BOOLEAN); } |
- t=<NULL> { constant = new Constant(null); } |
+ t=<FALSE> { constant = new Constant(Boolean.FALSE,
DataTypeManager.DefaultDataClasses.BOOLEAN); } |
+ t=<TRUE> { constant = new Constant(Boolean.TRUE,
DataTypeManager.DefaultDataClasses.BOOLEAN); } |
+ t=<UNKNOWN> { constant = new Constant(null,
DataTypeManager.DefaultDataClasses.BOOLEAN); } |
+ t=<NULL> { constant = new Constant(null); } |
- ( <BOOLEANTYPE> t=<STRINGVAL> {
- String boolStr = t.image.substring(1, t.image.length()-1);
- if(boolStr.equalsIgnoreCase("true")) { //$NON-NLS-1$
- constant = new Constant(Boolean.TRUE,
DataTypeManager.DefaultDataClasses.BOOLEAN);
- } else if(boolStr.equalsIgnoreCase("false")) { //$NON-NLS-1$
- constant = new Constant(Boolean.FALSE,
DataTypeManager.DefaultDataClasses.BOOLEAN);
- } else {
- Object[] params = new Object[] { boolStr };
- throw new
ParseException(QueryPlugin.Util.getString("SQLParser.Boolean_parse", params));
//$NON-NLS-1$
- }
- } <RBRACE> ) |
-
- ( <TIMESTAMPTYPE> t=<STRINGVAL> {
- String timestampStr = t.image.substring(1, t.image.length()-1);
+ ( (<BOOLEANTYPE> { escapeType=DataTypeManager.DefaultDataClasses.BOOLEAN;
} |
+ <TIMESTAMPTYPE> {
escapeType=DataTypeManager.DefaultDataClasses.TIMESTAMP; } |
+ <DATETYPE> { escapeType=DataTypeManager.DefaultDataClasses.DATE; }
|
+ <TIMETYPE> { escapeType=DataTypeManager.DefaultDataClasses.TIME; })
t=<STRINGVAL> {
+ String str = t.image.substring(1, t.image.length()-1);
try {
- constant = new Constant(java.sql.Timestamp.valueOf(timestampStr),
DataTypeManager.DefaultDataClasses.TIMESTAMP);
- } catch(IllegalArgumentException e) {
- Object[] params = new Object[] { timestampStr };
- throw new
ParseException(QueryPlugin.Util.getString("SQLParser.Timestamp_parse", params));
//$NON-NLS-1$
- }
- } <RBRACE>) |
-
- ( <DATETYPE> t=<STRINGVAL> {
- String dateStr = t.image.substring(1, t.image.length()-1);
- try {
- constant = new Constant(java.sql.Date.valueOf(dateStr),
DataTypeManager.DefaultDataClasses.DATE);
- } catch(IllegalArgumentException e) {
- Object[] params = new Object[] { dateStr };
- throw new
ParseException(QueryPlugin.Util.getString("SQLParser.Date_parse", params));
//$NON-NLS-1$
- }
- } <RBRACE>) |
+ constant = new Constant(DataTypeManager.transformValue(str, escapeType),
escapeType);
+ } catch (TransformationException e) {
+ throw new ParseException(e.getMessage()); //$NON-NLS-1$
+ }
+ } <RBRACE> )
- ( <TIMETYPE> t=<STRINGVAL> {
- String timeStr = t.image.substring(1, t.image.length()-1);
- try {
- constant = new Constant(java.sql.Time.valueOf(timeStr),
DataTypeManager.DefaultDataClasses.TIME);
- } catch(IllegalArgumentException e) {
- Object[] params = new Object[] { timeStr };
- throw new
ParseException(QueryPlugin.Util.getString("SQLParser.Time_parse", params));
//$NON-NLS-1$
- }
- } <RBRACE>)
-
)
{
return constant;
Modified: trunk/engine/src/test/java/com/metamatrix/query/function/TestFunction.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/function/TestFunction.java 2009-08-25
19:38:18 UTC (rev 1277)
+++ trunk/engine/src/test/java/com/metamatrix/query/function/TestFunction.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -408,7 +408,7 @@
}
@Test public void testConvertStringBoolean3() throws Exception {
- helpConvert("x", "boolean", Boolean.FALSE); //$NON-NLS-1$
//$NON-NLS-2$
+ helpConvertFail("x", "boolean"); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testConvertStringBoolean4() throws Exception {
@@ -424,7 +424,7 @@
}
@Test public void testConvertStringChar2() throws Exception {
- helpConvertFail("xx", "char"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpConvert("xx", "char", new Character('x'));
//$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testConvertStringByte1() throws Exception {
@@ -494,26 +494,17 @@
helpConvert(ts, "string", "2003-08-22 22:43:53.003333333");
//$NON-NLS-1$ //$NON-NLS-2$
}
- @Test public void testAscii1() throws Exception {
- Integer code = (Integer) FunctionMethods.ascii(new Character(' '));
- assertEquals("Didn't get expected code", 32, code.intValue());
//$NON-NLS-1$
- }
-
@Test public void testAscii2() throws Exception {
- Integer code = (Integer) FunctionMethods.ascii(" "); //$NON-NLS-1$
+ Integer code = FunctionMethods.ascii(" "); //$NON-NLS-1$
assertEquals("Didn't get expected code", 32, code.intValue());
//$NON-NLS-1$
}
@Test public void testAscii4() throws Exception {
- try {
- FunctionMethods.ascii(""); //$NON-NLS-1$
- fail("Expected function exception"); //$NON-NLS-1$
- } catch (FunctionExecutionException e) {
- }
+ assertNull(FunctionMethods.ascii("")); //$NON-NLS-1$
}
@Test public void testAscii5() throws Exception {
- Integer code = (Integer) FunctionMethods.ascii("abc"); //$NON-NLS-1$
+ Integer code = FunctionMethods.ascii("abc"); //$NON-NLS-1$
assertEquals("Didn't get expected code", 97, code.intValue());
//$NON-NLS-1$
}
@@ -672,7 +663,7 @@
@Test public void testBitnot() throws Exception {
// Both values are integers
- Integer result = (Integer) FunctionMethods.bitnot(new Integer(0xF0F));
+ Integer result = FunctionMethods.bitnot(0xF0F);
assertNotNull("Result should not be null", result); //$NON-NLS-1$
assertEquals("result should be 0xFFFFF0F0", 0xFFFFF0F0,
result.intValue()); //$NON-NLS-1$
}
Modified:
trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionDescriptorImpl.java
===================================================================
---
trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionDescriptorImpl.java 2009-08-25
19:38:18 UTC (rev 1277)
+++
trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionDescriptorImpl.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -53,7 +53,7 @@
// Build signature
Class[] objectSignature = new Class[numArgs];
for(int i=0; i<numArgs; i++) {
- objectSignature[i] = java.lang.Object.class;
+ objectSignature[i] = Integer.TYPE;
}
// Find Method
Modified: trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java 2009-08-25
19:38:18 UTC (rev 1277)
+++ trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java 2009-08-25
19:40:43 UTC (rev 1278)
@@ -1708,7 +1708,7 @@
query.setSelect(select);
query.setFrom(from);
- helpTest("SELECT {d'2002-9-1'} FROM m.g1", //$NON-NLS-1$
+ helpTest("SELECT {d'2002-09-01'} FROM m.g1", //$NON-NLS-1$
"SELECT {d'2002-09-01'} FROM m.g1", //$NON-NLS-1$
query);
}
@@ -1749,7 +1749,7 @@
query.setSelect(select);
query.setFrom(from);
- helpTest("SELECT {t '5:10:00'} FROM m.g1", //$NON-NLS-1$
+ helpTest("SELECT {t '05:10:00'} FROM m.g1", //$NON-NLS-1$
"SELECT {t'05:10:00'} FROM m.g1", //$NON-NLS-1$
query);
}
@@ -1779,75 +1779,74 @@
/** SELECT {b'true'} FROM m.g1 */
public void testBooleanLiteralTrue() {
- GroupSymbol g = new GroupSymbol("m.g1"); //$NON-NLS-1$
- From from = new From();
- from.addGroup(g);
+ Boolean expected = Boolean.TRUE;
+ Class<?> expectedType = DataTypeManager.DefaultDataClasses.BOOLEAN;
+ String sql = "SELECT {b'true'}"; //$NON-NLS-1$
+ String expectedSql = "SELECT TRUE"; //$NON-NLS-1$
+
+ helpTestLiteral(expected, expectedType, sql, expectedSql);
+ }
- Select select = new Select();
- select.addSymbol(new ExpressionSymbol("expr", new
Constant(Boolean.valueOf("true")))); //$NON-NLS-1$ //$NON-NLS-2$
+ private void helpTestLiteral(Boolean expected, Class<?> expectedType,
+ String sql, String expectedSql) {
+ Select select = new Select();
+ select.addSymbol(new ExpressionSymbol("expr", new Constant(expected,
expectedType))); //$NON-NLS-1$
Query query = new Query();
query.setSelect(select);
- query.setFrom(from);
- helpTest("SELECT {b'true'} FROM m.g1", //$NON-NLS-1$
- "SELECT TRUE FROM m.g1", //$NON-NLS-1$
- query);
- }
+ helpTest(sql,
+ expectedSql,
+ query);
+ }
/** SELECT TRUE FROM m.g1 */
public void testBooleanLiteralTrue2() {
- GroupSymbol g = new GroupSymbol("m.g1"); //$NON-NLS-1$
- From from = new From();
- from.addGroup(g);
-
- Select select = new Select();
- select.addSymbol(new ExpressionSymbol("expr", new
Constant(Boolean.valueOf("true")))); //$NON-NLS-1$ //$NON-NLS-2$
-
- Query query = new Query();
- query.setSelect(select);
- query.setFrom(from);
-
- helpTest("SELECT TRUE FROM m.g1", //$NON-NLS-1$
- "SELECT TRUE FROM m.g1", //$NON-NLS-1$
- query);
+ Boolean expected = Boolean.TRUE;
+ Class<?> expectedType = DataTypeManager.DefaultDataClasses.BOOLEAN;
+ String sql = "SELECT TRUE"; //$NON-NLS-1$
+ String expectedSql = "SELECT TRUE"; //$NON-NLS-1$
+
+ helpTestLiteral(expected, expectedType, sql, expectedSql);
}
/** SELECT {b'false'} FROM m.g1 */
public void testBooleanLiteralFalse() {
- GroupSymbol g = new GroupSymbol("m.g1"); //$NON-NLS-1$
- From from = new From();
- from.addGroup(g);
-
- Select select = new Select();
- select.addSymbol(new ExpressionSymbol("expr", new
Constant(Boolean.valueOf("false")))); //$NON-NLS-1$ //$NON-NLS-2$
-
- Query query = new Query();
- query.setSelect(select);
- query.setFrom(from);
-
- helpTest("SELECT {b'false'} FROM m.g1", //$NON-NLS-1$
- "SELECT FALSE FROM m.g1", //$NON-NLS-1$
- query);
+ Boolean expected = Boolean.FALSE;
+ Class<?> expectedType = DataTypeManager.DefaultDataClasses.BOOLEAN;
+ String sql = "SELECT {b'false'}"; //$NON-NLS-1$
+ String expectedSql = "SELECT FALSE"; //$NON-NLS-1$
+
+ helpTestLiteral(expected, expectedType, sql, expectedSql);
}
/** SELECT FALSE FROM m.g1 */
public void testBooleanLiteralFalse2() {
- GroupSymbol g = new GroupSymbol("m.g1"); //$NON-NLS-1$
- From from = new From();
- from.addGroup(g);
-
- Select select = new Select();
- select.addSymbol(new ExpressionSymbol("expr", new
Constant(Boolean.valueOf("false")))); //$NON-NLS-1$ //$NON-NLS-2$
-
- Query query = new Query();
- query.setSelect(select);
- query.setFrom(from);
-
- helpTest("SELECT FALSE FROM m.g1", //$NON-NLS-1$
- "SELECT FALSE FROM m.g1", //$NON-NLS-1$
- query);
+ Boolean expected = Boolean.FALSE;
+ Class<?> expectedType = DataTypeManager.DefaultDataClasses.BOOLEAN;
+ String sql = "SELECT {b'false'}"; //$NON-NLS-1$
+ String expectedSql = "SELECT FALSE"; //$NON-NLS-1$
+
+ helpTestLiteral(expected, expectedType, sql, expectedSql);
}
+ public void testBooleanLiteralUnknown() {
+ Boolean expected = null;
+ Class<?> expectedType = DataTypeManager.DefaultDataClasses.BOOLEAN;
+ String sql = "SELECT {b'unknown'}"; //$NON-NLS-1$
+ String expectedSql = "SELECT UNKNOWN"; //$NON-NLS-1$
+
+ helpTestLiteral(expected, expectedType, sql, expectedSql);
+ }
+
+ public void testBooleanLiteralUnknown2() {
+ Boolean expected = null;
+ Class<?> expectedType = DataTypeManager.DefaultDataClasses.BOOLEAN;
+ String sql = "SELECT UNKNOWN"; //$NON-NLS-1$
+ String expectedSql = "SELECT UNKNOWN"; //$NON-NLS-1$
+
+ helpTestLiteral(expected, expectedType, sql, expectedSql);
+ }
+
/** SELECT {b 'xyz'} FROM m.g1 */
public void testBooleanLiteralFail() {
helpException("SELECT {b 'xyz'} FROM m.g1"); //$NON-NLS-1$