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


Java DataType.INT属性代码示例

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


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

示例1: objectsToType

private static DataType objectsToType(final List<Object> objects) {
    if (objects.isEmpty()) {
        return DataType.INT;
    }
    short new_sz, sz = -1;
    DataType dataType = DataType.INT;
    for (final Object o : objects) {
        final DataType _type = ArrayMath.getDataType(o);
        new_sz = ArrayMath.typeToNBytes(_type);
        if (new_sz > sz) {
            dataType = _type;
            sz = new_sz;
        }
    }
    return dataType;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:16,代码来源:ArrayUtil.java

示例2: netcdfTypeFromJDBCType

public DataType netcdfTypeFromJDBCType(int col, ResultSetMetaData resultSetMetadata) throws SQLException {
    int columnType = resultSetMetadata.getColumnType(col);
    if (columnType == Types.DOUBLE) {
        return DataType.DOUBLE;
    } else if ( columnType == Types.FLOAT) {
        return DataType.FLOAT;
    } else if ( columnType == Types.REAL) {
        return DataType.FLOAT;
    } else if ( columnType == Types.INTEGER) {
        return DataType.INT;
    } else if ( columnType == Types.DECIMAL) {
        return DataType.FLOAT;
    } else if ( columnType == Types.SMALLINT) {
        return DataType.SHORT;
    } else if ( columnType == Types.TINYINT) {
        return DataType.BYTE;
    } else if ( columnType == Types.NUMERIC) {
        if ( resultSetMetadata.getScale(col) < 0) {
           return DataType.DOUBLE;
        }
        else if ( resultSetMetadata.getScale(col) > 0 &&
                  resultSetMetadata.getPrecision(col) > 0 ) {
           return DataType.DOUBLE;
        } else if ( resultSetMetadata.getScale(col) == 0 && 
                    resultSetMetadata.getPrecision(col) > 0 ) {
           return DataType.INT;
        } else {
           return DataType.DOUBLE;
        }
    } else if ( columnType == Types.CHAR || columnType == Types.VARCHAR) {
        return DataType.CHAR;
    } else {
        return DataType.CHAR;
    }
}
 
开发者ID:NOAA-PMEL,项目名称:LAS,代码行数:35,代码来源:IntermediateNetcdfFile.java

示例3: toDataType

/**
 * To data type - ucar.ma2
 *
 * @param dt Data type string
 * @return Data type
 */
public static DataType toDataType(String dt) {
    if (dt.contains("%")) {
        dt = dt.split("%")[1];
    }
    switch (dt.toLowerCase()) {
        case "c":
        case "s":
        case "string":
            return DataType.STRING;
        case "b":
        case "byte":
            return DataType.BYTE;
        case "short":
            return DataType.SHORT;
        case "i":
        case "int":
            return DataType.INT;
        case "f":
        case "float":
            return DataType.FLOAT;
        case "d":
        case "double":
            return DataType.DOUBLE;
        default:
            return DataType.OBJECT;
    }
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:33,代码来源:ArrayUtil.java

示例4: getDataType

/**
 * Get data type
 *
 * @param o Object
 * @return Data type
 */
public static DataType getDataType(Object o) {
    if (o instanceof Integer) {
        return DataType.INT;
    } else if (o instanceof Float) {
        return DataType.FLOAT;
    } else if (o instanceof Double) {
        return DataType.DOUBLE;
    } else {
        return DataType.OBJECT;
    }
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:17,代码来源:ArrayMath.java

示例5: read

/**
 * Read array data of the variable
 *
 * @param varName Variable name
 * @param origin The origin array
 * @param size The size array
 * @param stride The stride array
 * @return Array data
 */
@Override
public Array read(String varName, int[] origin, int[] size, int[] stride) {
    int varIdx = this._fieldList.indexOf(varName);
    if (varIdx < 0) {
        return null;
    }

    DataType dt = DataType.FLOAT;
    switch (varName) {
        case "Stid":
            dt = DataType.STRING;
            break;
        case "Grade":
            dt = DataType.INT;
            break;
    }
    int[] shape = new int[1];
    shape[0] = this.stNum;
    Array r = Array.factory(dt, shape);
    int i;
    float v;
    List<String> dataList;
    //List<List<String>> allDataList = this.readData();

    for (i = 0; i < this.stNum; i++) {
        dataList = this._dataList.get(i);
        switch (dt) {
            case STRING:
                r.setObject(i, dataList.get(varIdx));
                break;
            case INT:
                int vi = Integer.parseInt(dataList.get(varIdx));
                r.setInt(i, vi);
                break;
            case FLOAT:
                v = Float.parseFloat(dataList.get(varIdx));
                r.setFloat(i, v);
                break;
        }
    }

    return r;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:52,代码来源:MICAPS2DataInfo.java

示例6: read

/**
 * Read array data of the variable
 *
 * @param varName Variable name
 * @param origin The origin array
 * @param size The size array
 * @param stride The stride array
 * @return Array data
 */
@Override
public Array read(String varName, int[] origin, int[] size, int[] stride) {
    int varIdx = this._fieldList.indexOf(varName);
    if (varIdx < 0)
        return null;
    
    DataType dt = DataType.FLOAT;
    switch (varName){
        case "Stid":
            dt = DataType.STRING;
            break;
        case "Grade":
            dt = DataType.INT;
            break;
    }
    int[] shape = new int[1];
    shape[0] = this.stNum;
    Array r = Array.factory(dt, shape);
    int i;
    float v;       
    List<String> dataList;

    for (i = 0; i < _dataList.size(); i++) {
        dataList = _dataList.get(i);
        switch (dt) {
            case STRING:
                r.setObject(i, dataList.get(varIdx));
                break;
            case INT:
                int vi = Integer.parseInt(dataList.get(varIdx));
                r.setInt(i, vi);
                break;
            case FLOAT:
                v = Float.parseFloat(dataList.get(varIdx));
                r.setFloat(i, v);
                break;
        }
    }
    
    return r;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:50,代码来源:MICAPS120DataInfo.java

示例7: read

/**
 * Read array data of the variable
 *
 * @param varName Variable name
 * @param origin The origin array
 * @param size The size array
 * @param stride The stride array
 * @return Array data
 */
@Override
public Array read(String varName, int[] origin, int[] size, int[] stride) {
    int varIdx = this._fieldList.indexOf(varName);
    if (varIdx < 0) {
        return null;
    }

    DataType dt = DataType.FLOAT;
    switch (varName) {
        case "Stid":
            dt = DataType.STRING;
            break;
        case "Grade":
        case "CloudCover":
        case "WeatherPast1":
        case "WeatherPast2":
        case "WeatherNow":
        case "MiddleCloudShape":
        case "HighCloudShape":
            dt = DataType.INT;
            break;
    }
    int[] shape = new int[1];
    shape[0] = this._stNum;
    Array r = Array.factory(dt, shape);
    int i;
    float v;
    List<String> dataList;
    List<List<String>> allDataList = this.readData();

    for (i = 0; i < allDataList.size(); i++) {
        dataList = allDataList.get(i);
        switch (dt) {
            case STRING:
                r.setObject(i, dataList.get(varIdx));
                break;
            case INT:
                int vi = Integer.parseInt(dataList.get(varIdx));
                r.setInt(i, vi);
                break;
            case FLOAT:
                v = Float.parseFloat(dataList.get(varIdx));
                if (varIdx == 8) //Pressure
                {
                    if (!MIMath.doubleEquals(v, this.getMissingValue())) {
                        if (v > 800) {
                            v = v / 10 + 900;
                        } else {
                            v = v / 10 + 1000;
                        }
                    }
                }
                r.setFloat(i, v);
                break;
        }
    }
    try {
        r = r.section(origin, shape, stride);
    } catch (InvalidRangeException ex) {
        Logger.getLogger(MICAPS1DataInfo.class.getName()).log(Level.SEVERE, null, ex);
    }

    return r;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:73,代码来源:MICAPS1DataInfo.java


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