亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? messageformatter.java

?? Java開發最新的日志記錄工具slf4j的源碼
?? JAVA
字號:
/* 
 * Copyright (c) 2004-2007 QOS.ch
 * All rights reserved.
 * 
 * Permission is hereby granted, free  of charge, to any person obtaining
 * a  copy  of this  software  and  associated  documentation files  (the
 * "Software"), to  deal in  the Software without  restriction, including
 * without limitation  the rights to  use, copy, modify,  merge, publish,
 * distribute,  sublicense, and/or sell  copies of  the Software,  and to
 * permit persons to whom the Software  is furnished to do so, subject to
 * the following conditions:
 * 
 * The  above  copyright  notice  and  this permission  notice  shall  be
 * included in all copies or substantial portions of the Software.
 * 
 * THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
 * EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
 * MERCHANTABILITY,    FITNESS    FOR    A   PARTICULAR    PURPOSE    AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 * OF CONTRACT, TORT OR OTHERWISE,  ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

package org.slf4j.helpers;

import java.util.HashMap;
import java.util.Map;

// contributors: lizongbo: proposed special treatment of array parameter values
// J鰎n Huxhorn: pointed out double[] omission, suggested deep array copy
/**
 * Formats messages according to very simple substitution rules. Substitutions
 * can be made 1, 2 or more arguments.
 * <p>
 * For example,
 * 
 * <pre>MessageFormatter.format(&quot;Hi {}.&quot;, &quot;there&quot;)</pre>
 * 
 * will return the string "Hi there.".
 * <p>
 * The {} pair is called the <em>formatting anchor</em>. It serves to
 * designate the location where arguments need to be substituted within the
 * message pattern.
 * <p>
 * In case your message contains the '{' or the '}' character, you do not have
 * to do anything special unless the '}' character immediately follows '{'. For
 * example,
 * 
 * <pre>
 * MessageFormatter.format(&quot;Set {1,2,3} is not equal to {}.&quot;, &quot;1,2&quot;);
 * </pre>
 * 
 * will return the string "Set {1,2,3} is not equal to 1,2.".
 * 
 * <p>If for whatever reason you need to place the string "{}" in the message
 * without its <em>formatting anchor</em> meaning, then you need to escape the
 * '{' character with '\', that is the backslash character. Only the '{'
 * character should be escaped. There is no need to escape the '}' character.
 * For example,
 * 
 * <pre>
 * MessageFormatter.format(&quot;Set \\{} is not equal to {}.&quot;, &quot;1,2&quot;);
 * </pre>
 * 
 * will return the string "Set {} is not equal to 1,2.".
 * 
 * <p>
 * The escaping behavior just described can be overridden by escaping the escape
 * character '\'. Calling
 * 
 * <pre>
 * MessageFormatter.format(&quot;File name is C:\\\\{}.&quot;, &quot;file.zip&quot;);
 * </pre>
 * 
 * will return the string "File name is C:\file.zip".
 * 
 * <p>
 * See {@link #format(String, Object)}, {@link #format(String, Object, Object)}
 * and {@link #arrayFormat(String, Object[])} methods for more details.
 * 
 * @author Ceki G&uuml;lc&uuml;
 */
final public class MessageFormatter {
  static final char DELIM_START = '{';
  static final char DELIM_STOP = '}';
  static final String DELIM_STR = "{}";
  private static final char ESCAPE_CHAR = '\\';

  /**
   * Performs single argument substitution for the 'messagePattern' passed as
   * parameter.
   * <p>
   * For example,
   * 
   * <pre>
   * MessageFormatter.format(&quot;Hi {}.&quot;, &quot;there&quot;);
   * </pre>
   * 
   * will return the string "Hi there.".
   * <p>
   * 
   * @param messagePattern
   *                The message pattern which will be parsed and formatted
   * @param argument
   *                The argument to be substituted in place of the formatting
   *                anchor
   * @return The formatted message
   */
  final public static String format(String messagePattern, Object arg) {
    return arrayFormat(messagePattern, new Object[] { arg });
  }

  /**
   * 
   * Performs a two argument substitution for the 'messagePattern' passed as
   * parameter.
   * <p>
   * For example,
   * 
   * <pre>
   * MessageFormatter.format(&quot;Hi {}. My name is {}.&quot;, &quot;Alice&quot;, &quot;Bob&quot;);
   * </pre>
   * 
   * will return the string "Hi Alice. My name is Bob.".
   * 
   * @param messagePattern
   *                The message pattern which will be parsed and formatted
   * @param arg1
   *                The argument to be substituted in place of the first
   *                formatting anchor
   * @param arg2
   *                The argument to be substituted in place of the second
   *                formatting anchor
   * @return The formatted message
   */
  final public static String format(final String messagePattern, Object arg1, Object arg2) {
    return arrayFormat(messagePattern, new Object[] { arg1, arg2 });
  }

  /**
   * Same principle as the {@link #format(String, Object)} and
   * {@link #format(String, Object, Object)} methods except that any number of
   * arguments can be passed in an array.
   * 
   * @param messagePattern
   *                The message pattern which will be parsed and formatted
   * @param argArray
   *                An array of arguments to be substituted in place of
   *                formatting anchors
   * @return The formatted message
   */
  final public static String arrayFormat(final String messagePattern,
      final Object[] argArray) {
    if (messagePattern == null) {
      return null;
    }
    if (argArray == null) {
      return messagePattern;
    }
    int i = 0;
    int j;
    StringBuffer sbuf = new StringBuffer(messagePattern.length() + 50);

    for (int L = 0; L < argArray.length; L++) {

      j = messagePattern.indexOf(DELIM_STR, i);

      if (j == -1) {
        // no more variables
        if (i == 0) { // this is a simple string
          return messagePattern;
        } else { // add the tail string which contains no variables and return
          // the result.
          sbuf.append(messagePattern.substring(i, messagePattern.length()));
          return sbuf.toString();
        }
      } else {
        if (isEscapedDelimeter(messagePattern, j)) {
          if (!isDoubleEscaped(messagePattern, j)) {
            L--; // DELIM_START was escaped, thus should not be incremented
            sbuf.append(messagePattern.substring(i, j - 1));
            sbuf.append(DELIM_START);
            i = j + 1;
          } else {
            // The escape character preceding the delemiter start is
            // itself escaped: "abc x:\\{}"
            // we have to consume one backward slash
            sbuf.append(messagePattern.substring(i, j - 1));
            deeplyAppendParameter(sbuf, argArray[L], new HashMap());
            i = j + 2;
          }
        } else {
          // normal case
          sbuf.append(messagePattern.substring(i, j));
          deeplyAppendParameter(sbuf, argArray[L], new HashMap());
          i = j + 2;
        }
      }
    }
    // append the characters following the last {} pair.
    sbuf.append(messagePattern.substring(i, messagePattern.length()));
    return sbuf.toString();
  }

  final static boolean isEscapedDelimeter(String messagePattern,
      int delimeterStartIndex) {

    if (delimeterStartIndex == 0) {
      return false;
    }
    char potentialEscape = messagePattern.charAt(delimeterStartIndex - 1);
    if (potentialEscape == ESCAPE_CHAR) {
      return true;
    } else {
      return false;
    }
  }

  final static boolean isDoubleEscaped(String messagePattern, int delimeterStartIndex) {
    if (delimeterStartIndex >= 2
        && messagePattern.charAt(delimeterStartIndex - 2) == ESCAPE_CHAR) {
      return true;
    } else {
      return false;
    }
  }

  // special treatment of array values was suggested by 'lizongbo'
  private static void deeplyAppendParameter(StringBuffer sbuf, Object o,
      Map seenMap) {
    if (o == null) {
      sbuf.append("null");
      return;
    }
    if (!o.getClass().isArray()) {
      sbuf.append(o);
    } else {
      // check for primitive array types because they
      // unfortunately cannot be cast to Object[]
      if (o instanceof boolean[]) {
        booleanArrayAppend(sbuf, (boolean[]) o);
      } else if (o instanceof byte[]) {
        byteArrayAppend(sbuf, (byte[]) o);
      } else if (o instanceof char[]) {
        charArrayAppend(sbuf, (char[]) o);
      } else if (o instanceof short[]) {
        shortArrayAppend(sbuf, (short[]) o);
      } else if (o instanceof int[]) {
        intArrayAppend(sbuf, (int[]) o);
      } else if (o instanceof long[]) {
        longArrayAppend(sbuf, (long[]) o);
      } else if (o instanceof float[]) {
        floatArrayAppend(sbuf, (float[]) o);
      } else if (o instanceof double[]) {
        doubleArrayAppend(sbuf, (double[]) o);
      } else {
        objectArrayAppend(sbuf, (Object[]) o, seenMap);
      }
    }
  }

  private static void objectArrayAppend(StringBuffer sbuf, Object[] a,
      Map seenMap) {
    sbuf.append('[');
    if (!seenMap.containsKey(a)) {
      seenMap.put(a, null);
      final int len = a.length;
      for (int i = 0; i < len; i++) {
        deeplyAppendParameter(sbuf, a[i], seenMap);
        if (i != len - 1)
          sbuf.append(", ");
      }
      // allow repeats in siblings
      seenMap.remove(a);
    } else {
      sbuf.append("...");
    }
    sbuf.append(']');
  }

  private static void booleanArrayAppend(StringBuffer sbuf, boolean[] a) {
    sbuf.append('[');
    final int len = a.length;
    for (int i = 0; i < len; i++) {
      sbuf.append(a[i]);
      if (i != len - 1)
        sbuf.append(", ");
    }
    sbuf.append(']');
  }

  private static void byteArrayAppend(StringBuffer sbuf, byte[] a) {
    sbuf.append('[');
    final int len = a.length;
    for (int i = 0; i < len; i++) {
      sbuf.append(a[i]);
      if (i != len - 1)
        sbuf.append(", ");
    }
    sbuf.append(']');
  }

  private static void charArrayAppend(StringBuffer sbuf, char[] a) {
    sbuf.append('[');
    final int len = a.length;
    for (int i = 0; i < len; i++) {
      sbuf.append(a[i]);
      if (i != len - 1)
        sbuf.append(", ");
    }
    sbuf.append(']');
  }

  private static void shortArrayAppend(StringBuffer sbuf, short[] a) {
    sbuf.append('[');
    final int len = a.length;
    for (int i = 0; i < len; i++) {
      sbuf.append(a[i]);
      if (i != len - 1)
        sbuf.append(", ");
    }
    sbuf.append(']');
  }

  private static void intArrayAppend(StringBuffer sbuf, int[] a) {
    sbuf.append('[');
    final int len = a.length;
    for (int i = 0; i < len; i++) {
      sbuf.append(a[i]);
      if (i != len - 1)
        sbuf.append(", ");
    }
    sbuf.append(']');
  }

  private static void longArrayAppend(StringBuffer sbuf, long[] a) {
    sbuf.append('[');
    final int len = a.length;
    for (int i = 0; i < len; i++) {
      sbuf.append(a[i]);
      if (i != len - 1)
        sbuf.append(", ");
    }
    sbuf.append(']');
  }

  private static void floatArrayAppend(StringBuffer sbuf, float[] a) {
    sbuf.append('[');
    final int len = a.length;
    for (int i = 0; i < len; i++) {
      sbuf.append(a[i]);
      if (i != len - 1)
        sbuf.append(", ");
    }
    sbuf.append(']');
  }

  private static void doubleArrayAppend(StringBuffer sbuf, double[] a) {
    sbuf.append('[');
    final int len = a.length;
    for (int i = 0; i < len; i++) {
      sbuf.append(a[i]);
      if (i != len - 1)
        sbuf.append(", ");
    }
    sbuf.append(']');
  }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美精品日日鲁夜夜添| 91在线一区二区三区| 中文字幕乱码久久午夜不卡| 欧美午夜不卡在线观看免费| 国产成人一区在线| 免费人成网站在线观看欧美高清| 最新欧美精品一区二区三区| 日韩欧美国产午夜精品| 日本乱码高清不卡字幕| 成人免费视频一区| 狠狠色2019综合网| 天天综合色天天综合色h| 国产精品对白交换视频| 久久综合九色综合久久久精品综合| 欧美色区777第一页| 97aⅴ精品视频一二三区| 国产在线精品免费| 久久精品二区亚洲w码| 亚洲国产aⅴ天堂久久| 亚洲精品中文在线观看| 国产精品无遮挡| 久久久久成人黄色影片| 日韩免费高清av| 欧美一区二区日韩| 欧美区在线观看| 欧美中文字幕不卡| 在线看日本不卡| 在线欧美日韩国产| 色悠久久久久综合欧美99| 成人美女视频在线观看18| 国产在线播放一区| 久久精品国产77777蜜臀| 免费亚洲电影在线| 久久精品99国产国产精| 美女视频黄免费的久久 | 玖玖九九国产精品| 亚洲第一福利视频在线| 一区二区免费在线播放| 亚洲日本青草视频在线怡红院 | 琪琪久久久久日韩精品| 日韩精品五月天| 天天av天天翘天天综合网| 亚洲bdsm女犯bdsm网站| 亚洲国产三级在线| 亚洲成a人片在线观看中文| 亚洲国产一区二区三区| 日韩高清一区在线| 蜜臀av一区二区| 国产精品夜夜嗨| 成人黄色777网| 在线观看91视频| 欧美一级免费观看| 国产精品国产精品国产专区不片| 精品国产亚洲在线| 久久综合色鬼综合色| 中文字幕国产一区| 亚洲欧美一区二区三区极速播放| 亚洲影院久久精品| 蜜桃久久久久久久| 国产aⅴ精品一区二区三区色成熟| 白白色 亚洲乱淫| 欧美视频在线观看一区二区| 欧美一区二区播放| 中文字幕精品在线不卡| 一区二区成人在线观看| 免费成人小视频| 国产成人午夜精品5599| 在线一区二区视频| 精品国产麻豆免费人成网站| 中文在线免费一区三区高中清不卡| 一区二区在线观看不卡| 日韩成人av影视| 国产成人鲁色资源国产91色综| 91日韩精品一区| 日韩欧美国产综合一区| 亚洲视频图片小说| 日本一区中文字幕| 成人激情av网| 777xxx欧美| 亚洲欧美影音先锋| 久久精品国产一区二区| 91在线视频免费91| 欧美成人三级电影在线| 亚洲色图在线看| 另类综合日韩欧美亚洲| 色综合天天综合狠狠| 日韩限制级电影在线观看| 国产精品欧美精品| 美腿丝袜亚洲综合| 在线观看精品一区| 国产亚洲精品超碰| 秋霞国产午夜精品免费视频| 91视视频在线观看入口直接观看www | 亚洲免费色视频| 久久综合综合久久综合| 日本高清视频一区二区| 久久久久久影视| 日产国产高清一区二区三区| 99久久99久久免费精品蜜臀| 精品国产99国产精品| 亚洲一二三四区不卡| 大尺度一区二区| 精品国产123| 天天综合网 天天综合色| 91免费精品国自产拍在线不卡 | 国产精品入口麻豆九色| 日韩av二区在线播放| 色诱视频网站一区| 国产精品剧情在线亚洲| 精品一区二区三区视频在线观看| 欧美日韩激情一区二区| 亚洲精品欧美在线| 欧美三电影在线| 蜜臀91精品一区二区三区| 在线亚洲免费视频| 国产精品超碰97尤物18| 国产麻豆午夜三级精品| 欧美疯狂做受xxxx富婆| 亚洲小说欧美激情另类| 99国内精品久久| 中文字幕一区二区三区蜜月| 国产高清在线观看免费不卡| 26uuu国产一区二区三区| 久久aⅴ国产欧美74aaa| 欧美大胆一级视频| 久久综合综合久久综合| 日韩网站在线看片你懂的| 日韩电影在线一区二区| 欧美日韩精品三区| 日韩黄色免费网站| 这里只有精品99re| 日韩在线a电影| 91精品国产综合久久久蜜臀图片| 午夜电影久久久| 欧美精品自拍偷拍动漫精品| 五月天亚洲精品| 666欧美在线视频| 久久精品国产精品亚洲综合| 欧美r级在线观看| 国产一区二区精品久久| 久久久午夜电影| 波多野结衣在线一区| 亚洲欧美一区二区不卡| 欧美日韩在线播放三区| 日韩精品视频网站| 精品盗摄一区二区三区| 国产精品自在欧美一区| 国产精品久久久久一区二区三区 | 国产欧美一区二区精品仙草咪| 国产精品亚洲一区二区三区在线| 国产亚洲精品7777| av一本久道久久综合久久鬼色| 亚洲色图制服丝袜| 在线电影一区二区三区| 国产一区二区在线免费观看| 欧美国产成人精品| 色美美综合视频| 三级久久三级久久久| 精品日韩一区二区三区| 顶级嫩模精品视频在线看| 亚洲精品欧美专区| 欧美一区二区三区在线电影| 国产一区欧美二区| 亚洲天天做日日做天天谢日日欢| 欧美理论片在线| 国产一区二区三区在线观看免费视频 | 久久99精品久久久久久动态图 | 日本中文字幕一区| 国产日韩综合av| 在线观看亚洲一区| 成人一级视频在线观看| 日韩黄色在线观看| 国产精品国产三级国产a| 日韩精品自拍偷拍| 风流少妇一区二区| 久久免费偷拍视频| 欧洲生活片亚洲生活在线观看| 国产清纯白嫩初高生在线观看91 | 欧美日韩黄色影视| 国产剧情在线观看一区二区| 亚洲一区欧美一区| 午夜a成v人精品| 蜜臀va亚洲va欧美va天堂| 一区二区三区中文字幕精品精品| 99精品久久免费看蜜臀剧情介绍| 精品久久久久久久久久久久久久久| 亚洲最色的网站| 在线播放欧美女士性生活| 亚洲h在线观看| 久久久精品一品道一区| 欧美欧美欧美欧美首页| 欧美日韩一区三区| 精品一区二区三区免费观看| 精品日韩成人av| 国产高清不卡一区二区| 国产精品久久久久久久久果冻传媒 | 老司机一区二区| 日韩精品一区二区三区蜜臀| 极品少妇xxxx精品少妇偷拍| 欧美激情中文字幕|