Пример #1
0
 static void Args_reset(GfoMsg owner) {
   int len = owner.Subs_count();
   for (int i = 0; i < len; i++) {
     GfoMsg sub = owner.Subs_getAt(i);
     sub.Args_reset();
   }
 }
Пример #2
0
 public GfoMsg CloneNew() {
   GfoMsg_base rv = new GfoMsg_base().ctor_(key, parse);
   if (args != null) {
     rv.args = List_adp_.New();
     for (int i = 0; i < args.Count(); i++) rv.args.Add(args.Get_at(i));
   }
   if (subs != null) {
     rv.subs = List_adp_.New();
     for (int i = 0; i < args.Count(); i++) {
       GfoMsg sub = (GfoMsg) args.Get_at(i);
       rv.subs.Add(sub.CloneNew()); // NOTE: recursion
     }
   }
   return rv;
 }
Пример #3
0
 public static GfoMsg root_leafArgs_(String[] ary, Keyval... kvAry) {
   int len = Array_.Len(ary);
   if (len == 0) throw Err_.new_invalid_arg("== 0", "@len", len);
   GfoMsg root = new GfoMsg_base().ctor_(ary[0], false);
   GfoMsg owner = root;
   for (int i = 1; i < len; i++) {
     String key = ary[i];
     GfoMsg cur = new GfoMsg_base().ctor_(key, false);
     owner.Subs_add(cur);
     owner = cur;
   }
   for (int i = 0; i < kvAry.length; i++) {
     Keyval kv = kvAry[i];
     owner.Add(kv.Key(), kv.Val());
   }
   return root;
 }
Пример #4
0
 void To_str(String_bldr sb, XtoStrWkr wkr, GfoMsg m) {
   sb.Add(m.Key());
   if (m.Subs_count() == 0) {
     sb.Add(":");
     boolean first = true;
     for (int i = 0; i < m.Args_count(); i++) {
       Keyval kv = m.Args_getAt(i);
       if (kv.Val() == null) continue;
       if (!first) sb.Add(" ");
       sb.Add(kv.Key());
       sb.Add("='");
       sb.Add(wkr.To_str(kv.Val()));
       sb.Add("'");
       first = false;
     }
     sb.Add(";");
   } else {
     sb.Add(".");
     To_str(sb, wkr, m.Subs_getAt(0));
   }
 }
Пример #5
0
  public static GfoMsg chain_(GfoMsg owner, String key) {
    GfoMsg sub = owner;
    List_adp list = List_adp_.New();
    list.Add(sub.Key());
    while (sub != null) {
      if (sub.Subs_count() == 0) break;
      sub = (GfoMsg) sub.Subs_getAt(0);
      list.Add(sub.Key());
    }
    list.Add(key);

    GfoMsg root = GfoMsg_.new_parse_((String) list.Get_at(0));
    GfoMsg cur = root;
    for (int i = 1; i < list.Count(); i++) {
      String k = (String) list.Get_at(i);
      GfoMsg mm = GfoMsg_.new_parse_(k);
      cur.Subs_add(mm);
      cur = mm;
    }
    return root;
  }
Пример #6
0
 public static GfoMsg basic_(String cmd, Object... vals) {
   GfoMsg rv = new_cast_(cmd);
   int len = vals.length;
   for (int i = 0; i < len; i++) rv.Add("", vals[i]);
   return rv;
 }
Пример #7
0
 public static GfoMsg srl_(GfoMsg owner, String key) {
   GfoMsg rv = new_parse_(key);
   owner.Subs_add(rv);
   return rv;
 }