Java Code Examples for mil.nga.geopackage.db.GeoPackageDataType#DATETIME
The following examples show how to use
mil.nga.geopackage.db.GeoPackageDataType#DATETIME .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RelatedTablesUtils.java From geopackage-android with MIT License | 4 votes |
/** * Validate a user row * * @param columns array of columns * @param userRow user custom row */ public static void validateUserRow(String[] columns, UserCustomRow userRow) { TestCase.assertEquals(columns.length, userRow.columnCount()); for (int i = 0; i < userRow.columnCount(); i++) { UserCustomColumn column = userRow.getTable().getColumns().get(i); GeoPackageDataType dataType = column.getDataType(); TestCase.assertEquals(i, column.getIndex()); TestCase.assertEquals(columns[i], userRow.getColumnName(i)); TestCase.assertEquals(i, userRow.getColumnIndex(columns[i])); int rowType = userRow.getRowColumnType(i); Object value = userRow.getValue(i); switch (rowType) { case ResultUtils.FIELD_TYPE_INTEGER: TestUtils.validateIntegerValue(value, column.getDataType()); break; case ResultUtils.FIELD_TYPE_FLOAT: TestUtils.validateFloatValue(value, column.getDataType()); break; case ResultUtils.FIELD_TYPE_STRING: if (dataType == GeoPackageDataType.DATE || dataType == GeoPackageDataType.DATETIME) { TestCase.assertTrue(value instanceof Date); Date date = (Date) value; DateConverter converter = DateConverter.converter(dataType); String dateString = converter.stringValue(date); TestCase.assertEquals(date.getTime(), converter.dateValue(dateString).getTime()); } else { TestCase.assertTrue(value instanceof String); } break; case ResultUtils.FIELD_TYPE_BLOB: TestCase.assertTrue(value instanceof byte[]); break; case ResultUtils.FIELD_TYPE_NULL: TestCase.assertNull(value); break; } } }
Example 2
Source File: FeatureUtils.java From geopackage-android with MIT License | 4 votes |
/** * Validate a feature row * * @param columns * @param featureRow */ private static void validateFeatureRow(String[] columns, FeatureRow featureRow) { TestCase.assertEquals(columns.length, featureRow.columnCount()); for (int i = 0; i < featureRow.columnCount(); i++) { FeatureColumn column = featureRow.getTable().getColumns().get(i); GeoPackageDataType dataType = column.getDataType(); TestCase.assertEquals(i, column.getIndex()); TestCase.assertEquals(columns[i], featureRow.getColumnName(i)); TestCase.assertEquals(i, featureRow.getColumnIndex(columns[i])); int rowType = featureRow.getRowColumnType(i); Object value = featureRow.getValue(i); switch (rowType) { case Cursor.FIELD_TYPE_INTEGER: TestUtils.validateIntegerValue(value, column.getDataType()); break; case Cursor.FIELD_TYPE_FLOAT: TestUtils.validateFloatValue(value, column.getDataType()); break; case Cursor.FIELD_TYPE_STRING: if (dataType == GeoPackageDataType.DATE || dataType == GeoPackageDataType.DATETIME) { TestCase.assertTrue(value instanceof Date); Date date = (Date) value; DateConverter converter = DateConverter.converter(dataType); String dateString = converter.stringValue(date); TestCase.assertEquals(date.getTime(), converter.dateValue(dateString).getTime()); } else { TestCase.assertTrue(value instanceof String); } break; case Cursor.FIELD_TYPE_BLOB: if (featureRow.getGeometryColumnIndex() == i) { TestCase.assertTrue(value instanceof GeoPackageGeometryData); } else { TestCase.assertTrue(value instanceof byte[]); } break; case Cursor.FIELD_TYPE_NULL: TestCase.assertNull(value); break; } } TestCase.assertTrue(featureRow.getId() >= 0); }
Example 3
Source File: AttributesUtils.java From geopackage-android with MIT License | 4 votes |
/** * Validate an attributes row * * @param columns * @param attributesRow */ private static void validateAttributesRow(String[] columns, AttributesRow attributesRow) { TestCase.assertEquals(columns.length, attributesRow.columnCount()); for (int i = 0; i < attributesRow.columnCount(); i++) { AttributesColumn column = attributesRow.getTable().getColumns() .get(i); GeoPackageDataType dataType = column.getDataType(); TestCase.assertEquals(i, column.getIndex()); TestCase.assertEquals(columns[i], attributesRow.getColumnName(i)); TestCase.assertEquals(i, attributesRow.getColumnIndex(columns[i])); int rowType = attributesRow.getRowColumnType(i); Object value = attributesRow.getValue(i); switch (rowType) { case ResultUtils.FIELD_TYPE_INTEGER: TestUtils.validateIntegerValue(value, column.getDataType()); break; case ResultUtils.FIELD_TYPE_FLOAT: TestUtils.validateFloatValue(value, column.getDataType()); break; case ResultUtils.FIELD_TYPE_STRING: if (dataType == GeoPackageDataType.DATE || dataType == GeoPackageDataType.DATETIME) { TestCase.assertTrue(value instanceof Date); Date date = (Date) value; DateConverter converter = DateConverter.converter(dataType); String dateString = converter.stringValue(date); TestCase.assertEquals(date.getTime(), converter.dateValue(dateString).getTime()); } else { TestCase.assertTrue(value instanceof String); } break; case ResultUtils.FIELD_TYPE_BLOB: TestCase.assertTrue(value instanceof byte[]); break; case ResultUtils.FIELD_TYPE_NULL: TestCase.assertNull(value); break; } } TestCase.assertTrue(attributesRow.getId() >= 0); }
Example 4
Source File: RelatedTablesUtils.java From geopackage-java with MIT License | 4 votes |
/** * Validate a user row * * @param columns * array of columns * @param userRow * user custom row */ public static void validateUserRow(String[] columns, UserCustomRow userRow) { TestCase.assertEquals(columns.length, userRow.columnCount()); for (int i = 0; i < userRow.columnCount(); i++) { UserCustomColumn column = userRow.getTable().getColumns().get(i); GeoPackageDataType dataType = column.getDataType(); TestCase.assertEquals(i, column.getIndex()); TestCase.assertEquals(columns[i], userRow.getColumnName(i)); TestCase.assertEquals(i, userRow.getColumnIndex(columns[i])); int rowType = userRow.getRowColumnType(i); Object value = userRow.getValue(i); switch (rowType) { case ResultUtils.FIELD_TYPE_INTEGER: TestUtils.validateIntegerValue(value, column.getDataType()); break; case ResultUtils.FIELD_TYPE_FLOAT: TestUtils.validateFloatValue(value, column.getDataType()); break; case ResultUtils.FIELD_TYPE_STRING: if (dataType == GeoPackageDataType.DATE || dataType == GeoPackageDataType.DATETIME) { TestCase.assertTrue(value instanceof Date); Date date = (Date) value; DateConverter converter = DateConverter.converter(dataType); String dateString = converter.stringValue(date); TestCase.assertEquals(date.getTime(), converter.dateValue(dateString).getTime()); } else { TestCase.assertTrue(value instanceof String); } break; case ResultUtils.FIELD_TYPE_BLOB: TestCase.assertTrue(value instanceof byte[]); break; case ResultUtils.FIELD_TYPE_NULL: TestCase.assertNull(value); break; } } }
Example 5
Source File: FeatureUtils.java From geopackage-java with MIT License | 4 votes |
/** * Validate a feature row * * @param columns * @param featureRow */ private static void validateFeatureRow(String[] columns, FeatureRow featureRow) { TestCase.assertEquals(columns.length, featureRow.columnCount()); for (int i = 0; i < featureRow.columnCount(); i++) { FeatureColumn column = featureRow.getTable().getColumns().get(i); GeoPackageDataType dataType = column.getDataType(); TestCase.assertEquals(i, column.getIndex()); TestCase.assertEquals(columns[i], featureRow.getColumnName(i)); TestCase.assertEquals(i, featureRow.getColumnIndex(columns[i])); int rowType = featureRow.getRowColumnType(i); Object value = featureRow.getValue(i); switch (rowType) { case ResultUtils.FIELD_TYPE_INTEGER: TestUtils.validateIntegerValue(value, column.getDataType()); break; case ResultUtils.FIELD_TYPE_FLOAT: TestUtils.validateFloatValue(value, column.getDataType()); break; case ResultUtils.FIELD_TYPE_STRING: if (dataType == GeoPackageDataType.DATE || dataType == GeoPackageDataType.DATETIME) { TestCase.assertTrue(value instanceof Date); Date date = (Date) value; DateConverter converter = DateConverter.converter(dataType); String dateString = converter.stringValue(date); TestCase.assertEquals(date.getTime(), converter.dateValue(dateString).getTime()); } else { TestCase.assertTrue(value instanceof String); } break; case ResultUtils.FIELD_TYPE_BLOB: if (featureRow.getGeometryColumnIndex() == i) { TestCase.assertTrue(value instanceof GeoPackageGeometryData); } else { TestCase.assertTrue(value instanceof byte[]); } break; case ResultUtils.FIELD_TYPE_NULL: TestCase.assertNull(value); break; } } TestCase.assertTrue(featureRow.getId() >= 0); }
Example 6
Source File: AttributesUtils.java From geopackage-java with MIT License | 4 votes |
/** * Validate an attributes row * * @param columns * @param attributesRow */ private static void validateAttributesRow(String[] columns, AttributesRow attributesRow) { TestCase.assertEquals(columns.length, attributesRow.columnCount()); for (int i = 0; i < attributesRow.columnCount(); i++) { AttributesColumn column = attributesRow.getTable().getColumns() .get(i); GeoPackageDataType dataType = column.getDataType(); TestCase.assertEquals(i, column.getIndex()); TestCase.assertEquals(columns[i], attributesRow.getColumnName(i)); TestCase.assertEquals(i, attributesRow.getColumnIndex(columns[i])); int rowType = attributesRow.getRowColumnType(i); Object value = attributesRow.getValue(i); switch (rowType) { case ResultUtils.FIELD_TYPE_INTEGER: TestUtils.validateIntegerValue(value, column.getDataType()); break; case ResultUtils.FIELD_TYPE_FLOAT: TestUtils.validateFloatValue(value, column.getDataType()); break; case ResultUtils.FIELD_TYPE_STRING: if (dataType == GeoPackageDataType.DATE || dataType == GeoPackageDataType.DATETIME) { TestCase.assertTrue(value instanceof Date); Date date = (Date) value; DateConverter converter = DateConverter.converter(dataType); String dateString = converter.stringValue(date); TestCase.assertEquals(date.getTime(), converter.dateValue(dateString).getTime()); } else { TestCase.assertTrue(value instanceof String); } break; case ResultUtils.FIELD_TYPE_BLOB: TestCase.assertTrue(value instanceof byte[]); break; case ResultUtils.FIELD_TYPE_NULL: TestCase.assertNull(value); break; } } TestCase.assertTrue(attributesRow.getId() >= 0); }