Example usage for org.apache.commons.beanutils ConversionException ConversionException

List of usage examples for org.apache.commons.beanutils ConversionException ConversionException

Introduction

In this page you can find the example usage for org.apache.commons.beanutils ConversionException ConversionException.

Prototype

public ConversionException(String message, Throwable cause) 

Source Link

Document

Construct a new exception with the specified message and root cause.

Usage

From source file:ca.sqlpower.wabit.dao.session.PNGImageConverter.java

public Image convertToComplexType(InputStream convertFrom) throws ConversionException {
    try {/*from ww  w  .j  a va  2  s. co m*/
        BufferedImage img = ImageIO.read(convertFrom);
        return img;
    } catch (Exception e) {
        throw new ConversionException("Cannot convert the given image", e);
    }
}

From source file:ca.sqlpower.wabit.dao.session.CubeConverter.java

public Cube convertToComplexType(String convertFrom) throws ConversionException {

    String[] pieces = PersisterUtils.splitByDelimiter(convertFrom, 4);

    Olap4jDataSource ds = dsCollection.getDataSource(pieces[0], Olap4jDataSource.class);

    Catalog catalog;/*from  w  ww  .  j a  v a 2 s  .c o  m*/
    try {
        catalog = mapping.createConnection(ds).getCatalogs().get(pieces[1]);
    } catch (Exception ex) {
        throw new ConversionException(
                "Error connecting to data source " + pieces[0] + " to get cube defined by " + convertFrom, ex);
    }
    Schema schema;
    try {
        schema = catalog.getSchemas().get(pieces[2]);
        Cube cube = schema.getCubes().get(pieces[3]);
        return cube;
    } catch (OlapException e) {
        throw new ConversionException("The cube could not be retrieved from the string " + convertFrom, e);
    }
}

From source file:net.joinedminds.masserr.util.IdentifiableBeanConverter.java

@Override
public Object convert(Class type, Object value) {
    if (type.isAssignableFrom(value.getClass())) {
        return value;
    }/* w w  w .  ja va 2s . c om*/
    Constructor constructor;
    try {
        try {
            constructor = type.getConstructor(value.getClass());
            return constructor.newInstance(value);
        } catch (NoSuchMethodException e) {
            try {
                constructor = type.getConstructor(String.class);
                return constructor.newInstance(value.toString());
            } catch (NoSuchMethodException e1) {
                throw new ConversionException("Could not find single parameter constructor.", e1);
            }
        }
    } catch (Exception e) {
        throw new ConversionException("Could not construct " + type.getName(), e);
    }
}

From source file:com.puppycrawl.tools.checkstyle.checks.AbstractOptionCheck.java

/**
 * Set the option to enforce.//from  w  w w. j  a v  a 2s  .  com
 * @param optionStr string to decode option from
 * @throws ConversionException if unable to decode
 */
public void setOption(String optionStr) {
    try {
        abstractOption = Enum.valueOf(optionClass, optionStr.trim().toUpperCase(Locale.ENGLISH));
    } catch (IllegalArgumentException iae) {
        throw new ConversionException("unable to parse " + abstractOption, iae);
    }
}

From source file:com.puppycrawl.tools.checkstyle.checks.usage.AbstractUsageCheck.java

/**
 * Set the ignore format to the specified regular expression.
 * @param aFormat a <code>String</code> value
 * @throws ConversionException unable to parse aFormat
 *//*from w  ww. j  a  v  a 2s .c  o  m*/
public void setIgnoreFormat(String aFormat) throws ConversionException {
    try {
        mRegexp = Utils.getPattern(aFormat);
        mIgnoreFormat = aFormat;
    } catch (PatternSyntaxException e) {
        throw new ConversionException("unable to parse " + aFormat, e);
    }
}

From source file:com.puppycrawl.tools.checkstyle.checks.UncommentedMainCheck.java

/**
 * Set the excluded classes pattern./*  w  ww .  ja va  2  s  . c  o m*/
 * @param excludedClasses a <code>String</code> value
 * @throws ConversionException unable to parse excludedClasses
 */
public void setExcludedClasses(String excludedClasses) throws ConversionException {
    try {
        this.excludedClasses = excludedClasses;
        excludedClassesPattern = Utils.getPattern(excludedClasses);
    } catch (final PatternSyntaxException e) {
        throw new ConversionException("unable to parse " + excludedClasses, e);
    }
}

From source file:com.puppycrawl.tools.checkstyle.checks.whitespace.AbstractParenPadCheck.java

/**
 * Set the option to enforce./*  w  w  w . ja v  a  2s  . c  o  m*/
 * @param optionStr string to decode option from
 * @throws ConversionException if unable to decode
 */
public void setOption(String optionStr) {
    try {
        option = PadOption.valueOf(optionStr.trim().toUpperCase(Locale.ENGLISH));
    } catch (IllegalArgumentException iae) {
        throw new ConversionException("unable to parse " + optionStr, iae);
    }
}

From source file:com.puppycrawl.tools.checkstyle.checks.AbstractFormatCheck.java

/**
 * Updates the regular expression using the supplied format and compiler
 * flags. Will also update the member variables.
 * @param regexpFormat the format of the regular expression.
 * @param compileFlagsParam the compiler flags to use.
 *///from   ww w.j a  v  a  2s  . c o m
private void updateRegexp(String regexpFormat, int compileFlagsParam) {
    try {
        regexp = Pattern.compile(regexpFormat, compileFlagsParam);
        format = regexpFormat;
        compileFlags |= compileFlagsParam;
    } catch (final PatternSyntaxException e) {
        throw new ConversionException("unable to parse " + regexpFormat, e);
    }
}

From source file:com.puppycrawl.tools.checkstyle.checks.NewlineAtEndOfFileCheck.java

/**
 * Sets the line separator to one of 'crlf', 'lf','cr', 'lf_cr_crlf' or 'system'.
 *
 * @param lineSeparatorParam The line separator to set
 * @throws IllegalArgumentException If the specified line separator is not
 *         one of 'crlf', 'lf', 'cr', 'lf_cr_crlf' or 'system'
 *//*from  w  w  w  .ja v a  2s  .  c om*/
public void setLineSeparator(String lineSeparatorParam) {
    try {
        lineSeparator = Enum.valueOf(LineSeparatorOption.class,
                lineSeparatorParam.trim().toUpperCase(Locale.ENGLISH));
    } catch (IllegalArgumentException iae) {
        throw new ConversionException("unable to parse " + lineSeparatorParam, iae);
    }
}

From source file:com.puppycrawl.tools.checkstyle.Utils.java

/**
 * Helper method to create a regular expression.
 * @param pattern the pattern to match//from   w ww .  j  av a  2 s.  c  o m
 * @return a created regexp object
 * @throws ConversionException if unable to create Pattern object.
 **/
public static Pattern createPattern(String pattern) throws ConversionException {
    try {
        return Pattern.compile(pattern);
    } catch (final PatternSyntaxException e) {
        throw new ConversionException("Failed to initialise regular expression " + pattern, e);
    }
}