Example usage for java.util IllegalFormatException getClass

List of usage examples for java.util IllegalFormatException getClass

Introduction

In this page you can find the example usage for java.util IllegalFormatException getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:wjhk.jupload2.policies.DefaultUploadPolicy.java

/** @see UploadPolicy#getLocalizedString(String, Object...) */
public String getLocalizedString(String key, Object... args) {
    String ret = this.resourceBundle.getString(key);
    try {/* w w  w .j av  a 2s  .co  m*/
        // We have to recreate the correct call to String.format
        switch (args.length) {
        case 0:
            return String.format(ret);
        case 1:
            return String.format(ret, args[0]);
        case 2:
            return String.format(ret, args[0], args[1]);
        case 3:
            return String.format(ret, args[0], args[1], args[2]);
        case 4:
            return String.format(ret, args[0], args[1], args[2], args[3]);
        case 5:
            return String.format(ret, args[0], args[1], args[2], args[3], args[4]);
        case 6:
            return String.format(ret, args[0], args[1], args[2], args[3], args[4], args[5]);
        case 7:
            return String.format(ret, args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
        default:
            throw new IllegalArgumentException(
                    "DefaultUploadPolicy.getLocalizedString accepts up to 7 variable parameters (" + args.length
                            + " values were given for the 'args' argument");
        }
    } catch (IllegalFormatException ife) {
        displayErr(ife.getClass().getName() + " (" + ife.getMessage() + ")when managing this string: " + ret);
        throw ife;
    }
}