Example usage for java.text MessageFormat getClass

List of usage examples for java.text MessageFormat getClass

Introduction

In this page you can find the example usage for java.text MessageFormat getClass.

Prototype

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

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:com.jkoolcloud.tnt4j.streams.fields.ActivityInfo.java

private static String formatArrayPattern(String pattern, Object[] vArray) {
    MessageFormat mf = new MessageFormat(pattern);

    try {/*from   w ww . ja va 2  s . c  o  m*/
        Field f = mf.getClass().getDeclaredField("maxOffset");
        f.setAccessible(true);
        int maxOffset = f.getInt(mf);
        if (maxOffset >= 0) {
            f = mf.getClass().getDeclaredField("argumentNumbers");
            f.setAccessible(true);
            int[] ana = (int[]) f.get(mf);
            int maxIndex = ana[maxOffset];

            if (maxIndex >= vArray.length) {
                LOGGER.log(OpLevel.WARNING,
                        StreamsResources.getString(StreamsResources.RESOURCE_BUNDLE_NAME,
                                "ActivityInfo.formatting.arguments.mismatch"),
                        pattern, maxIndex, ArrayUtils.getLength(vArray));
            }
        }
    } catch (Exception exc) {
    }

    return mf.format(vArray);
}