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


Java Attribute.isString方法代码示例

本文整理汇总了Java中ucar.nc2.Attribute.isString方法的典型用法代码示例。如果您正苦于以下问题:Java Attribute.isString方法的具体用法?Java Attribute.isString怎么用?Java Attribute.isString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ucar.nc2.Attribute的用法示例。


在下文中一共展示了Attribute.isString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getStringValue

import ucar.nc2.Attribute; //导入方法依赖的package包/类
/**
 * Reads the value of an attribute of a variable and returns its value as a string.
 * 
 * @param attribute a NetCDF attribute.
 * @param variable a NetCDF variable.
 * 
 * @return value of the attribute
 * 
 * @throws NetCdfAttributeException invalid request (see error message).
 */
public static String getStringValue(Variable variable, Attribute attribute) throws NetCdfAttributeException {
    String value = null;
    if (attribute == null) {
        return value;
    }

    if (!attribute.isString()) {
        throw new NetCdfAttributeException(
                variable,
                attribute,
                String.format("Error in getStringValue - Unable to get string value from attribute - Attribute type (%s) is not STRING ",
                              attribute.getDataType().toString()));
    }

    value = attribute.getStringValue();

    if (value == null) {
        throw new NetCdfAttributeException(variable, attribute, "Error in getStringValue - Unable to get string value from attribute");
    }
    return value;
}
 
开发者ID:clstoulouse,项目名称:motu,代码行数:32,代码来源:NetCdfReader.java

示例2: isUgrid

import ucar.nc2.Attribute; //导入方法依赖的package包/类
/**
 * Looks inside a NetCDF dataset to determine whether it follows the UGRID
 * conventions.
 * 
 * @param nc
 *            The dataset
 * @return <code>true</code> if this is a UGRID dataset
 */
private static boolean isUgrid(NetcdfDataset nc) {
    /*
     * First find the variable containing the "cf_role = mesh_topology"
     * attribute. This is what defines that we are working with a UGRID
     * dataset.
     */
    List<Variable> variables = nc.getVariables();
    Variable meshTopology = null;
    for (Variable var : variables) {
        Attribute cfRole = var.findAttribute("cf_role");
        if (cfRole != null && cfRole.isString()
                && cfRole.getStringValue().equalsIgnoreCase("mesh_topology")) {
            meshTopology = var;
            break;
        }
    }
    return meshTopology != null;
}
 
开发者ID:Reading-eScience-Centre,项目名称:edal-java,代码行数:27,代码来源:CdmGridDatasetFactory.java

示例3: isSgrid

import ucar.nc2.Attribute; //导入方法依赖的package包/类
/**
 * Looks inside a NetCDF dataset to determine whether it follows the SGRID
 * conventions.
 * 
 * @param nc
 *            The dataset
 * @return <code>true</code> if this is a SGRID dataset
 */
private static boolean isSgrid(NetcdfDataset nc) {
    /*
     * First find the variable containing the "cf_role = grid_topology"
     * attribute. This is what defines that we are working with a UGRID
     * dataset.
     */
    List<Variable> variables = nc.getVariables();
    Variable gridTopology = null;
    for (Variable var : variables) {
        Attribute cfRole = var.findAttribute("cf_role");
        if (cfRole != null && cfRole.isString()
                && cfRole.getStringValue().equalsIgnoreCase("grid_topology")) {
            gridTopology = var;
            break;
        }
    }
    return gridTopology != null;
}
 
开发者ID:Reading-eScience-Centre,项目名称:edal-java,代码行数:27,代码来源:CdmGridDatasetFactory.java

示例4: writeGlobalAttribute

import ucar.nc2.Attribute; //导入方法依赖的package包/类
/**
 * Write a global attribute to the file.
 * 
 * @param att take attribute name, value, from here
 */
public void writeGlobalAttribute(Attribute att) {
    if (att.isArray()) {
        ncfile.addGlobalAttribute(att.getName(), att.getValues());
    } else if (att.isString()) {
        ncfile.addGlobalAttribute(att.getName(), att.getStringValue());
    } else {
        ncfile.addGlobalAttribute(att.getName(), att.getNumericValue());
    }
}
 
开发者ID:clstoulouse,项目名称:motu,代码行数:15,代码来源:NetCdfWriter.java

示例5: writeAttribute

import ucar.nc2.Attribute; //导入方法依赖的package包/类
/**
 * Write a Variable attribute to the file.
 * 
 * @param varName name of variable to attach attribute to
 * @param att take attribute name, value, from here
 */
public void writeAttribute(String varName, Attribute att) {
    long d1 = System.nanoTime();
    if (att.isArray()) {
        ncfile.addVariableAttribute(varName, att.getName(), att.getValues());
    } else if (att.isString()) {
        ncfile.addVariableAttribute(varName, att.getName(), att.getStringValue());
    } else {
        ncfile.addVariableAttribute(varName, att.getName(), att.getNumericValue());
    }
    long d2 = System.nanoTime();
    this.writingTime += (d2 - d1);
}
 
开发者ID:clstoulouse,项目名称:motu,代码行数:19,代码来源:NetCdfWriter.java

示例6: getFileMetadata

import ucar.nc2.Attribute; //导入方法依赖的package包/类
/**
 * <p>
 * Devuelve la informaci&oacute;n obtenida de los atributos del archivo
 * NetCDF
 * </p>
 * .
 * 
 * @return informaci&oacute;n de metadatos
 */
public String[] getFileMetadata() {
    if (fileDataSet == null)
        return new String[0];

    // Crea la lista de metadatos
    ArrayList<String> metadata = new ArrayList<String>();

    // Toma todos los atributos del archivo NetCDF
    List<Attribute> attrs = fileDataSet.getGlobalAttributes();
    // Recorre todos los atributos del archivo
    for (Attribute attr : attrs) {
        // Nombre del atributo
        StringBuilder sb = new StringBuilder();
        sb.append(attr.getName());
        sb.append("=");

        // El valor del atributo es de tipo cadena
        if (attr.isString()) {
            sb.append(attr.getStringValue(0));
            // Verifica si el valor del atributo es un arreglo
            for (int i = 0; i < attr.getLength(); ++i) {
                sb.append(",");
                sb.append(attr.getStringValue(i));
            }

            // El valor del atributo es de tipo numérico
        } else {
            sb.append(attr.getNumericValue(0).doubleValue());
            // Verifica si el valor del atributo es un arreglo
            for (int i = 0; i < attr.getLength(); ++i) {
                sb.append(",");
                sb.append(attr.getNumericValue(i).doubleValue());
            }
        }
        metadata.add(sb.toString());
    }

    return metadata.toArray(new String[0]);
}
 
开发者ID:rmillo,项目名称:extsdf,代码行数:49,代码来源:NetCDFController.java


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