/// <summary> method returns a clone and set id, name and value. /// </summary> public Object Clone() { MultiSlot newms = new MultiSlot(); newms.Id = Id; newms.Name = Name; newms.Value = (Object[])Value; return(newms); }
/// <summary> Convienance method for cloning a fact. If a slot's value is a BoundParam, /// the cloned fact uses the value of the BoundParam. /// </summary> /// <returns> /// /// </returns> public virtual Deffact cloneFact() { Deffact newfact = new Deffact(deftemplate, objInstance, deftemplate.cloneAllSlots(), -1); Slot[] slts = newfact.slots; for (int idx = 0; idx < slts.Length; idx++) { // probably need to revisit this and make sure if (slots[idx] is MultiSlot) { // it's multislot so we have to replace the bound values // correctly MultiSlot ms = (MultiSlot)slots[idx]; Object[] sval = (Object[])ms.Value; Object[] mval = new Object[sval.Length]; for (int mdx = 0; mdx < mval.Length; mdx++) { Object v = sval[mdx]; if (v is BoundParam) { mval[mdx] = ((BoundParam)v).Value; } else { mval[mdx] = v; } } slts[idx].Value = mval; } else if (slots[idx].Value is BoundParam) { if (slts[idx].ValueType == Constants.STRING_TYPE) { slts[idx].Value = ((BoundParam)slots[idx].Value).Value.ToString(); } else { slts[idx].Value = ((BoundParam)slots[idx].Value).Value; } } else { slts[idx].Value = slots[idx].Value; } } return(newfact); }
/// <summary> /// create the deftemplate for the defclass /// </summary> /// <param name="tempName">Name of the temp.</param> /// <returns></returns> public virtual Deftemplate createDeftemplate(String tempName) { Slot[] st = new Slot[PROPS.Length]; for (int idx = 0; idx < st.Length; idx++) { if (PROPS[idx].PropertyType.IsArray) { st[idx] = new MultiSlot(PROPS[idx].Name); st[idx].Id = idx; } else { st[idx] = new Slot(PROPS[idx].Name); st[idx].ValueType = ConversionUtils.getTypeCode(PROPS[idx].PropertyType); // set the column id for the slot st[idx].Id = idx; } } Deftemplate temp = new Deftemplate(tempName, OBJECT_CLASS.FullName, st); return(temp); }
/// <summary> method returns a clone and set id, name and value. /// </summary> public Object Clone() { MultiSlot newms = new MultiSlot(); newms.Id = Id; newms.Name = Name; newms.Value = (Object[]) Value; return newms; }
/* assert body */ public void assertContents(IList tokens) { Token exp; Object body = null; jj_consume_token(CLIPSParserConstants_Fields.LBRACE); exp = jj_consume_token(CLIPSParserConstants_Fields.IDENTIFIER); switch ((jj_ntk_Renamed_Field == - 1) ? jj_ntk() : jj_ntk_Renamed_Field) { case CLIPSParserConstants_Fields.INTEGER_LITERAL: case CLIPSParserConstants_Fields.FLOATING_POINT_LITERAL: case CLIPSParserConstants_Fields.STRING_LITERAL: case CLIPSParserConstants_Fields.BIND: case CLIPSParserConstants_Fields.BIND3: case CLIPSParserConstants_Fields.BIND4: case CLIPSParserConstants_Fields.TRUE: case CLIPSParserConstants_Fields.TRUE2: case CLIPSParserConstants_Fields.FALSE: case CLIPSParserConstants_Fields.FALSE2: case CLIPSParserConstants_Fields.IDENTIFIER: case CLIPSParserConstants_Fields.PATH_LITERAL: body = checkMultiSlot(); break; default: jj_la1[20] = jj_gen; ; break; } jj_consume_token(CLIPSParserConstants_Fields.RBRACE); if (body != null) { if (body.GetType().IsArray) { MultiSlot msl = new MultiSlot(exp.image); msl.Value = body; tokens.Add(msl); } else { Slot s = new Slot(exp.image); s.Value = body; tokens.Add(s); } } exp.clear(); exp = null; body = null; }
public void templateBody(IList slots) { Token sname; int stype; int sid; Slot sl; MultiSlot msl; Object defaultvalue; if (jj_2_8(2147483647)) { jj_consume_token(CLIPSParserConstants_Fields.LBRACE); jj_consume_token(CLIPSParserConstants_Fields.SLOT); sname = jj_consume_token(CLIPSParserConstants_Fields.IDENTIFIER); stype = slotType(); defaultvalue = defaultValue(); jj_consume_token(CLIPSParserConstants_Fields.RBRACE); sid = slots.Count; sl = new Slot(sname.image); sl.Id = sid; sl.ValueType = stype; slots.Add(sl); sname = null; } else if (jj_2_9(2147483647)) { jj_consume_token(CLIPSParserConstants_Fields.LBRACE); jj_consume_token(CLIPSParserConstants_Fields.MULTISLOT); sname = jj_consume_token(CLIPSParserConstants_Fields.IDENTIFIER); jj_consume_token(CLIPSParserConstants_Fields.RBRACE); sid = slots.Count; msl = new MultiSlot(sname.image); msl.Id = sid; slots.Add(msl); sname = null; } else { jj_consume_token(- 1); throw new ParseException(); } }
/// <summary> /// create the deftemplate for the defclass /// </summary> /// <param name="tempName">Name of the temp.</param> /// <returns></returns> public virtual Deftemplate createDeftemplate(String tempName) { Slot[] st = new Slot[PROPS.Length]; for (int idx = 0; idx < st.Length; idx++) { if (PROPS[idx].PropertyType.IsArray) { st[idx] = new MultiSlot(PROPS[idx].Name); st[idx].Id = idx; } else { st[idx] = new Slot(PROPS[idx].Name); st[idx].ValueType = ConversionUtils.getTypeCode(PROPS[idx].PropertyType); // set the column id for the slot st[idx].Id = idx; } } Deftemplate temp = new Deftemplate(tempName, OBJECT_CLASS.FullName, st); return temp; }
/* assert body */ public void assertContents(ArrayList tokens) { Token exp; Object body = null; mcc_consume_token(LBRACE); exp = mcc_consume_token(IDENTIFIER); switch ((mcc_ntk == -1) ? mcc_mntk() : mcc_ntk) { case INTEGER_LITERAL: case FLOATING_POINT_LITERAL: case STRING_LITERAL: case BIND: case BIND3: case BIND4: case TRUE: case TRUE2: case FALSE: case FALSE2: case IDENTIFIER: case PATH_LITERAL: body = checkMultiSlot(); break; default: mcc_la1[20] = mcc_gen; ; break; } mcc_consume_token(RBRACE); if (body != null) { if (body.GetType().IsArray) { MultiSlot msl = new MultiSlot(exp.image); msl.Value = body; tokens.Add(msl); } else { Slot s = new Slot(exp.image); s.Value = body; tokens.Add(s); } } exp.Clear(); exp = null; body = null; }
public void templateBody(ArrayList slots) { Token sname; int stype; int sid; Slot sl; MultiSlot msl; Object defaultvalue; if (mcc_2_8(2147483647)) { mcc_consume_token(LBRACE); mcc_consume_token(SLOT); sname = mcc_consume_token(IDENTIFIER); stype = slotType(); defaultvalue = defaultValue(); mcc_consume_token(RBRACE); sid = slots.Count; sl = new Slot(sname.image); sl.Id = sid; sl.ValueType = stype; sl.Value = defaultvalue; slots.Add(sl); sname = null; } else if (mcc_2_9(2147483647)) { mcc_consume_token(LBRACE); mcc_consume_token(MULTISLOT); sname = mcc_consume_token(IDENTIFIER); mcc_consume_token(RBRACE); sid = slots.Count; msl = new MultiSlot(sname.image); msl.Id = sid; slots.Add(msl); sname = null; } else { mcc_consume_token(-1); throw new ParseException(); } }
public virtual IFact createFact(Object[] data, long id) { Slot[] values = cloneAllSlots(); List <Object> bslots = new List <Object>(); bool hasbinding = false; for (int idz = 0; idz < data.Length; idz++) { Slot s = (Slot)data[idz]; for (int idx = 0; idx < values.Length; idx++) { if (values[idx].Name.Equals(s.Name)) { if (s is MultiSlot) { // since the value is multislot, we have to // check for boundparams MultiSlot ms = (MultiSlot)s; Object[] mvals = (Object[])ms.Value; for (int mdx = 0; mdx < mvals.Length; mdx++) { if (mvals[mdx] is BoundParam) { bslots.Add((MultiSlot)ms.Clone()); hasbinding = true; break; } } values[idx].Value = s.Value; } else { if (s.Value == null) { values[idx].Value = Constants.NIL_SYMBOL; } else if (values[idx].ValueType == Constants.STRING_TYPE && !(s.Value is BoundParam)) { values[idx].Value = s.Value.ToString(); } else if (s.Value is BoundParam) { values[idx].Value = s.Value; bslots.Add((Slot)s.Clone()); hasbinding = true; } else { values[idx].Value = s.Value; } } break; } } } Deffact newfact = new Deffact(this, null, values, id); if (hasbinding) { Slot[] slts2 = new Slot[bslots.Count]; bslots.CopyTo(slts2, 0); newfact.boundSlots = slts2; newfact.hasBinding_Renamed_Field = true; } // we call this to create the string used to map the fact. newfact.equalityIndex(); return(newfact); }