001/* 002 * Copyright 2018 Leibniz-Institut für Analytische Wissenschaften – ISAS – e.V.. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package uk.ac.ebi.pride.jmztab2.model; 017 018import java.util.ArrayList; 019 020/** 021 * This is list which each item split by a split char. 022 * 023 * @author qingwei 024 * @param <E> the generic element type of the list. 025 * @since 31/01/13 026 * 027 */ 028public class SplitList<E> extends ArrayList<E> { 029 private char splitChar; 030 031 /** 032 * <p>Constructor for SplitList.</p> 033 * 034 * @param splitChar a char. 035 */ 036 public SplitList(char splitChar) { 037 this.splitChar = splitChar; 038 } 039 040 /** 041 * <p>Getter for the field <code>splitChar</code>.</p> 042 * 043 * @return a char. 044 */ 045 public char getSplitChar() { 046 return splitChar; 047 } 048 049 /** 050 * <p>Setter for the field <code>splitChar</code>.</p> 051 * 052 * @param splitChar a char. 053 */ 054 public void setSplitChar(char splitChar) { 055 this.splitChar = splitChar; 056 } 057 058 /** {@inheritDoc} */ 059 @Override 060 public String toString() { 061 if (isEmpty()) { 062 return ""; 063 } 064 065 StringBuilder sb = new StringBuilder(); 066 sb.append(get(0)); 067 068 for (int i = 1; i < size(); i++) { 069 sb.append(splitChar).append(get(i)); 070 } 071 072 return sb.toString(); 073 } 074}