gt:         for (String colName : colNames) {
context: /*
   * Copyright (C) 2011 Brockmann Consult GmbH (info@brockmann-consult.de)
   *
   * This program is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License as published by the Free
   * Software Foundation; either version 3 of the License, or (at your option)
   * any later version.
   * This program is distributed in the hope that it will be useful, but WITHOUT
   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
   * more details.
   *
   * You should have received a copy of the GNU General Public License along
   * with this program; if not, see http://www.gnu.org/licenses/
   */
  
  package org.esa.snap.dataio.placemark;
  
  import com.bc.ceres.binding.Property;
  import com.bc.ceres.binding.ValidationException;
  import org.esa.snap.dataio.dimap.DimapProductConstants;
  import org.esa.snap.dataio.dimap.DimapProductHelpers;
  import org.esa.snap.framework.datamodel.Band;
  import org.esa.snap.framework.datamodel.GeoCoding;
  import org.esa.snap.framework.datamodel.GeoPos;
  import org.esa.snap.framework.datamodel.PixelPos;
  import org.esa.snap.framework.datamodel.Placemark;
  import org.esa.snap.framework.datamodel.PlacemarkDescriptor;
  import org.esa.snap.framework.datamodel.Product;
  import org.esa.snap.framework.datamodel.ProductData;
  import org.esa.snap.framework.datamodel.ProductNode;
  import org.esa.snap.util.Debug;
  import org.esa.snap.util.Guardian;
  import org.esa.snap.util.StringUtils;
  import org.esa.snap.util.SystemUtils;
  import org.esa.snap.util.XmlWriter;
  import org.esa.snap.util.io.SnapFileFilter;
  import org.jdom.Document;
  import org.jdom.Element;
  import org.jdom.input.DOMBuilder;
  import org.xml.sax.InputSource;
  import org.xml.sax.SAXException;
  
  import javax.xml.parsers.DocumentBuilder;
  import javax.xml.parsers.DocumentBuilderFactory;
  import javax.xml.parsers.FactoryConfigurationError;
  import javax.xml.parsers.ParserConfigurationException;
  import java.awt.Color;
  import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.PrintWriter;
  import java.io.PushbackReader;
  import java.io.Reader;
  import java.io.Writer;
  import java.text.DateFormat;
  import java.text.MessageFormat;
  import java.text.ParseException;
  import java.util.ArrayList;
  import java.util.Date;
  import java.util.List;
  
  /**
   * Utility class, that reads and writes placemarks from and to various plain text formats.
   *
   * @author Nobody wants to be responsible for this mess.
   * @since BEAM 1.0
   * @deprecated since BEAM 4.10, Placemark API is being fully renewed
   */
  @Deprecated
  public class PlacemarkIO {
  
      public static final String FILE_EXTENSION_FLAT_OLD = ".pnf";
      public static final String FILE_EXTENSION_XML_OLD = ".pnx";
      public static final String FILE_EXTENSION_FLAT_TEXT = ".txt";
      public static final String FILE_EXTENSION_PLACEMARK = ".placemark";
  
      private static final int INDEX_FOR_NAME = 0;
      private static final int INDEX_FOR_LON = 1;
      private static final int INDEX_FOR_LAT = 2;
      private static final int INDEX_FOR_DESC = 3;
      private static final int INDEX_FOR_LABEL = 4;
      private static final int INDEX_FOR_DATETIME = 5;
  
      private static final String LABEL_COL_NAME = "Label";
      // same columns allowed as in VectorDataNodeReader
      private static final String[] LON_COL_NAMES = {"Lon", "long", "longitude", "lon_IS"};
      private static final String[] LAT_COL_NAMES = {"Lat", "latitude", "lat_IS"};
      private static final String NAME_COL_NAME = "Name";
      private static final String[] DESC_COL_NAMES = {"Desc", "Description"};
      private static final String DATETIME_COL_NAME = "DateTime";
  
      private static final String ISO8601_PATTERN = "yyyy-MM-dd'T'HH:mm:ss";
      private static final DateFormat dateFormat = ProductData.UTC.createDateFormat(ISO8601_PATTERN);
  
      private PlacemarkIO() {
  
      }
  
      public static List<Placemark> readPlacemarks(Reader reader, GeoCoding geoCoding,
                                                   PlacemarkDescriptor placemarkDescriptor) throws IOException {
          final char[] magicBytes = new char[5];
          try (PushbackReader inputReader = new PushbackReader(reader, magicBytes.length)) {
              inputReader.read(magicBytes);
              inputReader.unread(magicBytes);
              if (XmlWriter.XML_HEADER_LINE.startsWith(new String(magicBytes))) {
                  return readPlacemarksFromXMLFile(inputReader, geoCoding, placemarkDescriptor);
              } else {
                  return readPlacemarksFromFlatFile(inputReader, geoCoding, placemarkDescriptor);
              }
          }
      }
  
      private static List<Placemark> readPlacemarksFromFlatFile(Reader reader, GeoCoding geoCoding,
                                                                PlacemarkDescriptor placemarkDescriptor) throws
              IOException {
          ArrayList<Placemark> placemarks = new ArrayList<>();
          try (BufferedReader lineReader = new BufferedReader(reader)) {
              int row = 0;
              List<Integer> stdColIndexes = null;
              int biggestIndex = 0;
              while (true) {
                  String line = lineReader.readLine();
                  if (line == null) {
                      break;
                  }
                  line = line.trim(); // cut \n and \r from the end of the line
                  if (line.isEmpty() || line.startsWith("#")) {
                      continue;
                  }
                  String[] strings = StringUtils.toStringArray(line, "\t");
                  if (stdColIndexes == null) {
                      int nameIndex = findColumnIndex(strings, NAME_COL_NAME);
                      int lonIndex = findColumnIndex(strings, LON_COL_NAMES);
                      int latIndex = findColumnIndex(strings, LAT_COL_NAMES);
                      int descIndex = findColumnIndex(strings, DESC_COL_NAMES);
                      int labelIndex = findColumnIndex(strings, LABEL_COL_NAME);
                      int dateTimeIndex = findColumnIndex(strings, DATETIME_COL_NAME);
                      if (nameIndex == -1 || lonIndex == -1 || latIndex == -1) {
                          throw new IOException("Invalid placemark file format:\n" +
                                                "at least the columns 'Name', 'Lon' and 'Lat' must be given.");
                      }
                      biggestIndex = biggestIndex > nameIndex ? biggestIndex : nameIndex;
                      biggestIndex = biggestIndex > lonIndex ? biggestIndex : lonIndex;
                      biggestIndex = biggestIndex > latIndex ? biggestIndex : latIndex;
                      stdColIndexes = new ArrayList<>(6);
                      stdColIndexes.add(INDEX_FOR_NAME, nameIndex);
                      stdColIndexes.add(INDEX_FOR_LON, lonIndex);
                      stdColIndexes.add(INDEX_FOR_LAT, latIndex);
                      stdColIndexes.add(INDEX_FOR_DESC, descIndex);
                      stdColIndexes.add(INDEX_FOR_LABEL, labelIndex);
                      stdColIndexes.add(INDEX_FOR_DATETIME, dateTimeIndex);
  
                  } else {
                      row++;
                      if (strings.length > biggestIndex) {
                          String name = strings[stdColIndexes.get(INDEX_FOR_NAME)];
                          double lon;
                          try {
                              lon = Double.parseDouble(strings[stdColIndexes.get(INDEX_FOR_LON)]);
                          } catch (NumberFormatException ignored) {
                              throw new IOException("Invalid placemark file format:\n" +
                                                    "data row " + row + ": value for 'Lon' is invalid");      /*I18N*/
                          }
                          double lat;
                          try {
                              lat = Double.parseDouble(strings[stdColIndexes.get(INDEX_FOR_LAT)]);
                          } catch (NumberFormatException ignored) {
                              throw new IOException("Invalid placemark file format:\n" +
                                                    "data row " + row + ": value for 'Lat' is invalid");      /*I18N*/
                          }
                          String label = name;
                          final Integer labelIndex = stdColIndexes.get(INDEX_FOR_LABEL);
                          if (labelIndex >= 0 && strings.length > labelIndex) {
                              label = strings[labelIndex];
                          }
  
                          Placemark placemark = Placemark.createPointPlacemark(placemarkDescriptor, name, label, "", null, new GeoPos(lat, lon),
                                                                               geoCoding);
                          String desc = null;
                          final Integer descIndex = stdColIndexes.get(INDEX_FOR_DESC);
                          if (descIndex >= 0 && strings.length > descIndex) {
                              desc = strings[descIndex];
                          }
                          if (desc != null) {
                              placemark.setDescription(desc);
                          }
  
                          final Integer dateTimeIndex = stdColIndexes.get(INDEX_FOR_DATETIME);
                          if (dateTimeIndex >= 0 && strings.length > dateTimeIndex) {
                              try {
                                  final Date date = dateFormat.parse(strings[dateTimeIndex]);
                                  placemark.getFeature().setAttribute(Placemark.PROPERTY_NAME_DATETIME, date);
                              } catch (ParseException ignored) {
                              }
                          }
                          placemarks.add(placemark);
                      } else {
                          throw new IOException("Invalid placemark file format:\n" +
                                                "data row " + row + ": values for 'Name', 'Lon' and 'Lat' must be given.");   /*I18N*/
                      }
                  }
              }
          }
  
          return placemarks;
      }
  
      static int findColumnIndex(String[] strings, String... colNames) {
          int index = -1;
  