Here you can find the source of stringToItems(List
Parameter | Description |
---|---|
fontsList | List of array of fonts (every list is a category) |
useSeparator | specify if a separator must be used between each category |
public static String[] stringToItems(List<String[]> fontsList, boolean useSeparator)
//package com.java2s; /******************************************************************************* * Copyright (C) 2005 - 2014 TIBCO Software Inc. All rights reserved. * http://www.jaspersoft.com.//w w w . j a va 2s . c om * * Unless you have purchased a commercial license agreement from Jaspersoft, * the following license terms apply: * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html ******************************************************************************/ import java.util.ArrayList; import java.util.List; public class Main { public static String separator = "__________________"; /** * Convert a list of array of string into a single array of string, ready to be inserted into a combo * * @param fontsList * List of array of fonts (every list is a category) * @param useSeparator * specify if a separator must be used between each category * * @return List of combo item */ public static String[] stringToItems(List<String[]> fontsList, boolean useSeparator) { List<String> itemsList = new ArrayList<String>(); for (int index = 0; index < fontsList.size(); index++) { String[] fonts = fontsList.get(index); for (String element : fonts) itemsList.add(element); if (index + 1 != fontsList.size() && fonts.length > 0 && useSeparator) itemsList.add(separator); } String[] result = new String[itemsList.size()]; return itemsList.toArray(result); } /** * Convert a list of array of string into a single array of string, ready to be inserted into a combo * * @param fontsList * List of array of fonts, between every array will be inserted a separator * @return List of combo item */ public static String[] stringToItems(List<String[]> fontsList) { return stringToItems(fontsList, true); } }