Example usage for org.eclipse.jface.resource StringConverter asInt

List of usage examples for org.eclipse.jface.resource StringConverter asInt

Introduction

In this page you can find the example usage for org.eclipse.jface.resource StringConverter asInt.

Prototype

public static int asInt(String value) throws DataFormatException 

Source Link

Document

Converts the given value into an int.

Usage

From source file:org.codecover.eclipse.preferences.RGBWithBoundaries.java

License:Open Source License

/**
 * Sets the values of this RGBWithBoundaries according to the given string,
 * which can be created by calling toString(). UpperBoundary & lowerBoundary
 * are set so lowerBoundary <= upperBoundary
 * /*from  www  .  j  ava2 s  . c om*/
 * @param string
 *            an encoding of a RGBWithBoundaries
 * @throws DataFormatException
 *             thrown, if stringformat doesn't fit
 */
public void setValues(String string) throws DataFormatException {
    String[] elements = string.split(SEPERATOR);
    if (elements.length == 3) {
        this.setValues(StringConverter.asRGB(elements[0]), StringConverter.asInt(elements[1]),
                StringConverter.asInt(elements[2]));
    } else {
        throw new DataFormatException("Invalid data format. " //$NON-NLS-1$
                + string + " doesn't consist of three parts devided by \"" //$NON-NLS-1$
                + SEPERATOR + "\""); //$NON-NLS-1$
    }
}