Skip to content
Snippets Groups Projects
Commit d399afd1 authored by gmantele's avatar gmantele
Browse files

[TAP] Ensure scalar values do not have an `arraysize="1"` attribute in VOTable.

parent 9c0b2a7b
No related branches found
No related tags found
No related merge requests found
package tap.metadata; package tap.metadata;
import adql.db.DBType;
import adql.db.DBType.DBDatatype;
/* /*
* This file is part of TAPLibrary. * This file is part of TAPLibrary.
* *
...@@ -16,14 +19,12 @@ package tap.metadata; ...@@ -16,14 +19,12 @@ package tap.metadata;
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with TAPLibrary. If not, see <http://www.gnu.org/licenses/>. * along with TAPLibrary. If not, see <http://www.gnu.org/licenses/>.
* *
* Copyright 2012,2014 - UDS/Centre de Données astronomiques de Strasbourg (CDS), * Copyright 2012-2017 - UDS/Centre de Données astronomiques de Strasbourg (CDS),
* Astronomisches Rechen Institut (ARI) * Astronomisches Rechen Institut (ARI)
*/ */
import tap.TAPException; import tap.TAPException;
import uk.ac.starlink.votable.VOSerializer; import uk.ac.starlink.votable.VOSerializer;
import adql.db.DBType;
import adql.db.DBType.DBDatatype;
/** /**
* <p>Describes a full VOTable type. Thus it includes the following field attributes:</p> * <p>Describes a full VOTable type. Thus it includes the following field attributes:</p>
...@@ -34,7 +35,7 @@ import adql.db.DBType.DBDatatype; ...@@ -34,7 +35,7 @@ import adql.db.DBType.DBDatatype;
* </ul> * </ul>
* *
* @author Gr&eacute;gory Mantelet (CDS;ARI) * @author Gr&eacute;gory Mantelet (CDS;ARI)
* @version 2.0 (02/2015) * @version 2.1 (03/2017)
*/ */
public final class VotType { public final class VotType {
/** /**
...@@ -129,43 +130,43 @@ public final class VotType { ...@@ -129,43 +130,43 @@ public final class VotType {
switch(tapType.type){ switch(tapType.type){
case SMALLINT: case SMALLINT:
this.datatype = VotDatatype.SHORT; this.datatype = VotDatatype.SHORT;
this.arraysize = "1"; this.arraysize = null;
this.xtype = null; this.xtype = null;
break; break;
case INTEGER: case INTEGER:
this.datatype = VotDatatype.INT; this.datatype = VotDatatype.INT;
this.arraysize = "1"; this.arraysize = null;
this.xtype = null; this.xtype = null;
break; break;
case BIGINT: case BIGINT:
this.datatype = VotDatatype.LONG; this.datatype = VotDatatype.LONG;
this.arraysize = "1"; this.arraysize = null;
this.xtype = null; this.xtype = null;
break; break;
case REAL: case REAL:
this.datatype = VotDatatype.FLOAT; this.datatype = VotDatatype.FLOAT;
this.arraysize = "1"; this.arraysize = null;
this.xtype = null; this.xtype = null;
break; break;
case DOUBLE: case DOUBLE:
this.datatype = VotDatatype.DOUBLE; this.datatype = VotDatatype.DOUBLE;
this.arraysize = "1"; this.arraysize = null;
this.xtype = null; this.xtype = null;
break; break;
case CHAR: case CHAR:
this.datatype = VotDatatype.CHAR; this.datatype = VotDatatype.CHAR;
this.arraysize = Integer.toString(tapType.length > 0 ? tapType.length : 1); this.arraysize = Integer.toString(tapType.length > 0 ? tapType.length : null);
this.xtype = null; this.xtype = null;
break; break;
case BINARY: case BINARY:
this.datatype = VotDatatype.UNSIGNEDBYTE; this.datatype = VotDatatype.UNSIGNEDBYTE;
this.arraysize = Integer.toString(tapType.length > 0 ? tapType.length : 1); this.arraysize = Integer.toString(tapType.length > 0 ? tapType.length : null);
this.xtype = null; this.xtype = null;
break; break;
...@@ -253,7 +254,7 @@ public final class VotType { ...@@ -253,7 +254,7 @@ public final class VotType {
* *
* @return The corresponding {@link DBType}. * @return The corresponding {@link DBType}.
* *
* @throws TAPException If the conversion is impossible (particularly if the array-size refers to a multi-dimensional array ; only 1D arrays are allowed). * @throws TAPException If the conversion is impossible (particularly if the array-size refers to a multi-dimensional array ; only 1D arrays are allowed).
*/ */
public DBType toTAPType() throws TAPException{ public DBType toTAPType() throws TAPException{
...@@ -264,7 +265,7 @@ public final class VotType { ...@@ -264,7 +265,7 @@ public final class VotType {
// Convert the VOTable datatype into TAP datatype: // Convert the VOTable datatype into TAP datatype:
switch(datatype){ switch(datatype){
/* NUMERIC TYPES */ /* NUMERIC TYPES */
case SHORT: case SHORT:
case BOOLEAN: case BOOLEAN:
return convertNumericType(DBDatatype.SMALLINT); return convertNumericType(DBDatatype.SMALLINT);
...@@ -281,7 +282,7 @@ public final class VotType { ...@@ -281,7 +282,7 @@ public final class VotType {
case DOUBLE: case DOUBLE:
return convertNumericType(DBDatatype.DOUBLE); return convertNumericType(DBDatatype.DOUBLE);
/* BINARY TYPES */ /* BINARY TYPES */
case UNSIGNEDBYTE: case UNSIGNEDBYTE:
// BLOB exception: // BLOB exception:
if (xtype != null && xtype.equalsIgnoreCase(XTYPE_BLOB)) if (xtype != null && xtype.equalsIgnoreCase(XTYPE_BLOB))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment