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

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

?? optionconverter.java

?? apache的log4j源碼
?? JAVA
字號:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at *  *      http://www.apache.org/licenses/LICENSE-2.0 *  * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.log4j.helpers;import java.util.Properties;import java.net.URL;import org.apache.log4j.Level;import org.apache.log4j.spi.Configurator;import org.apache.log4j.spi.LoggerRepository;import org.apache.log4j.PropertyConfigurator;// Contributors:   Avy Sharell (sharell@online.fr)//                 Matthieu Verbert (mve@zurich.ibm.com)//                 Colin Sampaleanu/**   A convenience class to convert property values to specific types.   @author Ceki G&uuml;lc&uuml;   @author Simon Kitching;   @author Anders Kristensen*/public class OptionConverter {  static String DELIM_START = "${";  static char   DELIM_STOP  = '}';  static int DELIM_START_LEN = 2;  static int DELIM_STOP_LEN  = 1;  /** OptionConverter is a static class. */  private OptionConverter() {}  public  static  String[] concatanateArrays(String[] l, String[] r) {    int len = l.length + r.length;    String[] a = new String[len];    System.arraycopy(l, 0, a, 0, l.length);    System.arraycopy(r, 0, a, l.length, r.length);    return a;  }  public  static  String convertSpecialChars(String s) {    char c;    int len = s.length();    StringBuffer sbuf = new StringBuffer(len);    int i = 0;    while(i < len) {      c = s.charAt(i++);      if (c == '\\') {	c =  s.charAt(i++);	if(c == 'n')      c = '\n';	else if(c == 'r') c = '\r';	else if(c == 't') c = '\t';	else if(c == 'f') c = '\f';	else if(c == '\b') c = '\b';	else if(c == '\"') c = '\"';	else if(c == '\'') c = '\'';	else if(c == '\\') c = '\\';      }      sbuf.append(c);    }    return sbuf.toString();  }  /**     Very similar to <code>System.getProperty</code> except     that the {@link SecurityException} is hidden.     @param key The key to search for.     @param def The default value to return.     @return the string value of the system property, or the default     value if there is no property with that key.     @since 1.1 */  public  static  String getSystemProperty(String key, String def) {    try {      return System.getProperty(key, def);    } catch(Throwable e) { // MS-Java throws com.ms.security.SecurityExceptionEx      LogLog.debug("Was not allowed to read system property \""+key+"\".");      return def;    }  }  public  static  Object instantiateByKey(Properties props, String key, Class superClass,				Object defaultValue) {    // Get the value of the property in string form    String className = findAndSubst(key, props);    if(className == null) {      LogLog.error("Could not find value for key " + key);      return defaultValue;    }    // Trim className to avoid trailing spaces that cause problems.    return OptionConverter.instantiateByClassName(className.trim(), superClass,						  defaultValue);  }  /**     If <code>value</code> is "true", then <code>true</code> is     returned. If <code>value</code> is "false", then     <code>true</code> is returned. Otherwise, <code>default</code> is     returned.     <p>Case of value is unimportant.  */  public  static  boolean toBoolean(String value, boolean dEfault) {    if(value == null)      return dEfault;    String trimmedVal = value.trim();    if("true".equalsIgnoreCase(trimmedVal))      return true;    if("false".equalsIgnoreCase(trimmedVal))      return false;    return dEfault;  }  public  static  int toInt(String value, int dEfault) {    if(value != null) {      String s = value.trim();      try {	return Integer.valueOf(s).intValue();      }      catch (NumberFormatException e) {	 LogLog.error("[" + s + "] is not in proper int form.");	e.printStackTrace();      }    }    return dEfault;  }  /**     Converts a standard or custom priority level to a Level     object.  <p> If <code>value</code> is of form     "level#classname", then the specified class' toLevel method     is called to process the specified level string; if no '#'     character is present, then the default {@link org.apache.log4j.Level}     class is used to process the level value.     <p>As a special case, if the <code>value</code> parameter is     equal to the string "NULL", then the value <code>null</code> will     be returned.     <p> If any error occurs while converting the value to a level,     the <code>defaultValue</code> parameter, which may be     <code>null</code>, is returned.     <p> Case of <code>value</code> is insignificant for the level level, but is     significant for the class name part, if present.     @since 1.1 */  public  static  Level toLevel(String value, Level defaultValue) {    if(value == null)      return defaultValue;          value = value.trim();    int hashIndex = value.indexOf('#');    if (hashIndex == -1) {      if("NULL".equalsIgnoreCase(value)) {	return null;      } else {	// no class name specified : use standard Level class	return(Level) Level.toLevel(value, defaultValue);      }    }    Level result = defaultValue;    String clazz = value.substring(hashIndex+1);    String levelName = value.substring(0, hashIndex);    // This is degenerate case but you never know.    if("NULL".equalsIgnoreCase(levelName)) {	return null;    }    LogLog.debug("toLevel" + ":class=[" + clazz + "]"		 + ":pri=[" + levelName + "]");    try {      Class customLevel = Loader.loadClass(clazz);      // get a ref to the specified class' static method      // toLevel(String, org.apache.log4j.Level)      Class[] paramTypes = new Class[] { String.class,					 org.apache.log4j.Level.class                                       };      java.lang.reflect.Method toLevelMethod =                      customLevel.getMethod("toLevel", paramTypes);      // now call the toLevel method, passing level string + default      Object[] params = new Object[] {levelName, defaultValue};      Object o = toLevelMethod.invoke(null, params);      result = (Level) o;    } catch(ClassNotFoundException e) {      LogLog.warn("custom level class [" + clazz + "] not found.");    } catch(NoSuchMethodException e) {      LogLog.warn("custom level class [" + clazz + "]"        + " does not have a class function toLevel(String, Level)", e);    } catch(java.lang.reflect.InvocationTargetException e) {      LogLog.warn("custom level class [" + clazz + "]"		   + " could not be instantiated", e);    } catch(ClassCastException e) {      LogLog.warn("class [" + clazz        + "] is not a subclass of org.apache.log4j.Level", e);    } catch(IllegalAccessException e) {      LogLog.warn("class ["+clazz+		   "] cannot be instantiated due to access restrictions", e);    } catch(Exception e) {      LogLog.warn("class ["+clazz+"], level ["+levelName+		   "] conversion failed.", e);    }    return result;   }  public  static  long toFileSize(String value, long dEfault) {    if(value == null)      return dEfault;    String s = value.trim().toUpperCase();    long multiplier = 1;    int index;    if((index = s.indexOf("KB")) != -1) {      multiplier = 1024;      s = s.substring(0, index);    }    else if((index = s.indexOf("MB")) != -1) {      multiplier = 1024*1024;      s = s.substring(0, index);    }    else if((index = s.indexOf("GB")) != -1) {      multiplier = 1024*1024*1024;      s = s.substring(0, index);    }    if(s != null) {      try {	return Long.valueOf(s).longValue() * multiplier;      }      catch (NumberFormatException e) {	LogLog.error("[" + s + "] is not in proper int form.");	LogLog.error("[" + value + "] not in expected format.", e);      }    }    return dEfault;  }  /**     Find the value corresponding to <code>key</code> in     <code>props</code>. Then perform variable substitution on the     found value. */  public  static  String findAndSubst(String key, Properties props) {    String value = props.getProperty(key);    if(value == null)      return null;    try {      return substVars(value, props);    } catch(IllegalArgumentException e) {      LogLog.error("Bad option value ["+value+"].", e);      return value;    }  }  /**     Instantiate an object given a class name. Check that the     <code>className</code> is a subclass of     <code>superClass</code>. If that test fails or the object could     not be instantiated, then <code>defaultValue</code> is returned.     @param className The fully qualified class name of the object to instantiate.     @param superClass The class to which the new object should belong.     @param defaultValue The object to return in case of non-fulfillment   */  public  static  Object instantiateByClassName(String className, Class superClass,				Object defaultValue) {    if(className != null) {      try {	Class classObj = Loader.loadClass(className);	if(!superClass.isAssignableFrom(classObj)) {	  LogLog.error("A \""+className+"\" object is not assignable to a \""+		       superClass.getName() + "\" variable.");	  LogLog.error("The class \""+ superClass.getName()+"\" was loaded by ");	  LogLog.error("["+superClass.getClassLoader()+"] whereas object of type ");	  LogLog.error("\"" +classObj.getName()+"\" was loaded by ["		       +classObj.getClassLoader()+"].");	  return defaultValue;	}	return classObj.newInstance();      } catch (Exception e) {	LogLog.error("Could not instantiate class [" + className + "].", e);      }    }    return defaultValue;  }  /**     Perform variable substitution in string <code>val</code> from the     values of keys found in the system propeties.     <p>The variable substitution delimeters are <b>${</b> and <b>}</b>.     <p>For example, if the System properties contains "key=value", then     the call     <pre>     String s = OptionConverter.substituteVars("Value of key is ${key}.");     </pre>     will set the variable <code>s</code> to "Value of key is value.".     <p>If no value could be found for the specified key, then the     <code>props</code> parameter is searched, if the value could not     be found there, then substitution defaults to the empty string.     <p>For example, if system propeties contains no value for the key     "inexistentKey", then the call     <pre>     String s = OptionConverter.subsVars("Value of inexistentKey is [${inexistentKey}]");     </pre>     will set <code>s</code> to "Value of inexistentKey is []"     <p>An {@link java.lang.IllegalArgumentException} is thrown if     <code>val</code> contains a start delimeter "${" which is not     balanced by a stop delimeter "}". </p>     <p><b>Author</b> Avy Sharell</a></p>     @param val The string on which variable substitution is performed.     @throws IllegalArgumentException if <code>val</code> is malformed.  */  public static  String substVars(String val, Properties props) throws                        IllegalArgumentException {    StringBuffer sbuf = new StringBuffer();    int i = 0;    int j, k;    while(true) {      j=val.indexOf(DELIM_START, i);      if(j == -1) {	// no more variables	if(i==0) { // this is a simple string	  return val;	} else { // add the tail string which contails no variables and return the result.	  sbuf.append(val.substring(i, val.length()));	  return sbuf.toString();	}      } else {	sbuf.append(val.substring(i, j));	k = val.indexOf(DELIM_STOP, j);	if(k == -1) {	  throw new IllegalArgumentException('"'+val+		      "\" has no closing brace. Opening brace at position " + j					     + '.');	} else {	  j += DELIM_START_LEN;	  String key = val.substring(j, k);	  // first try in System properties	  String replacement = getSystemProperty(key, null);	  // then try props parameter	  if(replacement == null && props != null) {	    replacement =  props.getProperty(key);	  }	  if(replacement != null) {	    // Do variable substitution on the replacement string	    // such that we can solve "Hello ${x2}" as "Hello p1"             // the where the properties are	    // x1=p1            // x2=${x1}	    String recursiveReplacement = substVars(replacement, props);	    sbuf.append(recursiveReplacement);	  }	  i = k + DELIM_STOP_LEN;	}      }    }  }  /**     Configure log4j given a URL.     <p>The url must point to a file or resource which will be interpreted by     a new instance of a log4j configurator.     <p>All configurations steps are taken on the     <code>hierarchy</code> passed as a parameter.     <p>     @param url The location of the configuration file or resource.     @param clazz The classname, of the log4j configurator which will parse     the file or resource at <code>url</code>. This must be a subclass of     {@link Configurator}, or null. If this value is null then a default     configurator of {@link PropertyConfigurator} is used, unless the     filename pointed to by <code>url</code> ends in '.xml', in which case     {@link org.apache.log4j.xml.DOMConfigurator} is used.     @param hierarchy The {@link org.apache.log4j.Hierarchy} to act on.     @since 1.1.4 */  static  public  void selectAndConfigure(URL url, String clazz, LoggerRepository hierarchy) {   Configurator configurator = null;   String filename = url.getFile();   if(clazz == null && filename != null && filename.endsWith(".xml")) {     clazz = "org.apache.log4j.xml.DOMConfigurator";   }   if(clazz != null) {     LogLog.debug("Preferred configurator class: " + clazz);     configurator = (Configurator) instantiateByClassName(clazz,							  Configurator.class,							  null);     if(configurator == null) {   	  LogLog.error("Could not instantiate configurator ["+clazz+"].");   	  return;     }   } else {     configurator = new PropertyConfigurator();   }   configurator.doConfigure(url, hierarchy);  }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91蜜桃在线免费视频| 久久久久国产精品麻豆| 91网站最新地址| 国产经典欧美精品| 国产美女精品人人做人人爽| 精品无码三级在线观看视频| 美国精品在线观看| 久久er99热精品一区二区| 久久精品国产99| 韩国视频一区二区| 欧美—级在线免费片| 91视频观看视频| 一本一道久久a久久精品综合蜜臀| 丁香六月综合激情| 成人av在线网| 91麻豆免费看| 欧美在线观看一区二区| 制服丝袜国产精品| 欧美videos中文字幕| 国产日韩精品一区二区三区在线| 国产欧美精品一区二区色综合| 国产精品视频看| 亚洲综合一二三区| 日产国产欧美视频一区精品 | 成人h动漫精品一区二区| 岛国一区二区在线观看| 色综合久久六月婷婷中文字幕| 在线精品亚洲一区二区不卡| 欧美一级黄色录像| 久久亚洲二区三区| 国产精品成人免费在线| 亚洲gay无套男同| 激情丁香综合五月| 99精品视频在线播放观看| 欧美日韩国产电影| 国产日韩视频一区二区三区| 亚洲摸摸操操av| 婷婷夜色潮精品综合在线| 韩国三级电影一区二区| 色悠悠久久综合| 日韩一级大片在线观看| 国产精品第一页第二页第三页| 亚洲午夜久久久久久久久电影网 | 亚洲图片欧美综合| 国产一区二区三区免费播放 | 国产精品人人做人人爽人人添| 一区二区三区欧美日| 琪琪一区二区三区| 成人毛片老司机大片| 欧美精品一级二级三级| 国产精品女上位| 日本网站在线观看一区二区三区| 粉嫩嫩av羞羞动漫久久久| 欧美色电影在线| 国产日韩亚洲欧美综合| 天天色综合成人网| 91尤物视频在线观看| 欧美成人三级在线| 亚洲在线成人精品| 豆国产96在线|亚洲| 3atv一区二区三区| 亚洲人妖av一区二区| 黄网站免费久久| 欧美午夜在线一二页| 久久久久亚洲蜜桃| 免费在线观看成人| 在线视频观看一区| 中文字幕av一区二区三区高| 日本不卡视频在线| 色999日韩国产欧美一区二区| 久久婷婷国产综合国色天香| 午夜国产精品一区| 风间由美一区二区av101| 日韩免费观看高清完整版在线观看| 欧美精品电影在线播放| 91精品国产一区二区三区蜜臀 | 五月天久久比比资源色| 99国产精品久久久久久久久久久| 精品国产一区二区三区久久影院| 亚洲精品免费视频| 99视频在线精品| 国产欧美视频一区二区| 久久成人羞羞网站| 欧美久久久久久久久久| 亚洲午夜在线视频| 91九色最新地址| 中文字幕一区二区三区在线不卡 | 裸体一区二区三区| 欧美男女性生活在线直播观看| 亚洲精品伦理在线| 99综合电影在线视频| 国产喂奶挤奶一区二区三区| 九九精品视频在线看| 欧美一级高清大全免费观看| 视频一区二区不卡| 欧美日韩不卡视频| 偷拍日韩校园综合在线| 欧美日韩国产首页在线观看| 午夜天堂影视香蕉久久| 欧美日韩精品欧美日韩精品一综合| 亚洲午夜一区二区三区| 在线观看亚洲a| 夜夜精品浪潮av一区二区三区| 色国产综合视频| 亚洲美女视频在线| 在线这里只有精品| 亚洲电影在线播放| 在线综合视频播放| 久久91精品国产91久久小草| 精品久久久久久亚洲综合网| 激情另类小说区图片区视频区| 久久婷婷久久一区二区三区| 国产福利一区二区三区在线视频| 国产欧美一二三区| 91亚洲精品一区二区乱码| 亚洲美女少妇撒尿| 欧美精选一区二区| 久久99日本精品| 亚洲国产岛国毛片在线| 99久久精品国产麻豆演员表| 夜夜嗨av一区二区三区网页| 欧美日韩国产电影| 国内精品伊人久久久久av影院| 久久久久久亚洲综合影院红桃| 国产成人啪午夜精品网站男同| 国产精品女人毛片| 在线精品视频免费播放| 天天av天天翘天天综合网| 精品国产一区二区三区av性色| 国产福利一区二区三区视频在线| 国产精品久久久久天堂| 欧美体内she精高潮| 蜜臀久久99精品久久久久宅男| 久久精品视频在线免费观看| 91在线视频在线| 亚洲成人在线免费| 久久久久久久久久久电影| av在线不卡免费看| 日韩国产欧美在线视频| 久久久精品免费网站| 91久久免费观看| 久久国产精品一区二区| 国产精品高潮呻吟久久| 欧美蜜桃一区二区三区| 国产一区二区三区四区五区美女| 亚洲视频在线一区| 日韩视频免费观看高清完整版在线观看| 国产精品综合一区二区| 一区二区在线观看免费视频播放 | 琪琪一区二区三区| 国产精品久久久久久福利一牛影视 | 日本一二三不卡| 欧美性受xxxx| 国产精品一区二区你懂的| 亚洲午夜免费福利视频| 国产亚洲精品久| 欧美日韩亚洲综合在线| 高清视频一区二区| 日本不卡视频在线观看| 亚洲免费观看视频| 久久综合色8888| 欧美久久久久免费| 91视频在线观看免费| 狠狠网亚洲精品| 无吗不卡中文字幕| 自拍av一区二区三区| 久久婷婷色综合| 在线播放91灌醉迷j高跟美女 | 日韩午夜激情视频| 一本在线高清不卡dvd| 国产高清成人在线| 日韩国产高清影视| 亚洲综合色成人| 中文久久乱码一区二区| 精品久久久久久久久久久久久久久久久| 91国偷自产一区二区使用方法| 国产精品影音先锋| 蜜臀av国产精品久久久久| 亚洲va欧美va国产va天堂影院| 国产精品视频看| 国产日韩av一区| 精品久久99ma| 91精品视频网| 欧美久久一二区| 欧美亚洲一区二区在线| 91麻豆国产自产在线观看| 国产suv精品一区二区6| 狠狠色丁香九九婷婷综合五月| 日韩高清在线观看| 午夜国产精品影院在线观看| 亚洲夂夂婷婷色拍ww47 | 岛国一区二区在线观看| 国产一区二区在线观看视频| 另类综合日韩欧美亚洲| 日韩中文字幕区一区有砖一区 | 国产视频一区在线播放| 精品嫩草影院久久| 欧美电视剧在线观看完整版| 日韩午夜在线观看| 欧美一级高清大全免费观看|