Formats event output by key, usually equal to the method name.

@param key the event key
@param defaultPattern the default pattern to return if a custom pattern
is not found
@param args the args used to format output
@return A formatted event output
169710
protected String format(String key, String defaultPattern, Object... args) {
        String escape = escape(defaultPattern);
        String s = lookupPattern(key, escape);
        Object[] objects = escapeAll(args);
        return MessageFormat.format(s, objects);
    }
598421
@Override
    public final void applyPattern(String pattern)
    {

        if (hasRegistry())
        {
            super.applyPattern(pattern);
            toPattern = super.toPattern();
            return;
        }

        ArrayList<Format> foundFormats = new ArrayList<Format>();
        ArrayList<String> foundDescriptions = new ArrayList<String>();
        StringBuilder stripCustom = new StringBuilder(pattern.length());

        ParsePosition pos = new ParsePosition(0);
        char[] c = pattern.toCharArray();
        int fmtCount = 0;

        while (pos.getIndex() < pattern.length())
        {

            char charType = c[pos.getIndex()];

            if (QUOTE == charType)
            {

                appendQuotedString(pattern, pos, stripCustom, true);
                continue;

            }

            if (START_FE == charType)
            {

                fmtCount++;
                seekNonWs(pattern, pos);
                int start = pos.getIndex();
                int index = readArgumentIndex(pattern, next(pos));
                stripCustom.append(START_FE).append(index);
                seekNonWs(pattern, pos);
                Format format = null;
                String formatDescription = null;
                if (c[pos.getIndex()] == START_FMT)
                {
                    formatDescription = parseFormatDescription(pattern, next(pos));
                    format = getFormat(formatDescription);
                    if (format == null)
                    {
                        stripCustom.append(START_FMT).append(formatDescription);
                    }
                }
                foundFormats.add(format);
                foundDescriptions.add(format == null ? null : formatDescription);

                Preconditions.checkState(foundFormats.size() == fmtCount);
                Preconditions.checkState(foundDescriptions.size() == fmtCount);

                if (c[pos.getIndex()] != END_FE)
                {
                    throw new IllegalArgumentException("Unreadable format element at position " + start);
                }

            }

            //$FALL-THROUGH$
            stripCustom.append(c[pos.getIndex()]);
            next(pos);

        }

        super.applyPattern(stripCustom.toString());

        toPattern = insertFormats(super.toPattern(), foundDescriptions);

        if (containsElements(foundFormats))
        {
            Format[] origFormats = getFormats();
            // only loop over what we know we have, as MessageFormat on Java 1.3
            // seems to provide an extra format element:
            Iterator<Format> it = foundFormats.iterator();
            for (int i = 0; it.hasNext(); i++)
            {
                Format f = it.next();
                if (f != null)
                {
                    origFormats[i] = f;
                }
            }
            super.setFormats(origFormats);
        }

    }
853641
public void applyPattern(String newPattern) {
        StringBuffer[] segments = new StringBuffer[2];
        for (int i = 0; i < segments.length; ++i) {
            segments[i] = new StringBuffer();
        }
        double[] newChoiceLimits = new double[30];
        String[] newChoiceFormats = new String[30];
        int count = 0;
        int part = 0;
        double startValue = 0;
        double oldStartValue = Double.NaN;
        boolean inQuote = false;
        for (int i = 0; i < newPattern.length(); ++i) {
            char ch = newPattern.charAt(i);
            if (ch=='\'') {
                // Check for "''" indicating a literal quote
                if ((i+1)<newPattern.length() && newPattern.charAt(i+1)==ch) {
                    segments[part].append(ch);
                    ++i;
                } else {
                    inQuote = !inQuote;
                }
            } else if (inQuote) {
                segments[part].append(ch);
            } else if (ch == '<' || ch == '#' || ch == '\u2264') {
                if (segments[0].length() == 0) {
                    throw new IllegalArgumentException();
                }
                try {
                    String tempBuffer = segments[0].toString();
                    if (tempBuffer.equals("\u221E")) {
                        startValue = Double.POSITIVE_INFINITY;
                    } else if (tempBuffer.equals("-\u221E")) {
                        startValue = Double.NEGATIVE_INFINITY;
                    } else {
                        startValue = Double.valueOf(segments[0].toString()).doubleValue();
                    }
                } catch (Exception e) {
                    throw new IllegalArgumentException();
                }
                if (ch == '<' && startValue != Double.POSITIVE_INFINITY &&
                        startValue != Double.NEGATIVE_INFINITY) {
                    startValue = nextDouble(startValue);
                }
                if (startValue <= oldStartValue) {
                    throw new IllegalArgumentException();
                }
                segments[0].setLength(0);
                part = 1;
            } else if (ch == '|') {
                if (count == newChoiceLimits.length) {
                    newChoiceLimits = doubleArraySize(newChoiceLimits);
                    newChoiceFormats = doubleArraySize(newChoiceFormats);
                }
                newChoiceLimits[count] = startValue;
                newChoiceFormats[count] = segments[1].toString();
                ++count;
                oldStartValue = startValue;
                segments[1].setLength(0);
                part = 0;
            } else {
                segments[part].append(ch);
            }
        }
        // clean up last one
        if (part == 1) {
            if (count == newChoiceLimits.length) {
                newChoiceLimits = doubleArraySize(newChoiceLimits);
                newChoiceFormats = doubleArraySize(newChoiceFormats);
            }
            newChoiceLimits[count] = startValue;
            newChoiceFormats[count] = segments[1].toString();
            ++count;
        }
        choiceLimits = new double[count];
        System.arraycopy(newChoiceLimits, 0, choiceLimits, 0, count);
        choiceFormats = new String[count];
        System.arraycopy(newChoiceFormats, 0, choiceFormats, 0, count);
    }
1327919
public static <S, T extends Event, U extends T> InputMapTemplate<S, U> ignore(
            EventPattern<? super T, ? extends U> eventPattern) {
        return new PatternActionTemplate<>(eventPattern, PatternActionTemplate.CONST_IGNORE);
    }
984579
public String formatMessage(String key, Object[] args) {
		try {
			String raw = this.getMessage(key);
			return MessageFormat.format(raw, args);
		} catch (MissingResourceException ex) {
			return "???!"+key+"!???";
		}
	}
1280621
public static CharSequence matchesPattern(final CharSequence input, final String pattern, final String message) {
        return INSTANCE.matchesPattern(input, pattern, message);
    }
841368
public static String getFormattedString(String key, Object... arguments) {
		// échappement des quotes qui sont des caractères spéciaux pour MessageFormat
		final String string = getString(key).replace("'", "''");
		return new MessageFormat(string, getCurrentLocale()).format(arguments);
	}
672847
public static String format(final Calendar calendar, final String pattern) {
        return format(calendar, pattern, null, null);
    }
1228738
public static String format(String formatString, Object... args) {
    // Rewrites the varargs so that objects that need special formatting are
    // replaced with formatted strings, then hands off to {@link String#format}.

    Object[] formattedArgs = new Object[args.length];
    for (int i = 0; i < args.length; ++i) {
      formattedArgs[i] = formatObject(args[i]);
    }

    return String.format(formatString, (Object[]) formattedArgs);
  }
341637
private static String format(String template, @javax.annotation.Nullable Object... args) {
    // If no arguments return the template.
    if (args == null) {
      return template;
    }

    // start substituting the arguments into the '%s' placeholders
    StringBuilder builder = new StringBuilder(template.length() + 16 * args.length);
    int templateStart = 0;
    int i = 0;
    while (i < args.length) {
      int placeholderStart = template.indexOf("%s", templateStart);
      if (placeholderStart == -1) {
        break;
      }
      builder.append(template, templateStart, placeholderStart);
      builder.append(args[i++]);
      templateStart = placeholderStart + 2;
    }
    builder.append(template, templateStart, template.length());

    // if we run out of placeholders, append the extra args in square braces
    if (i < args.length) {
      builder.append(" [");
      builder.append(args[i++]);
      while (i < args.length) {
        builder.append(", ");
        builder.append(args[i++]);
      }
      builder.append(']');
    }

    return builder.toString();
  }
295599
static String format(final String messagePattern, final Object[] arguments) {
        final StringBuilder result = new StringBuilder();
        final int argCount = arguments == null ? 0 : arguments.length;
        formatMessage(result, messagePattern, arguments, argCount);
        return result.toString();
    }
737817
protected String internalFormatMessage(String pattern, Object[] args) {
        /* todo: perf -- could the MessageFormat objects be cached? */
        MessageFormat format = new MessageFormat(pattern);
        String msg = format.format(args).toString();
        return msg;
    }
770798
public String formatMessage(String key, Object[] args) {
        assert _resourceProvider != null : "Received a null resource provider";
        return _resourceProvider.formatMessage(key, args);
    }
477473
private static synchronized String getDefaultPattern() {
        ULocale defaultLocale = ULocale.getDefault(Category.FORMAT);
        if (!defaultLocale.equals(cachedDefaultLocale)) {
            cachedDefaultLocale = defaultLocale;
            Calendar cal = Calendar.getInstance(cachedDefaultLocale);

            try {
                // Load the calendar data directly.
                ICUResourceBundle rb = (ICUResourceBundle) UResourceBundle.getBundleInstance(
                        ICUData.ICU_BASE_NAME, cachedDefaultLocale);
                String resourcePath = "calendar/" + cal.getType() + "/DateTimePatterns";
                ICUResourceBundle patternsRb= rb.findWithFallback(resourcePath);

                if (patternsRb == null) {
                    patternsRb = rb.findWithFallback("calendar/gregorian/DateTimePatterns");
                }
                if (patternsRb == null || patternsRb.getSize() < 9) {
                    cachedDefaultPattern = FALLBACKPATTERN;
                } else {
                    int defaultIndex = 8;
                    if (patternsRb.getSize() >= 13) {
                        defaultIndex += (SHORT + 1);
                    }
                    String basePattern = patternsRb.getString(defaultIndex);

                    cachedDefaultPattern = SimpleFormatterImpl.formatRawPattern(
                            basePattern, 2, 2,
                            patternsRb.getString(SHORT), patternsRb.getString(SHORT + 4));
                }
            } catch (MissingResourceException e) {
                cachedDefaultPattern = FALLBACKPATTERN;
            }
        }
        return cachedDefaultPattern;
    }
1298928
public static <S, T extends Event, U extends T> InputMapTemplate<S, U> process(
            EventPattern<? super T, ? extends U> eventPattern,
            BiFunction<? super S, ? super U, InputHandler.Result> action) {
        return new PatternActionTemplate<>(eventPattern, action);
    }
515326
public String format(String key) {
        if (traceNLS != null) {
            return traceNLS.getString(key);
        } else {
            return key;
        }
    }
364499
public String format(final String code, @Nullable final Object... args) {
    String pattern = getMessage(code);
    if (args != null) {
      return String.format(pattern, args);
    }
    else {
      return pattern;
    }
  }