Package fitnesse.slim.converters

Source Code of fitnesse.slim.converters.BooleanArrayConverter

// Copyright (C) 2003-2009 by Object Mentor, Inc. All rights reserved.
// Released under the terms of the CPL Common Public License version 1.0.
package fitnesse.slim.converters;

import java.util.Arrays;

import fitnesse.slim.Converter;
import fitnesse.slim.SlimError;

@SuppressWarnings("rawtypes")
public class BooleanArrayConverter implements Converter {
  private static final BooleanConverter booleanConverter = new BooleanConverter();

  public String toString(Object o) {
    if (o == null) return "null";
    Boolean[] booleans = (Boolean[]) o;
    return Arrays.asList(booleans).toString();
  }

  public Object fromString(String arg) {
    String[] strings = ListConverter.fromStringToArrayOfStrings(arg);
    Boolean[] booleans = new Boolean[strings.length];
    for (int i = 0; i < strings.length; i++) {
      try {
        booleans[i] = booleanConverter.fromString(strings[i]);
      } catch (NumberFormatException e) {
        throw new SlimError("message:<<CANT_CONVERT_TO_BOOLEAN_LIST>>");
      }
    }
    return booleans;
  }
}
TOP

Related Classes of fitnesse.slim.converters.BooleanArrayConverter

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.