public void linkObject(Object object, Object parent, Object linkinfo, QName[] pathname, AReadContext context) throws Exception { StackElement se = context.getStackElement(context.getStackSize()-2); String name = se.getRawAttributes().containsKey("ref") ? se.getRawAttributes().get("ref") : se.getRawAttributes().get("cref"); ((UnparsedExpression)object).setName(MElement.internalName(name)); ((MConfigParameterElement)parent).addParameter((UnparsedExpression)object); // super add would required additional support for parameterset (subobjectinfo on all MConfigParameterElement elems // super.linkObject(object, parent, linkinfo, pathname, context); } };
public Object postProcess(IContext context, Object object) { try { BDIXModel model = (BDIXModel)context.getRootObject(); MCapability mcapa = model.getCapability(); AReadContext ar = (AReadContext)context; Map<String, String> rawattrs = ar.getTopStackElement().getRawAttributes(); String service = rawattrs.get("class"); String method = rawattrs.get("method"); MGoal mgoal = (MGoal)ar.getStackElement(ar.getStackSize()-2).getObject(); Class<?> iface = SReflect.findClass(service, model.getAllImports(), ar.getClassLoader()); ClassInfo ci = new ClassInfo(iface.getName()); // Just use first method if no name is given if(method==null) method = iface.getDeclaredMethods()[0].getName(); mcapa.addGoalPublication(ci, mgoal, method); } catch(Exception e) { throw new RuntimeException(e); } return null; }
public void linkObject(Object object, Object parent, Object linkinfo, QName[] pathname, AReadContext context) throws Exception { if(object instanceof MCondition) { MGoal mgoal = (MGoal)parent; String condtype = pathname[pathname.length-1].getLocalPart(); condtype = condtype.substring(0, condtype.length()-9); mgoal.addCondition(condtype, (MCondition)object); } else if(object instanceof String && parent instanceof MGoal && context.getStackElement(context.getStackSize()-4).getObject() instanceof BDIXModel) { BDIXModel model = (BDIXModel)context.getStackElement(context.getStackSize()-4).getObject(); model.getCapability().addGoalReference(MElement.internalName((String)object), ((MElement)parent).getName()); } else { context.getDefaultHandler().linkObject(object, parent, linkinfo, pathname, context); } } };
public void linkObject(Object object, Object parent, Object linkinfo, QName[] pathname, AReadContext context) throws Exception if(context.getStackElement(context.getStackSize()-1).getTag().equals(new QName(uri, "match"))) MTrigger mtrig = (MTrigger)context.getStackElement(context.getStackSize()-3).getObject(); String ref = (String)context.getStackElement(context.getStackSize()-2).getRawAttributes().get("ref"); if(ref==null) ref = (String)context.getStackElement(context.getStackSize()-2).getRawAttributes().get("cref"); MTrigger mtrig = (MTrigger)context.getStackElement(context.getStackSize()-2).getObject(); mtrig.addFactAdded(MElement.internalName((String)object)); MTrigger mtrig = (MTrigger)context.getStackElement(context.getStackSize()-2).getObject(); mtrig.addFactRemoved(MElement.internalName((String)object)); MTrigger mtrig = (MTrigger)context.getStackElement(context.getStackSize()-2).getObject(); mtrig.addFactChanged(MElement.internalName((String)object));
public void linkObject(Object object, Object parent, Object linkinfo, QName[] pathname, AReadContext context) throws Exception { if(object instanceof String && parent instanceof MBelief)// && context.getStackElement(context.getStackSize()-4).getObject() instanceof BDIXModel) { BDIXModel model = (BDIXModel)context.getStackElement(context.getStackSize()-4).getObject(); model.getCapability().addBeliefReference(MElement.internalName((String)object), ((MElement)parent).getName()); } // goals in condlinker else if(object instanceof String && parent instanceof MMessageEvent)// && context.getStackElement(context.getStackSize()-4).getObject() instanceof BDIXModel) { BDIXModel model = (BDIXModel)context.getStackElement(context.getStackSize()-4).getObject(); model.getCapability().addEventReference(MElement.internalName((String)object), ((MElement)parent).getName()); } else if(object instanceof String && parent instanceof MInternalEvent)// && context.getStackElement(context.getStackSize()-4).getObject() instanceof BDIXModel) { BDIXModel model = (BDIXModel)context.getStackElement(context.getStackSize()-4).getObject(); model.getCapability().addEventReference(MElement.internalName((String)object), ((MElement)parent).getName()); } else { super.linkObject(object, parent, linkinfo, pathname, context); } } };
public void linkObject(Object object, Object parent, Object linkinfo, QName[] pathname, AReadContext context) throws Exception { boolean done = false; if(pathname[pathname.length-1].getLocalPart().startsWith("initial") || pathname[pathname.length-1].getLocalPart().startsWith("end")) { String config = ((ConfigurationInfo)parent).getName(); BDIXModel model = (BDIXModel)context.getStackElement(pathname.length-2).getObject(); parent = model.getCapability().getConfiguration(config); if(parent==null) { MConfiguration mconf = new MConfiguration(config); model.getCapability().addConfiguration(mconf); parent = mconf; } // initial capabilities. if(object instanceof String) { ((MConfiguration)parent).addInitialCapability(context.getStackElement(context.getStackSize()-1).getRawAttributes().get("ref"), (String)object); done = true; } } if(!done) { context.getTopStackElement().getReaderHandler().linkObject(object, parent, linkinfo, pathname, context); } } };