public virtual Type parameterize(Map pars) { if (this == Sys.ListType) { Type v = (Type)pars.get(FanStr.m_ascii['V']); if (v == null) { throw ArgErr.make("List.parameterize - V undefined").val; } return(v.toListOf()); } if (this == Sys.MapType) { Type v = (Type)pars.get(FanStr.m_ascii['V']); Type k = (Type)pars.get(FanStr.m_ascii['K']); if (v == null) { throw ArgErr.make("Map.parameterize - V undefined").val; } if (k == null) { throw ArgErr.make("Map.parameterize - K undefined").val; } return(new MapType(k, v)); } if (this == Sys.FuncType) { Type r = (Type)pars.get(FanStr.m_ascii['R']); if (r == null) { throw ArgErr.make("Map.parameterize - R undefined").val; } ArrayList p = new ArrayList(); for (int i = 'A'; i <= 'H'; ++i) { Type x = (Type)pars.get(FanStr.m_ascii[i]); if (x == null) { break; } p.Add(x); } return(new FuncType((Type[])p.ToArray(System.Type.GetType("Fan.Sys.Type")), r)); } throw UnsupportedErr.make("not generic: " + this).val; }
public virtual OutStream writeProps(Map props, bool cls) { Charset origCharset = charset(); charset(Charset.utf8()); try { List keys = props.keys().sort(); int size = keys.sz(); long eq = '='; long nl = '\n'; for (int i = 0; i < size; ++i) { string key = (string)keys.get(i); string val = (string)props.get(key); writePropStr(key); writeChar(eq); writePropStr(val); writeChar(nl); } return(this); } finally { try { if (cls) { close(); } } catch (System.Exception e) { Err.dumpStack(e); } charset(origCharset); } }
static void addProp(Map props, string n, string v, bool listVals) { if (listVals) { List list = (List)props.get(n); if (list == null) { props.add(n, list = new List(Sys.StrType)); } list.add(v); } else { props.add(n, v); } }
////////////////////////////////////////////////////////////////////////// // Option Utils ////////////////////////////////////////////////////////////////////////// bool getOption(Map options, string key, bool def) { if (options == null) return def; Boolean x = (Boolean)options.get(key); if (x == null) return def; return x.booleanValue(); }
public static string encodeQuery(Map map) { StringBuilder buf = new StringBuilder(256); IEnumerator en = map.keysEnumerator(); while (en.MoveNext()) { string key = (string)en.Current; string val = (string)map.get(key); if (buf.Length > 0) buf.Append('&'); encodeQueryStr(buf, key); if (val != null) { buf.Append('='); encodeQueryStr(buf, val); } } return buf.ToString(); }
public virtual OutStream writeProps(Map props, bool cls) { Charset origCharset = charset(); charset(Charset.utf8()); try { List keys = props.keys().sort(); int size = keys.sz(); long eq = '='; long nl = '\n'; for (int i=0; i<size; ++i) { string key = (string)keys.get(i); string val = (string)props.get(key); writePropStr(key); writeChar(eq); writePropStr(val); writeChar(nl); } return this; } finally { try { if (cls) close(); } catch (System.Exception e) { Err.dumpStack(e); } charset(origCharset); } }
private void addQueryParam(Map map, string q, int start, int eq, int end, bool escaped) { string key, val; if (start == eq && q[start] != '=') { key = toQueryStr(q, start, end, escaped); val = "true"; } else { key = toQueryStr(q, start, eq, escaped); val = toQueryStr(q, eq+1, end, escaped); } string dup = (string)map.get(key); if (dup != null) val = dup + "," + val; map.set(key, val); }
public virtual Type parameterize(Map pars) { if (this == Sys.ListType) { Type v = (Type)pars.get(FanStr.m_ascii['V']); if (v == null) throw ArgErr.make("List.parameterize - V undefined").val; return v.toListOf(); } if (this == Sys.MapType) { Type v = (Type)pars.get(FanStr.m_ascii['V']); Type k = (Type)pars.get(FanStr.m_ascii['K']); if (v == null) throw ArgErr.make("Map.parameterize - V undefined").val; if (k == null) throw ArgErr.make("Map.parameterize - K undefined").val; return new MapType(k, v); } if (this == Sys.FuncType) { Type r = (Type)pars.get(FanStr.m_ascii['R']); if (r == null) throw ArgErr.make("Map.parameterize - R undefined").val; ArrayList p = new ArrayList(); for (int i='A'; i<='H'; ++i) { Type x = (Type)pars.get(FanStr.m_ascii[i]); if (x == null) break; p.Add(x); } return new FuncType((Type[])p.ToArray(System.Type.GetType("Fan.Sys.Type")), r); } throw UnsupportedErr.make("not generic: " + this).val; }
private static bool option(Map options, string name, bool def) { Boolean val = (Boolean)options.get(name); if (val == null) return def; return val.booleanValue(); }
private static int option(Map options, string name, int def) { Long val = (Long)options.get(name); if (val == null) return def; return val.intValue(); }
static string sysConfig(string name) { return((string)m_sysConfig.get(name)); }
static void addProp(Map props, string n, string v, bool listVals) { if (listVals) { List list =(List)props.get(n); if (list == null) props.add(n, list = new List(Sys.StrType)); list.add(v); } else { props.add(n, v); } }