本文整理汇总了Java中com.google.api.client.util.Data.isNull方法的典型用法代码示例。如果您正苦于以下问题:Java Data.isNull方法的具体用法?Java Data.isNull怎么用?Java Data.isNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.api.client.util.Data
的用法示例。
在下文中一共展示了Data.isNull方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkObject
import com.google.api.client.util.Data; //导入方法依赖的package包/类
private static Map<String, Object> checkObject(
Object value, Map<String, Object> map, String name) {
if (Data.isNull(value)) {
// This is a JSON literal null. When represented as an object, this is an
// empty map.
return Collections.<String, Object>emptyMap();
}
if (!(value instanceof Map)) {
throw new IncorrectTypeException(name, map, "an object (not a map)");
}
@SuppressWarnings("unchecked")
Map<String, Object> mapValue = (Map<String, Object>) value;
if (!mapValue.containsKey(PropertyNames.OBJECT_TYPE_NAME)) {
throw new IncorrectTypeException(
name, map, "an object (no \"" + PropertyNames.OBJECT_TYPE_NAME + "\" field)");
}
return mapValue;
}
示例2: getDictionary
import com.google.api.client.util.Data; //导入方法依赖的package包/类
public static Map<String, Object> getDictionary(Map<String, Object> map, String name) {
@Nullable Object value = map.get(name);
if (value == null) {
throw new ParameterNotFoundException(name, map);
}
if (Data.isNull(value)) {
// This is a JSON literal null. When represented as a dictionary, this is
// an empty map.
return Collections.<String, Object>emptyMap();
}
if (!(value instanceof Map)) {
throw new IncorrectTypeException(name, map, "a dictionary");
}
@SuppressWarnings("unchecked")
Map<String, Object> result = (Map<String, Object>) value;
return result;
}
示例3: getScale
import com.google.api.client.util.Data; //导入方法依赖的package包/类
/**
* <p>
* <h1>Implementation Details:</h1><br>
* Not implemented yet.
* </p>
*
* @throws BQSQLException
*/
@Override
public int getScale(int column) throws SQLException {
if (this.getColumnType(column) == java.sql.Types.DOUBLE) {
int max = 0;
for (int i = 0; i < this.result.getRows().size(); i++) {
Object rowdataObject = this.result.getRows().get(i).getF().get(column - 1).getV();
if (Data.isNull(rowdataObject)) {
return 0;
}
String rowdata = (String) rowdataObject;
if (rowdata.contains(".")) {
int pointback = rowdata.length() - rowdata.indexOf(".");
if (pointback > max) {
pointback = max;
}
}
}
return max;
} else {
return 0;
}
}
示例4: getStrings
import com.google.api.client.util.Data; //导入方法依赖的package包/类
@Nullable
public static List<String> getStrings(
Map<String, Object> map, String name, @Nullable List<String> defaultValue) {
@Nullable Object value = map.get(name);
if (value == null) {
if (map.containsKey(name)) {
throw new IncorrectTypeException(name, map, "a string or a list");
}
return defaultValue;
}
if (Data.isNull(value)) {
// This is a JSON literal null. When represented as a list of strings,
// this is an empty list.
return Collections.<String>emptyList();
}
@Nullable String singletonString = decodeValue(value, String.class);
if (singletonString != null) {
return Collections.singletonList(singletonString);
}
if (!(value instanceof List)) {
throw new IncorrectTypeException(name, map, "a string or a list");
}
@SuppressWarnings("unchecked")
List<Object> elements = (List<Object>) value;
List<String> result = new ArrayList<>(elements.size());
for (Object o : elements) {
@Nullable String s = decodeValue(o, String.class);
if (s == null) {
throw new IncorrectTypeException(name, map, "a list of strings");
}
result.add(s);
}
return result;
}
示例5: getListOfMaps
import com.google.api.client.util.Data; //导入方法依赖的package包/类
@Nullable
public static List<Map<String, Object>> getListOfMaps(
Map<String, Object> map, String name, @Nullable List<Map<String, Object>> defaultValue) {
@Nullable Object value = map.get(name);
if (value == null) {
if (map.containsKey(name)) {
throw new IncorrectTypeException(name, map, "a list");
}
return defaultValue;
}
if (Data.isNull(value)) {
// This is a JSON literal null. When represented as a list,
// this is an empty list.
return Collections.<Map<String, Object>>emptyList();
}
if (!(value instanceof List)) {
throw new IncorrectTypeException(name, map, "a list");
}
List<?> elements = (List<?>) value;
for (Object elem : elements) {
if (!(elem instanceof Map)) {
throw new IncorrectTypeException(name, map, "a list of Map objects");
}
}
@SuppressWarnings("unchecked")
List<Map<String, Object>> result = (List<Map<String, Object>>) elements;
return result;
}
示例6: getString
import com.google.api.client.util.Data; //导入方法依赖的package包/类
@Override
/**
* Returns the current rows Data at the given index as String
* @param columnIndex - the column to be used
* @return - the stored value parsed to String
* @throws SQLException - if the resultset is closed or the columnIndex is not valid, or the type is unsupported
*/
public String getString(int columnIndex) throws SQLException {
//to make the logfiles smaller!
//logger.debug("Function call getString columnIndex is: " + String.valueOf(columnIndex));
this.closestrm();
if (this.isClosed()) {
throw new BQSQLException("This Resultset is Closed");
}
if (this.getMetaData().getColumnCount() < columnIndex
|| columnIndex < 1) {
throw new BQSQLException("ColumnIndex is not valid");
}
if (this.RowsofResult == null) throw new BQSQLException("Invalid position!");
Object resultObject = ((TableRow) this.RowsofResult[this.Cursor]).getF().get(columnIndex - 1).getV();
if (Data.isNull(resultObject)) {
this.wasnull = true;
return null;
}
this.wasnull = false;
return (String) resultObject;
}
示例7: getObject
import com.google.api.client.util.Data; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public Object getObject(int columnIndex) throws SQLException {
// to make the logfiles smaller!
//logger.debug("Function call getObject columnIndex is: " + String.valueOf(columnIndex));
this.closestrm();
if (this.isClosed()) {
throw new BQSQLException("This Resultset is Closed");
}
this.ThrowCursorNotValidExeption();
if (this.RowsofResult == null) {
throw new BQSQLException("There are no rows in this Resultset");
}
if (this.getMetaData().getColumnCount() < columnIndex
|| columnIndex < 1) {
throw new BQSQLException("ColumnIndex is not valid");
}
String Columntype = this.Result.getSchema().getFields()
.get(columnIndex - 1).getType();
TableCell field = ((TableRow) this.RowsofResult[this.Cursor]).getF().get(columnIndex - 1);
if (Data.isNull(field.getV())) {
this.wasnull = true;
return null;
} else {
String result = field.getV().toString();
this.wasnull = false;
try {
if (Columntype.equals("STRING")) {
//removing the excess byte by the setmaxFiledSize
if (maxFieldSize == 0 || maxFieldSize == Integer.MAX_VALUE) {
return result;
} else {
try { //lets try to remove the excess bytes
return result.substring(0, maxFieldSize);
} catch (IndexOutOfBoundsException iout) {
//we don't need to remove any excess byte
return result;
}
}
}
if (Columntype.equals("FLOAT")) {
return Float.parseFloat(result);
}
if (Columntype.equals("BOOLEAN")) {
return Boolean.parseBoolean(result);
}
if (Columntype.equals("INTEGER")) {
return Long.parseLong(result);
}
if (Columntype.equals("TIMESTAMP")) {
long val = new BigDecimal(result).longValue() * 1000;
return new Timestamp(val);
}
throw new BQSQLException("Unsupported Type (" + Columntype + ")");
} catch (NumberFormatException e) {
throw new BQSQLException(e);
}
}
}
示例8: getObject
import com.google.api.client.util.Data; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public Object getObject(int columnIndex) throws SQLException {
// to make the logfiles smaller!
//logger.debug("Function call getObject columnIndex is: " + String.valueOf(columnIndex));
this.closestrm();
if (this.isClosed()) {
throw new BQSQLException("This Resultset is Closed");
}
this.ThrowCursorNotValidExeption();
if (this.RowsofResult == null) {
throw new BQSQLException("There are no rows in this Resultset");
}
if (this.getMetaData().getColumnCount() < columnIndex
|| columnIndex < 1) {
throw new BQSQLException("ColumnIndex is not valid");
}
String Columntype = this.Result.getSchema().getFields()
.get(columnIndex - 1).getType();
TableCell field = ((TableRow) this.RowsofResult[this.Cursor]).getF().get(columnIndex - 1);
if (Data.isNull(field.getV())) {
this.wasnull = true;
return null;
} else {
String result = field.getV().toString();
this.wasnull = false;
try {
if (Columntype.equals("STRING")) {
//removing the excess byte by the setmaxFiledSize
if (maxFieldSize == 0 || maxFieldSize == Integer.MAX_VALUE) {
return result;
} else {
try { //lets try to remove the excess bytes
return result.substring(0, maxFieldSize);
} catch (IndexOutOfBoundsException iout) {
//we don't need to remove any excess byte
return result;
}
}
}
if (Columntype.equals("FLOAT")) {
return Float.parseFloat(result);
}
if (Columntype.equals("BOOLEAN")) {
return Boolean.parseBoolean(result);
}
if (Columntype.equals("INTEGER")) {
return Long.parseLong(result);
}
if (Columntype.equals("TIMESTAMP")) {
long val = new BigDecimal(result).longValue() * 1000;
return new Timestamp(val);
}
throw new BQSQLException("Unsupported Type");
} catch (NumberFormatException e) {
throw new BQSQLException(e);
}
}
}
示例9: toString
import com.google.api.client.util.Data; //导入方法依赖的package包/类
@Override
public String toString() {
StringBuilder builder = new StringBuilder(name);
builder.append(":\n");
if (!Data.isNull(origin))
builder.append(" From: ").append(origin).append("\n");
if (!Data.isNull(primary_category)) {
builder.append(" Style: ").append(primary_category);
if (!Data.isNull(secondary_category)) {
builder.append(" - ").append(secondary_category);
}
if (!Data.isNull(style)) {
builder.append(" - ").append(style);
}
builder.append("\n");
}
if (!Data.isNull(alcohol_content)) {
builder.append(" Alchohol content: ")
.append((float) alcohol_content / 100.0)
.append("%\n");
}
if (!Data.isNull(packaging))
builder.append(" Package: ").append(packaging).append("\n");
if (!Data.isNull(price_in_cents)) {
builder.append(" Price: $").append(price_in_cents / 100);
if (!Data.isNull(regular_price_in_cents) &&
regular_price_in_cents.compareTo(price_in_cents) != 0) {
builder.append(" (regular $")
.append(regular_price_in_cents / 100)
.append(")");
}
builder.append("\n");
}
if (!Data.isNull(producer_name))
builder.append(" Produced by: ").append(producer_name).append("\n");
if (!Data.isNull(inventory_count)) {
builder.append(" Total Inventory: ").append(inventory_count).append(" units");
if (!Data.isNull(inventory_volume_in_milliliters)) {
builder.append(" (")
.append(inventory_volume_in_milliliters / 1000)
.append(" litres)");
}
builder.append("\n");
}
builder.append("Store link: ")
.append("http://www.lcbo.com/lcbo/search?searchTerm=")
.append(id);
return builder.toString();
}
示例10: hasNotes
import com.google.api.client.util.Data; //导入方法依赖的package包/类
public boolean hasNotes() {
return !Data.isNull(tasting_note);
}
示例11: hasServingSuggestion
import com.google.api.client.util.Data; //导入方法依赖的package包/类
public boolean hasServingSuggestion() {
return !Data.isNull(serving_suggestion);
}