RegExp.compile = typeof RegExp.prototype.compile=="function" ?
 (function(regExpStr, options) {
    var r = new RegExp();
    if (!regExpStr) {
      return this;
    }
    r.compile(regExpStr, options);
    return r;
  }) :
 (function(regExpStr, options) {
   return new RegExp(regExpStr, options);
 });
joo.Class.prepare("package joo.util","import joo.lang.JOObject","public class PropertyAware extends JOObject",["toMethodSuffix","toPropertyName","setProperties","toSetterName","setProperty","getProperty"],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return["public static const",{SET:"set"},
"public static const",{GET:"get"},
"public static const",{IS:"is"},
"private static const",{PREFIX_REG_EXP:/^(get|is)[A-Z]/},"public static toMethodSuffix",function(prop){
return prop.charAt(0).toUpperCase()+prop.substring(1);
},
"public static toPropertyName",function(getterName){
var match=getterName.match(PREFIX_REG_EXP);
if(match){
var prefixLength=match[1].length;
return getterName.charAt(prefixLength).toLowerCase()+getterName.substring(prefixLength+1);
}
return null;
},"public _PropertyAware",function(props){
this[_super]();
if(props){
this.updateProperties(props);
}
},"public updateProperties",function(props){
setProperties(this,props);
},"public static setProperties",function(bean,props){
for(var prop in props){
setProperty(bean,prop,props[prop]);
}
},
"public static toSetterName",function(prop){
return SET+toMethodSuffix(prop);
},"public static setProperty",function(bean,prop,value){
var propSetterName=toSetterName(prop);
if(typeof bean[propSetterName]=="function"){bean[propSetterName](value);
}else if(typeof bean["getClass"]!="function"||prop in bean){bean[prop]=value;
}else{throw new Error("Unknown property "+bean+"."+prop+" set to '"+value+"'.");
}
},
"public static getProperty",function(bean,prop){
var methodSuffix=toMethodSuffix(prop);
var propGetterName=GET+methodSuffix;
if(typeof bean[propGetterName]=="function"){return bean[propGetterName]();
}
var boolPropGetterName=IS+methodSuffix;
if(typeof bean[boolPropGetterName]=="function"){return bean[boolPropGetterName]();
}
return bean[prop];
},
]}
);
joo.Class.prepare("package joo.http","import joo.util.PropertyAware",
"public class Cookie extends PropertyAware",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return["public _Cookie",function(key,properties){
this[_key]=key;
this[_super](properties);
},"public setDomain",function(domain){
this[_domain]=domain;
return this;
},"public setPath",function(path){
this[_path]=path;
return this;
},
"public setDuration",function(duration){
this[_duration]=duration;
return this;
},
"public setSecure",function(secure){
this[_secure]=secure;
return this;
},"public save",function(value){
var cookie=[this[_key],"=",encodeURIComponent(value)];
if(this[_domain]){
cookie.push("; domain=",this[_domain]);
}
if(this[_path]){
cookie.push("; path=",this[_path]);
}
if(this[_duration]){
var date=new Date();
date.setTime(date.getTime()+this[_duration]*24*60*60*1000);
cookie.push("; expires=",date.toGMTString());
}
if(this[_secure]){
cookie.push("; secure");
}
window.document.cookie=cookie.join("");
return this.load()==(this[_duration]<0?null:value);
},"public load",function(){var cookieKey=this[_key].replace(/([.*+?^${}()|[\]\/\\])/g,"\\$1");
var match=window.document.cookie.match("(?:^|;)\\s*"+cookieKey+"=([^;]*)");
return match?decodeURIComponent(match[1]):null;
},"public remove",function(){
this[_duration]=-1;
return this.save("");
},"private var",{key: undefined},
"private var",{domain: undefined},
"private var",{path: undefined},
"private var",{duration: undefined},
"private var",{secure:false},
]}
);

