Example usage for java.lang IllegalArgumentException getMessage

List of usage examples for java.lang IllegalArgumentException getMessage

Introduction

In this page you can find the example usage for java.lang IllegalArgumentException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:bachelorthesis.captchabuilder.builder.GimpyParser.java

private static CaptchaBuilder parseGimpyRenderer(GimpyRendererType gimpyRendererType, String[] gimpyOptions,
        CaptchaBuilder builder) throws ParseException {
    GimpyRendererBuilder gimpyRendererBuilder = new GimpyRendererBuilder(gimpyRendererType);

    if (gimpyOptions.length == 0) {
        //return builder.gimp(gimpyRendererBuilder.create());
        builder.addBuildSequence(gimpyRendererBuilder);
        return builder;
    }/*  w  w  w .  j a va2s .  co  m*/

    if (gimpyOptions.length > GimpyRendererOptions.values().length) {
        throw new ParseException(
                "BackgroundProducer takes a max of " + GimpyRendererOptions.values().length + " arguments");
    }

    for (String gimpyRendererOption : gimpyOptions) {
        String[] optionArgs = gimpyRendererOption.split(CaptchaConstants.buildSequencelvl4Delim);
        try {
            GimpyRendererOptions gimpyRendererOptionType = GimpyRendererOptions.valueOf(optionArgs[0]);
            String[] gimpyRendererOptionArgs = Arrays.copyOfRange(optionArgs, 1, optionArgs.length);
            gimpyRendererBuilder = parseGimpyRendererOption(gimpyRendererOptionType, gimpyRendererOptionArgs,
                    gimpyRendererBuilder);
        } catch (IllegalArgumentException e) {
            throw new ParseException(e.getMessage());
        }
    }

    //return builder.gimp(gimpyRendererBuilder.create());
    builder.addBuildSequence(gimpyRendererBuilder);
    return builder;
}

From source file:bachelorthesis.captchabuilder.builder.GimpyParser.java

/**
 * Parses the string arguments for rendering transformations, creates a
 * GimpyRenderer and passes it to the CaptchaBuilder
 *
 * @param buildSequenceOptions the string arguments for building
 *                             transformations
 * @param builder              the CaptchaBuilder Object to be modified
 * <p/>// ww w  .j  a  va 2 s  . c o  m
 * @return a modified CaptchaBuilder object
 * <p/>
 * @throws org.apache.commons.cli.ParseException
 * @see CaptchaBuilder
 */
public static CaptchaBuilder parse(String[] buildSequenceOptions, CaptchaBuilder builder)
        throws ParseException {
    if (buildSequenceOptions.length == 0) {
        //return builder.gimp();
        builder.addBuildSequence(new GimpyRendererBuilder(GimpyRendererType.RIPPLE));
        return builder;
    }

    if (buildSequenceOptions.length > GimpyRendererOptions.values().length) {
        throw new ParseException("Gimp takes a max of " + GimpyRendererOptions.values().length + " arguments");
    }

    for (String gimpyOption : buildSequenceOptions) {
        if (!gimpyOption.isEmpty()) {
            try {
                String[] optionArgs = gimpyOption.split(CaptchaConstants.buildSequencelvl3Delim);
                GimpyRendererType gimpyRenenderType = GimpyRendererType.valueOf(optionArgs[0]);
                String[] gimpyOptions = Arrays.copyOfRange(optionArgs, 1, optionArgs.length);
                return parseGimpyRenderer(gimpyRenenderType, gimpyOptions, builder);
            } catch (IllegalArgumentException e) {
                throw new ParseException(e.getMessage());
            }
        }
    }

    return builder;
}

From source file:Main.java

public static void refreshJTextComponent(JTextComponent textComponent) {
    // borrowed from metaphase editor
    int pos = textComponent.getCaretPosition();
    textComponent.setText(textComponent.getText());
    textComponent.validate();/*from   ww w. ja va2s .c o  m*/
    try {
        textComponent.setCaretPosition(pos);
    } catch (IllegalArgumentException e) {
        // swallow the exception
        // seems like a bug in the JTextPane component
        // only happens occasionally when pasting text at the end of a document
        System.err.println(e.getMessage());
    }
}

From source file:bachelorthesis.captchabuilder.builder.CaptchaBuildSequenceParser.java

/**
 * Modifies the CaptchaBuilder to store a list of ElementCreatorBuilders the
 * parsers made/*from w  ww .  jav a 2 s. co m*/
 * from the buildstring.
 *
 * @param builder the CaptchBuilder object to be modified
 * <p/>
 * @throws ParseException
 * @see CaptchaBuilder
 */
public static void longParse(CaptchaBuilder builder) throws ParseException {

    for (String lvl1Arg : builder.getBuildSequence().split(CaptchaConstants.buildSequencelvl1Delim)) {
        if (!lvl1Arg.isEmpty()) {
            try {
                String[] optionArgs = lvl1Arg.split(CaptchaConstants.buildSequencelvl2Delim);
                BuildSequenceOptions buildSequenceOptionType = BuildSequenceOptions.valueOf(optionArgs[0]);
                String[] buildSequenceOptions = Arrays.copyOfRange(optionArgs, 1, optionArgs.length);

                builder = parseBuildSequenceOption(buildSequenceOptionType, buildSequenceOptions, builder);

            } catch (IllegalArgumentException e) {
                throw new ParseException(e.getMessage());
            }
        }
    }
}

From source file:edu.utah.further.core.api.message.ValidationUtil.java

/**
 * @param entityName//from  www . ja va 2  s .  com
 * @param object
 */
public static void validateNotNull(final String entityName, final Object object) {
    try {
        notNull(object, notNullMessage(entityName));
    } catch (final IllegalArgumentException e) {
        throw new BusinessRuleException(e.getMessage());
    }
}

From source file:edu.utah.further.core.api.message.ValidationUtil.java

/**
 * @param entityName/*from   w w  w .j  ava2s. c  om*/
 * @param string
 */
public static void validateNotEmpty(final String entityName, final String string) {
    try {
        notEmpty(string, notEmptyMessage(entityName));
    } catch (final IllegalArgumentException e) {
        throw new BusinessRuleException(e.getMessage());
    }
}

From source file:edu.utah.further.core.api.message.ValidationUtil.java

/**
 * @param entityName/*www. j  a v  a2 s  . co  m*/
 * @param object
 */
public static void validateNotEmpty(final String entityName, final Object[] object) {
    try {
        notEmpty(object, notEmptyMessage(entityName));
    } catch (final IllegalArgumentException e) {
        throw new BusinessRuleException(e.getMessage());
    }
}

From source file:edu.utah.further.core.api.message.ValidationUtil.java

/**
 * @param entityName/*ww w . j a  va 2s.c o m*/
 * @param object
 */
public static void validateNotEmpty(final String entityName, final Collection<?> object) {
    try {
        notEmpty(object, notEmptyMessage(entityName));
    } catch (final IllegalArgumentException e) {
        throw new BusinessRuleException(e.getMessage());
    }
}

From source file:edu.utah.further.core.api.message.ValidationUtil.java

/**
 * @param entityName/* w  w w.java  2  s  . co m*/
 * @param object
 */
public static void validateWired(final String entityName, final Object object) {
    try {
        notNull(object, notWiredMessage(entityName));
    } catch (final IllegalArgumentException e) {
        throw new BusinessRuleException(e.getMessage());
    }
}

From source file:edu.utah.further.core.api.message.ValidationUtil.java

/**
 * @param condition/*from   w  w  w.  j a va  2  s .c  o  m*/
 * @param message
 */
public static void validateIsTrue(final boolean condition, final String message) {
    try {
        isTrue(condition, message);
    } catch (final IllegalArgumentException e) {
        throw new BusinessRuleException(e.getMessage());
    }
}