本文整理汇总了Java中mil.nga.geopackage.db.DateConverter.stringValue方法的典型用法代码示例。如果您正苦于以下问题:Java DateConverter.stringValue方法的具体用法?Java DateConverter.stringValue怎么用?Java DateConverter.stringValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mil.nga.geopackage.db.DateConverter
的用法示例。
在下文中一共展示了DateConverter.stringValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: columnToContentValue
import mil.nga.geopackage.db.DateConverter; //导入方法依赖的package包/类
/**
* Map the column to the content values
*
* @param contentValues
* @param column
* @param value
*/
protected void columnToContentValue(ContentValues contentValues,
TColumn column, Object value) {
String columnName = column.getName();
if (value instanceof Number) {
if (value instanceof Byte) {
validateValue(column, value, Byte.class, Short.class,
Integer.class, Long.class);
contentValues.put(columnName, (Byte) value);
} else if (value instanceof Short) {
validateValue(column, value, Short.class, Integer.class,
Long.class);
contentValues.put(columnName, (Short) value);
} else if (value instanceof Integer) {
validateValue(column, value, Integer.class, Long.class);
contentValues.put(columnName, (Integer) value);
} else if (value instanceof Long) {
validateValue(column, value, Long.class, Double.class);
contentValues.put(columnName, (Long) value);
} else if (value instanceof Float) {
validateValue(column, value, Float.class);
contentValues.put(columnName, (Float) value);
} else if (value instanceof Double) {
validateValue(column, value, Double.class);
contentValues.put(columnName, (Double) value);
} else {
throw new GeoPackageException("Unsupported Number type: "
+ value.getClass().getSimpleName());
}
} else if (value instanceof String) {
validateValue(column, value, String.class);
String stringValue = (String) value;
if (column.getMax() != null
&& stringValue.length() > column.getMax()) {
throw new GeoPackageException(
"String is larger than the column max. Size: "
+ stringValue.length() + ", Max: "
+ column.getMax() + ", Column: " + columnName);
}
contentValues.put(columnName, stringValue);
} else if (value instanceof byte[]) {
validateValue(column, value, byte[].class);
byte[] byteValue = (byte[]) value;
if (column.getMax() != null && byteValue.length > column.getMax()) {
throw new GeoPackageException(
"Byte array is larger than the column max. Size: "
+ byteValue.length + ", Max: "
+ column.getMax() + ", Column: " + columnName);
}
contentValues.put(columnName, byteValue);
} else if (value instanceof Boolean) {
validateValue(column, value, Boolean.class);
Boolean booleanValue = (Boolean) value;
short shortBoolean = booleanValue ? (short) 1 : (short) 0;
contentValues.put(columnName, shortBoolean);
} else if (value instanceof Date) {
validateValue(column, value, Date.class, String.class);
Date dateValue = (Date) value;
DateConverter converter = DateConverter.converter(column
.getDataType());
String dateString = converter.stringValue(dateValue);
contentValues.put(columnName, dateString);
} else {
throw new GeoPackageException(
"Unsupported update column value. column: " + columnName
+ ", value: " + value);
}
}
示例2: validateFeatureRow
import mil.nga.geopackage.db.DateConverter; //导入方法依赖的package包/类
/**
* 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);
}
示例3: validateAttributesRow
import mil.nga.geopackage.db.DateConverter; //导入方法依赖的package包/类
/**
* 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 UserCoreResultUtils.FIELD_TYPE_INTEGER:
TestUtils.validateIntegerValue(value, column.getDataType());
break;
case UserCoreResultUtils.FIELD_TYPE_FLOAT:
TestUtils.validateFloatValue(value, column.getDataType());
break;
case UserCoreResultUtils.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 UserCoreResultUtils.FIELD_TYPE_BLOB:
TestCase.assertTrue(value instanceof byte[]);
break;
case UserCoreResultUtils.FIELD_TYPE_NULL:
TestCase.assertNull(value);
break;
}
}
TestCase.assertTrue(attributesRow.getId() >= 0);
}
示例4: columnToContentValue
import mil.nga.geopackage.db.DateConverter; //导入方法依赖的package包/类
/**
* Map the column to the content values
*
* @param contentValues
* @param column
* @param value
*/
protected void columnToContentValue(ContentValues contentValues,
TColumn column, Object value) {
String columnName = column.getName();
if (value instanceof Number) {
if (value instanceof Byte) {
validateValue(column, value, Byte.class, Short.class,
Integer.class, Long.class);
contentValues.put(columnName, (Byte) value);
} else if (value instanceof Short) {
validateValue(column, value, Short.class, Integer.class,
Long.class);
contentValues.put(columnName, (Short) value);
} else if (value instanceof Integer) {
validateValue(column, value, Integer.class, Long.class);
contentValues.put(columnName, (Integer) value);
} else if (value instanceof Long) {
validateValue(column, value, Long.class, Double.class);
contentValues.put(columnName, (Long) value);
} else if (value instanceof Float) {
validateValue(column, value, Float.class);
contentValues.put(columnName, (Float) value);
} else if (value instanceof Double) {
validateValue(column, value, Double.class);
contentValues.put(columnName, (Double) value);
} else {
throw new GeoPackageException("Unsupported Number type: "
+ value.getClass().getSimpleName());
}
} else if (value instanceof String) {
validateValue(column, value, String.class);
String stringValue = (String) value;
if (column.getMax() != null
&& stringValue.length() > column.getMax()) {
throw new GeoPackageException(
"String is larger than the column max. Size: "
+ stringValue.length() + ", Max: "
+ column.getMax() + ", Column: " + columnName);
}
contentValues.put(columnName, stringValue);
} else if (value instanceof byte[]) {
validateValue(column, value, byte[].class);
byte[] byteValue = (byte[]) value;
if (column.getMax() != null && byteValue.length > column.getMax()) {
throw new GeoPackageException(
"Byte array is larger than the column max. Size: "
+ byteValue.length + ", Max: "
+ column.getMax() + ", Column: " + columnName);
}
contentValues.put(columnName, byteValue);
} else if (value instanceof Boolean) {
validateValue(column, value, Boolean.class);
Boolean booleanValue = (Boolean) value;
short shortBoolean = booleanValue ? (short) 1 : (short) 0;
contentValues.put(columnName, shortBoolean);
} else if (value instanceof Date) {
validateValue(column, value, Date.class, String.class);
Date dateValue = (Date) value;
DateConverter converter = DateConverter.converter(column
.getDataType());
String dateString = converter.stringValue(dateValue);
contentValues.put(columnName, dateString);
} else {
throw new GeoPackageException(
"Unsupported update column value. column: " + columnName
+ ", value: " + value);
}
}
示例5: validateFeatureRow
import mil.nga.geopackage.db.DateConverter; //导入方法依赖的package包/类
/**
* 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 UserCoreResultUtils.FIELD_TYPE_INTEGER:
TestUtils.validateIntegerValue(value, column.getDataType());
break;
case UserCoreResultUtils.FIELD_TYPE_FLOAT:
TestUtils.validateFloatValue(value, column.getDataType());
break;
case UserCoreResultUtils.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 UserCoreResultUtils.FIELD_TYPE_BLOB:
if (featureRow.getGeometryColumnIndex() == i) {
TestCase.assertTrue(value instanceof GeoPackageGeometryData);
} else {
TestCase.assertTrue(value instanceof byte[]);
}
break;
case UserCoreResultUtils.FIELD_TYPE_NULL:
TestCase.assertNull(value);
break;
}
}
TestCase.assertTrue(featureRow.getId() >= 0);
}
示例6: validateAttributesRow
import mil.nga.geopackage.db.DateConverter; //导入方法依赖的package包/类
/**
* 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 UserCoreResultUtils.FIELD_TYPE_INTEGER:
TestUtils.validateIntegerValue(value, column.getDataType());
break;
case UserCoreResultUtils.FIELD_TYPE_FLOAT:
TestUtils.validateFloatValue(value, column.getDataType());
break;
case UserCoreResultUtils.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 UserCoreResultUtils.FIELD_TYPE_BLOB:
TestCase.assertTrue(value instanceof byte[]);
break;
case UserCoreResultUtils.FIELD_TYPE_NULL:
TestCase.assertNull(value);
break;
}
}
TestCase.assertTrue(attributesRow.getId() >= 0);
}