private int addAttributes(opendap.dap.AttributeTable table, Variable v, Iterator iter) { int count = 0; // add attribute table for this variable while (iter.hasNext()) { Attribute att = (Attribute) iter.next(); int dods_type = DODSNetcdfFile.convertToDODSType(att.getDataType(), false); try { String attName = NcDDS.escapeName(att.getName()); if (att.isString()) { /* FIX String value = escapeAttributeStringValues(att.getStringValue()); table.appendAttribute(attName, dods_type, "\""+value+"\""); */ table.appendAttribute(attName, dods_type, att.getStringValue()); } else { // cant send signed bytes if (att.getDataType() == DataType.BYTE) { boolean signed = false; for (int i = 0; i < att.getLength(); i++) { if (att.getNumericValue(i).byteValue() < 0) signed = true; } if (signed) // promote to signed short dods_type = opendap.dap.Attribute.INT16; } for (int i = 0; i < att.getLength(); i++) table.appendAttribute(attName, dods_type, att.getNumericValue(i).toString()); } count++; } catch (Exception e) { log.error( "Error appending attribute " + att.getName() + " = " + att.getStringValue() + "\n" + e); } } // loop over variable attributes // kludgy thing to map char arrays to DODS Strings if ((v != null) && (v.getDataType().getPrimitiveClassType() == char.class)) { int rank = v.getRank(); int strlen = (rank == 0) ? 0 : v.getShape(rank - 1); Dimension dim = (rank == 0) ? null : v.getDimension(rank - 1); try { opendap.dap.AttributeTable dodsTable = table.appendContainer("DODS"); dodsTable.appendAttribute("strlen", opendap.dap.Attribute.INT32, Integer.toString(strlen)); if ((dim != null) && dim.isShared()) dodsTable.appendAttribute("dimName", opendap.dap.Attribute.STRING, dim.getName()); count++; } catch (Exception e) { log.error("Error appending attribute strlen\n" + e); } } return count; }