本文整理汇总了Java中ucar.ma2.DataType.STRING属性的典型用法代码示例。如果您正苦于以下问题:Java DataType.STRING属性的具体用法?Java DataType.STRING怎么用?Java DataType.STRING使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类ucar.ma2.DataType
的用法示例。
在下文中一共展示了DataType.STRING属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
int[] shape = new int[1];
shape[0] = this.stNum;
DataType dt = DataType.FLOAT;
if (varName.equals("Stid"))
dt = DataType.STRING;
Array r = Array.factory(dt, shape);
List<String> dataList;
for (int i = 0; i < _dataList.size(); i++) {
dataList = _dataList.get(i);
r.setFloat(i, Float.parseFloat(dataList.get(varIdx)));
}
return r;
}
示例2: 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;
}
}
示例3: 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;
}
示例4: 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;
}
示例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":
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;
}