当前位置: 首页>>代码示例>>Java>>正文


Java Data.isNull方法代码示例

本文整理汇总了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;
}
 
开发者ID:apache,项目名称:beam,代码行数:19,代码来源:Structs.java

示例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;
}
 
开发者ID:apache,项目名称:beam,代码行数:18,代码来源:Structs.java

示例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;
    }
}
 
开发者ID:jonathanswenson,项目名称:starschema-bigquery-jdbc,代码行数:31,代码来源:BQResultSetMetadata.java

示例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;
}
 
开发者ID:apache,项目名称:beam,代码行数:35,代码来源:Structs.java

示例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;
}
 
开发者ID:apache,项目名称:beam,代码行数:32,代码来源:Structs.java

示例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;
}
 
开发者ID:jonathanswenson,项目名称:starschema-bigquery-jdbc,代码行数:29,代码来源:BQForwardOnlyResultSet.java

示例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);
        }
    }
}
 
开发者ID:jonathanswenson,项目名称:starschema-bigquery-jdbc,代码行数:62,代码来源:BQResultSet.java

示例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);
        }
    }
}
 
开发者ID:jonathanswenson,项目名称:starschema-bigquery-jdbc,代码行数:62,代码来源:BQScrollableResultSet.java

示例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();
}
 
开发者ID:kcbanner,项目名称:chief,代码行数:69,代码来源:LCBOCommand.java

示例10: hasNotes

import com.google.api.client.util.Data; //导入方法依赖的package包/类
public boolean hasNotes() {
	return !Data.isNull(tasting_note);
}
 
开发者ID:kcbanner,项目名称:chief,代码行数:4,代码来源:LCBOCommand.java

示例11: hasServingSuggestion

import com.google.api.client.util.Data; //导入方法依赖的package包/类
public boolean hasServingSuggestion() {
	return !Data.isNull(serving_suggestion);
}
 
开发者ID:kcbanner,项目名称:chief,代码行数:4,代码来源:LCBOCommand.java


注:本文中的com.google.api.client.util.Data.isNull方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。