get() public method

public get ( object key ) : object
key object
return object
Example #1
0
        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;
        }
Example #2
0
        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);
            }
        }
Example #3
0
 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);
     }
 }
Example #4
0
 //////////////////////////////////////////////////////////////////////////
 // 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();
 }
Example #5
0
File: Uri.cs Project: xored/f4
        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();
        }
Example #6
0
 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);
       }
 }
Example #7
0
File: Uri.cs Project: xored/f4
            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);
            }
Example #8
0
File: Type.cs Project: nomit007/f4
        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;
        }
Example #9
0
 private static bool option(Map options, string name, bool def)
 {
     Boolean val = (Boolean)options.get(name);
       if (val == null) return def;
       return val.booleanValue();
 }
Example #10
0
 private static int option(Map options, string name, int def)
 {
     Long val = (Long)options.get(name);
       if (val == null) return def;
       return val.intValue();
 }
Example #11
0
 static string sysConfig(string name)
 {
     return((string)m_sysConfig.get(name));
 }
Example #12
0
 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);
       }
 }