ServerList.java (1446B)
1 /* 2 * Openrat CMS-Client for Android 3 * 4 * Copyright (C) 2011 Jan Dankert 5 * 6 * This program is free software: you can redistribute it and/or modify it under 7 * the terms of the GNU General Public License as published by the Free Software 8 * Foundation, either version 3 of the License, or (at your option) any later 9 * version. 10 * 11 * This program is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 14 * details. 15 * 16 * You should have received a copy of the GNU General Public License along with 17 * this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 package de.openrat.android.client.util; 20 21 import java.util.ArrayList; 22 import java.util.Arrays; 23 import java.util.List; 24 25 import android.text.TextUtils; 26 27 public class ServerList 28 { 29 30 private List<String> serverList; 31 32 public ServerList(String plainList) 33 { 34 if (plainList.length() == 0) 35 { 36 this.serverList = new ArrayList<String>(); 37 } 38 else 39 { 40 serverList = new ArrayList<String>(Arrays.asList(TextUtils.split( 41 plainList, ","))); 42 } 43 } 44 45 public ServerList addServer(String name) 46 { 47 this.serverList.add(name); 48 return this; 49 } 50 51 public ServerList removeServer(String name) 52 { 53 this.serverList.remove(name); 54 return this; 55 } 56 57 public String toPlain() 58 { 59 return TextUtils.join(",", serverList); 60 } 61 62 }