Java Code Examples for mil.nga.geopackage.db.GeoPackageDataType#BLOB

The following examples show how to use mil.nga.geopackage.db.GeoPackageDataType#BLOB . 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: UserColumn.java    From geopackage-core-java with MIT License 6 votes vote down vote up
/**
 * Validate that if max is set, the data type is text or blob
 */
private void validateMax() {

	if (max != null) {
		if (dataType == null) {
			throw new GeoPackageException(
					"Column max is only supported for data typed columns. column: "
							+ name + ", max: " + max);
		} else if (dataType != GeoPackageDataType.TEXT
				&& dataType != GeoPackageDataType.BLOB) {
			throw new GeoPackageException(
					"Column max is only supported for "
							+ GeoPackageDataType.TEXT.name() + " and "
							+ GeoPackageDataType.BLOB.name()
							+ " columns. column: " + name + ", max: " + max
							+ ", type: " + dataType.name());
		}
	}

}
 
Example 2
Source File: FeatureCoreGenerator.java    From geopackage-core-java with MIT License 5 votes vote down vote up
/**
 * Get the type for the object value
 * 
 * @param value
 *            value
 * @return data type
 */
public static GeoPackageDataType getType(Object value) {

	GeoPackageDataType type = null;

	if (value instanceof String) {
		type = GeoPackageDataType.TEXT;
	} else if (value instanceof Boolean) {
		type = GeoPackageDataType.BOOLEAN;
	} else if (value instanceof Byte) {
		type = GeoPackageDataType.TINYINT;
	} else if (value instanceof Short) {
		type = GeoPackageDataType.SMALLINT;
	} else if (value instanceof Integer) {
		type = GeoPackageDataType.MEDIUMINT;
	} else if (value instanceof Long) {
		type = GeoPackageDataType.INT;
	} else if (value instanceof Float) {
		type = GeoPackageDataType.FLOAT;
	} else if (value instanceof Double) {
		type = GeoPackageDataType.DOUBLE;
	} else if (value instanceof byte[]) {
		type = GeoPackageDataType.BLOB;
	}

	if (type == null) {
		type = GeoPackageDataType.TEXT;
	}

	return type;
}
 
Example 3
Source File: TableInfo.java    From geopackage-core-java with MIT License 5 votes vote down vote up
/**
 * Get the data type from the type value
 * 
 * @param type
 *            type value
 * @return data type or null
 */
public static GeoPackageDataType getDataType(String type) {

	GeoPackageDataType dataType = GeoPackageDataType.findName(type);

	if (dataType == null) {

		// Check if a geometry and set as a blob
		if (GeometryType.findName(type) != null) {
			dataType = GeoPackageDataType.BLOB;
		}

	}
	return dataType;
}
 
Example 4
Source File: FeatureColumn.java    From geopackage-core-java with MIT License 3 votes vote down vote up
/**
 * Create a new geometry column
 * 
 * @param index
 *            index
 * @param name
 *            name
 * @param type
 *            geometry type
 * @param notNull
 *            not null flag
 * @param defaultValue
 *            default value
 * @return feature column
 */
public static FeatureColumn createGeometryColumn(int index, String name,
		GeometryType type, boolean notNull, Object defaultValue) {
	if (type == null) {
		throw new GeoPackageException(
				"Geometry Type is required to create geometry column: "
						+ name);
	}
	return new FeatureColumn(index, name, GeoPackageDataType.BLOB, null,
			notNull, defaultValue, false, type);
}
 
Example 5
Source File: SimpleAttributesTable.java    From geopackage-core-java with MIT License 2 votes vote down vote up
/**
 * Determine if the data type is a simple type: TEXT, INTEGER, or REAL
 * storage classes
 * 
 * @param dataType
 *            data type
 * @return true if a simple column
 */
public static boolean isSimple(GeoPackageDataType dataType) {
	return dataType != GeoPackageDataType.BLOB;
}
 
Example 6
Source File: TileColumn.java    From geopackage-core-java with MIT License 2 votes vote down vote up
/**
 * Create a tile data column
 * 
 * @param index
 *            index
 * @return tile column
 */
public static TileColumn createTileDataColumn(int index) {
	return new TileColumn(index, TileTable.COLUMN_TILE_DATA,
			GeoPackageDataType.BLOB, null, true, null, false);
}