class CookieUtil{
    constructor() {
    }
    static getCookie(sName){
        var sCookies = document.cookie ;
        if ("string" == typeof(sName)) {
            var sRE = "(?:; )?"+sName+"=([^;]*);?" ;
            var reRE = new RegExp(sRE) ;
            if (reRE.test(sCookies)) {
                return RegExp["$1"] ;
            } else {
                return null ;
            }
        } else {
            return sCookies ;
        }
    }
    static getUnicodeCookie(sName){
        var sValue = CookieUtil.getCookie(sName) ;
        if ( "string" == typeof(sName) ) {
            var sEncVal = CookieUtil.getCookie(sName) ;
            if (null == sEncVal) {
                return null ;
            } else {
                return decodeURIComponent(sEncVal) ;
            }
        } else {
            var sCookies = document.cookie ;
            return sCookies ;
        }
    }
    static setCookie(sName, sValue, oExpires, sPath, sDomain, bSecure){
        if ( "string" == typeof(sName) && "string" == typeof(sValue) ) {
            var sCookie = sName + "=" + sValue ;
            if (oExpires) {
                sCookie += "; expires=" + oExpires.toGMTString() ;
            }
            if (sPath) {
                sCookie += "; path=" + sPath ;
            }
            if (sDomain) {
                sCookie += "; domain=" + sDomain ;
            }
            if (bSecure) {
                sCookie += "; secure" ;
            }
            document.cookie = sCookie ;
        }
    }
    static setUnicodeCookie(sName, sValue, oExpires, sPath, sDomain, bSecure){
        if ( "string" == typeof(sName) && "string" == typeof(sValue) ) {
            sValue = encodeURIComponent(sValue) ;
            CookieUtil.setCookie(sName, sValue, oExpires, sPath, sDomain, bSecure) ;
        }
    }
}
export default CookieUtil;