Пример #1
0
 /**
  * Returns the phenomenon that the given variable represents.
  *
  * <p>This name will be, in order of preference:
  *
  * <p>The standard name
  *
  * <p>The long name
  *
  * <p>The variable name
  */
 private static String getVariableName(Variable var) {
   Attribute stdNameAtt = var.findAttributeIgnoreCase("standard_name");
   if (stdNameAtt == null || stdNameAtt.getStringValue().trim().equals("")) {
     Attribute longNameAtt = var.findAttributeIgnoreCase("long_name");
     if (longNameAtt == null || longNameAtt.getStringValue().trim().equals("")) {
       return var.getFullName();
     } else {
       return longNameAtt.getStringValue();
     }
   } else {
     return stdNameAtt.getStringValue();
   }
 }
  private static IndexCoding readIndexCoding(Variable variable, String indexCodingName)
      throws ProductIOException {
    final IndexCoding indexCoding = CfIndexCodingPart.readIndexCoding(variable, indexCodingName);

    if (indexCoding != null) {
      final Attribute descriptionsAtt = variable.findAttributeIgnoreCase(INDEX_DESCRIPTIONS);
      if (descriptionsAtt != null) {
        final String[] descriptions = descriptionsAtt.getStringValue().split(DESCRIPTION_SEPARATOR);
        if (indexCoding.getNumAttributes() == descriptions.length) {
          for (int i = 0; i < descriptions.length; i++) {
            indexCoding.getAttributeAt(i).setDescription(descriptions[i]);
          }
        }
      }
      final Attribute nameAtt = variable.findAttributeIgnoreCase(INDEX_CODING_NAME);
      if (nameAtt != null) {
        indexCoding.setName(nameAtt.getStringValue());
      }
    }
    return indexCoding;
  }