Commit b6256781edc2678f0a84ae389b5d7773a69bebbf

Authored by Nathanael Jourdane
1 parent 42819b99
Exists in master

Implement StringJoiner()

src/main/java/eu/omp/irap/vespa/epntapclient/votable/Utils.java 0 → 100644
... ... @@ -0,0 +1,50 @@
  1 +/*
  2 + * This file is a part of EpnTAPClient.
  3 + * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer.
  4 + * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861
  5 + * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie.
  6 + *
  7 + * This program is free software: you can
  8 + * redistribute it and/or modify it under the terms of the GNU General Public License as published
  9 + * by the Free Software Foundation, either version 3 of the License, or (at your option) any later
  10 + * version. This program is distributed in the hope that it will be useful, but WITHOUT ANY
  11 + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  12 + * PURPOSE. See the GNU General Public License for more details. You should have received a copy of
  13 + * the GNU General Public License along with this program. If not, see
  14 + * <http://www.gnu.org/licenses/>.
  15 + */
  16 +
  17 +package eu.omp.irap.vespa.epntapclient.votable;
  18 +
  19 +import java.util.ArrayList;
  20 +import java.util.List;
  21 +
  22 +/**
  23 + * @author N. Jourdane
  24 + */
  25 +public class Utils {
  26 + public static class StringJoiner {
  27 + String separator;
  28 + List<String> list;
  29 + String string;
  30 +
  31 + public StringJoiner(String separator) {
  32 + this.separator = separator;
  33 + this.list = new ArrayList();
  34 + string = "";
  35 + }
  36 +
  37 + public void add(String text) {
  38 + if ("".equals(string)) {
  39 + string = text;
  40 + } else {
  41 + string += separator + text;
  42 + }
  43 + }
  44 +
  45 + @Override
  46 + public String toString() {
  47 + return string;
  48 + }
  49 + }
  50 +}
... ...