ucar.nc2.Group.findAttributeIgnoreCase()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(72)

本文整理了Java中ucar.nc2.Group.findAttributeIgnoreCase()方法的一些代码示例,展示了Group.findAttributeIgnoreCase()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Group.findAttributeIgnoreCase()方法的具体详情如下:
包路径:ucar.nc2.Group
类名称:Group
方法名:findAttributeIgnoreCase

Group.findAttributeIgnoreCase介绍

[英]Find an Attribute in this Group by its name, ignore case.
[中]按名称查找此组中的属性,忽略大小写。

代码示例

代码示例来源:origin: org.apache.sis.storage/sis-netcdf

/**
 * Returns the netCDF attribute of the given name in the given group, or {@code null} if none.
 * This method is invoked for every global and group attributes to be read by this class (but
 * not {@linkplain ucar.nc2.VariableSimpleIF variable} attributes), thus providing a single point
 * where we can filter the attributes to be read - if we want to do that in a future version.
 *
 * <p>The {@code name} argument is typically (but is not restricted too) one of the constants
 * defined in the {@link org.apache.sis.storage.netcdf.AttributeNames} class.</p>
 *
 * @param  group  the group in which to search the attribute, or {@code null} for global attributes.
 * @param  name   the name of the attribute to search (can not be null).
 * @return the attribute, or {@code null} if none.
 */
private Attribute findAttribute(final Group group, final String name) {
  return (group != null) ? group.findAttributeIgnoreCase(name) : file.findGlobalAttributeIgnoreCase(name);
}

代码示例来源:origin: apache/sis

/**
 * Returns the netCDF attribute of the given name in the given group, or {@code null} if none.
 * This method is invoked for every global and group attributes to be read by this class (but
 * not {@linkplain ucar.nc2.VariableSimpleIF variable} attributes), thus providing a single point
 * where we can filter the attributes to be read - if we want to do that in a future version.
 *
 * <p>The {@code name} argument is typically (but is not restricted too) one of the constants
 * defined in the {@link org.apache.sis.storage.netcdf.AttributeNames} class.</p>
 *
 * @param  group  the group in which to search the attribute, or {@code null} for global attributes.
 * @param  name   the name of the attribute to search (can not be null).
 * @return the attribute, or {@code null} if none.
 */
private Attribute findAttribute(final Group group, final String name) {
  return (group != null) ? group.findAttributeIgnoreCase(name) : file.findGlobalAttributeIgnoreCase(name);
}

代码示例来源:origin: edu.ucar/netcdf

public int readAttributeInteger(Variable v, String attName, int defValue) {
 Attribute att;
 if (v == null)
  att = rootGroup.findAttributeIgnoreCase(attName);
 else
  att = v.findAttributeIgnoreCase(attName);
 if (att == null) return defValue;
 if (att.isString())
  return Integer.parseInt(att.getStringValue());
 else
  return att.getNumericValue().intValue();
}

代码示例来源:origin: edu.ucar/netcdf

public double readAttributeDouble(Variable v, String attName, double defValue) {
 Attribute att;
 if (v == null)
  att = rootGroup.findAttributeIgnoreCase(attName);
 else
  att = v.findAttributeIgnoreCase(attName);
 if (att == null) return defValue;
 if (att.isString())
  return Double.parseDouble(att.getStringValue());
 else
  return att.getNumericValue().doubleValue();
}

代码示例来源:origin: edu.ucar/cdm

public int readAttributeInteger(Variable v, String attName, int defValue) {
 Attribute att;
 if (v == null)
  att = rootGroup.findAttributeIgnoreCase(attName);
 else
  att = v.findAttributeIgnoreCase(attName);
 if (att == null) return defValue;
 if (att.isString())
  return Integer.parseInt(att.getStringValue());
 else
  return att.getNumericValue().intValue();
}

代码示例来源:origin: Unidata/thredds

public int readAttributeInteger(Variable v, String attName, int defValue) {
 Attribute att;
 if (v == null)
  att = rootGroup.findAttributeIgnoreCase(attName);
 else
  att = v.findAttributeIgnoreCase(attName);
 if (att == null) return defValue;
 if (att.isString())
  return Integer.parseInt(att.getStringValue());
 else
  return att.getNumericValue().intValue();
}

代码示例来源:origin: Unidata/thredds

public double readAttributeDouble(Variable v, String attName, double defValue) {
 Attribute att;
 if (v == null)
  att = rootGroup.findAttributeIgnoreCase(attName);
 else
  att = v.findAttributeIgnoreCase(attName);
 if (att == null) return defValue;
 if (att.isString())
  return Double.parseDouble(att.getStringValue());
 else
  return att.getNumericValue().doubleValue();
}

代码示例来源:origin: edu.ucar/cdm

public double readAttributeDouble(Variable v, String attName, double defValue) {
 Attribute att;
 if (v == null)
  att = rootGroup.findAttributeIgnoreCase(attName);
 else
  att = v.findAttributeIgnoreCase(attName);
 if (att == null) return defValue;
 if (att.isString())
  return Double.parseDouble(att.getStringValue());
 else
  return att.getNumericValue().doubleValue();
}

代码示例来源:origin: edu.ucar/netcdf

/**
 * Find a String-valued global or variable Attribute by
 * Attribute name (ignore case), return the Value of the Attribute.
 * If not found return defaultValue
 *
 * @param v            the variable or null for global attribute
 * @param attName      the (full) name of the attribute, case insensitive
 * @param defaultValue return this if attribute not found
 * @return the attribute value, or defaultValue if not found
 */
public String findAttValueIgnoreCase(Variable v, String attName, String defaultValue) {
 String attValue = null;
 Attribute att;
 if (v == null)
  att = rootGroup.findAttributeIgnoreCase(attName);
 else
  att = v.findAttributeIgnoreCase(attName);
 if ((att != null) && att.isString())
  attValue = att.getStringValue();
 if (null == attValue)                     // not found, use default
  attValue = defaultValue;
 return attValue;
}

代码示例来源:origin: Unidata/thredds

/**
 * Find a String-valued global or variable Attribute by
 * Attribute name (ignore case), return the Value of the Attribute.
 * If not found return defaultValue
 *
 * @param v            the variable or null for global attribute
 * @param attName      the (full) name of the attribute, case insensitive
 * @param defaultValue return this if attribute not found
 * @return the attribute value, or defaultValue if not found
 */
public String findAttValueIgnoreCase(Variable v, String attName, String defaultValue) {
 String attValue = null;
 Attribute att;
 if (v == null)
  att = rootGroup.findAttributeIgnoreCase(attName);
 else
  att = v.findAttributeIgnoreCase(attName);
 if ((att != null) && att.isString())
  attValue = att.getStringValue();
 if (null == attValue)                     // not found, use default
  attValue = defaultValue;
 return attValue;
}

代码示例来源:origin: edu.ucar/cdm

/**
 * Find a String-valued global or variable Attribute by
 * Attribute name (ignore case), return the Value of the Attribute.
 * If not found return defaultValue
 *
 * @param v            the variable or null for global attribute
 * @param attName      the (full) name of the attribute, case insensitive
 * @param defaultValue return this if attribute not found
 * @return the attribute value, or defaultValue if not found
 */
public String findAttValueIgnoreCase(Variable v, String attName, String defaultValue) {
 String attValue = null;
 Attribute att;
 if (v == null)
  att = rootGroup.findAttributeIgnoreCase(attName);
 else
  att = v.findAttributeIgnoreCase(attName);
 if ((att != null) && att.isString())
  attValue = att.getStringValue();
 if (null == attValue)                     // not found, use default
  attValue = defaultValue;
 return attValue;
}

代码示例来源:origin: Unidata/thredds

Attribute orgConv =  root.findAttributeIgnoreCase(CDM.CONVENTIONS);
String convAtt = CoordSysBuilder.buildConventionAttribute("CF-1.4", (orgConv == null ? null : orgConv.getStringValue()));
root.addAttribute(new Attribute(CDM.CONVENTIONS, convAtt));

相关文章