1 /*
2 * Copyright (C) 2002-2003, Mark Diggory
3 *
4 * This file is part of the Repast Taglibrary Package for use with Jelly.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. License
19 * information is also available at http://www.gnu.org.
20 *
21 * @author Mark Diggory <mdiggory@latte.harvard.edu>
22 */
23 package org.mrd.repast.util;
24
25 import java.util.*;
26 /***
27 *
28 * @author administrator
29 */
30 public class StringUtils {
31
32 /*** Utility method for parsing a string into a double[]
33 * @param str String containing double tokens
34 */
35 public static double[] chop(String str){
36 StringTokenizer tok = new StringTokenizer(str,",");
37 double[] table = new double[tok.countTokens()];
38 for(int i = 0; i < table.length;i++){
39 table[i] = Double.parseDouble(tok.nextToken().trim());
40 }
41 return table;
42 }
43
44 /*** Utility method for displaying a double[] as a string
45 * @param table A double[] containing tokens
46 */
47 public static String mush(double[] table){
48 StringBuffer buffer = new StringBuffer();
49 for(int i = 0; i < table.length;i++){
50 buffer.append(table[i]);
51 if(i < table.length - 1){
52 buffer.append(", ");
53 }
54 }
55 return buffer.toString();
56 }
57 }
This page was automatically generated by Maven