/** * CDL representation * * @param strict if true, create strict CDL, escaping names * @return CDL representation */ public String toString(boolean strict) { StringBuilder buff = new StringBuilder(); buff.append(strict ? NetcdfFile.escapeNameCDL(getName()) : getName()); if (isString()) { buff.append(" = "); for (int i = 0; i < getLength(); i++) { if (i != 0) buff.append(", "); String val = getStringValue(i); if (val != null) buff.append("\"").append(NCdumpW.encodeString(val)).append("\""); } } else { buff.append(" = "); for (int i = 0; i < getLength(); i++) { if (i != 0) buff.append(", "); buff.append(getNumericValue(i)); if (dataType == DataType.FLOAT) buff.append("f"); else if (dataType == DataType.SHORT) { if (isUnsigned()) buff.append("US"); else buff.append("S"); } else if (dataType == DataType.BYTE) { if (isUnsigned()) buff.append("UB"); else buff.append("B"); } else if (dataType == DataType.LONG) { if (isUnsigned()) buff.append("UL"); else buff.append("L"); } else if (dataType == DataType.INT) { if (isUnsigned()) buff.append("U"); } } } return buff.toString(); }