package com.xxx.config;
Import Java. io. *; import Java. util. hashmap; import Java. util. map; import Java. util. properties;/*** read configuration integration class <br> * If the configuration source is not set, by default, xxxxxx configuration * @ author */public class configmanager {Private Static configs _ default = NULL; // Private Static hashmap configs = new hashmap (); private Static Boolean hasdefault = true;/*** get the configuration information of the specified configuration file * @ Param conf configuration file name * @ return configs object */public static configs getconfigs (St Ring module) {configs cf = NULL; // (configs) configs. get (module); If (cf = NULL) {configs df = getdefadefaconfigs (); If (df = NULL) return NULL; string file = DF. getconfig (module); If (file! = NULL & file. length ()> 0 & New Java. io. file (file ). isfile () {cf = new configs (); cf. init (file, DF. getconfigproperty ();} else {cf = DF;} // configs. put (module, CF);} return CF ;} /*** get the configuration information of the specified configuration file * @ Param conf configuration file name * @ return configs object */public static void setdefault (string module) {configs df = getdefaconfigconfigs (); if (df = NULL) return; string file = DF. getconfig (module); If (file! = NULL & file. length ()> 0 & New Java. io. file (file ). isfile () {configs cf = new configs (); cf. init (file, DF. getconfigproperty (); _ default = CF ;}} /*** get the configuration information of the specified configuration file * @ Param conf configuration file name * @ return configs object */public static void resetdefault () {_ default = NULL ;} /*** get the configuration value based on the configuration node name * @ Param key configure the node name * @ return configuration value */public static string getkey (string key) {return getkey (key, null, false );} /*** Get the configuration value based on the configuration node name * @ Param key configure the node name * @ Param defaul default value * @ return if there is a configuration value, the configuration value is returned, otherwise, the default value */public static string getkey (string key, string defaul) {return getkey (Key, defaul, false) is returned );} /*** get the configuration value based on the configuration node name * @ Param key configure the node name * @ Param islog whether to write logs. If it is true and the returned configuration value is null, write the log * @ return configuration value */public static string getkey (string key, Boolean islog) {return getkey (Key, null, islog);}/*** get the configuration value based on the configuration node name * @ Param key configure node name * @ Param defaul default value * @ Param islog whether to write logs. If it is true and the returned configuration value is null, write the log * @ return. If there is a configuration value, return the configuration value. Otherwise, return the default value */public static string getkey (string key, string defaul, Boolean islog) {configs cf = getdefaconfigconfigs (); If (CF! = NULL) return cf. getconfig (Key, defaul, islog); Return defaul;}/*** get the default configuration * @ return configs object */public static configs getdefaconfigconfigs () {If (_ default = NULL & hasdefault) {loaddefaconfig config () ;}return _ default;} static void loaddefaultconfig () {string F = ""; if (file. separatorchar = '\') F = "C: \ XXX. conf "; else f ="/xxx. conf "; system. out. println ("configuration file address" + F + "---------------------" ); File = new file (f); If (! File. isfile () {hasdefault = false; return ;}_ default = new configs (); _ default. INIT (f );}}