public Object getPathElementObject(Object element) { return ((StackElement)element).getObject(); }
/** * Get the xml path for a stack. * @param stack The stack. * @return The string representig the xml stack (e.g. tag1/tag2/tag3) */ protected QName[] getXMLPath() { QName[] ret = new QName[stack.size()]; for(int i=0; i<stack.size(); i++) { ret[i] = ((StackElement)stack.get(i)).getTag(); } return ret; }
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); } };
final TypeInfo typeinfo = readcontext.getPathManager().getTypeInfo(localname, fullpath, topse.getRawAttributes()); if((topse.getObject()==null && topse.getContent()!=null && topse.getContent().trim().length()>0) || topse.getObject()==STRING_MARKER) Object val = topse.getContent()!=null? topse.getContent(): topse.getObject(); if(val instanceof String) val = topse.getReaderHandler().convertContentObject((String)val, localname, readcontext); topse = new StackElement(topse.getReaderHandler(), topse.getTag(), val, topse.getRawAttributes(), null, topse.getLocation()); readcontext.setStackElement(topse, readcontext.getStackSize()-1); if(topse.getObject()!=null && topse.getContent()!=null && topse.getContent().trim().length()>0) topse.getReaderHandler().handleAttributeValue(topse.getObject(), null, null, topse.getContent(), typeinfo.getContentInfo(), readcontext); readcontext.getReporter().report("No content mapping for: "+topse.getContent()+" tag="+topse.getTag(), "link error", se, se.getLocation()); final IPostProcessor[] postprocs = topse.getReaderHandler().getPostProcessors(topse.getObject(), typeinfo); if(postprocs!=null && postprocs.length>0) Object changed = postprocs[i].postProcess(readcontext, topse.getObject()); topse.setObject(null); topse.setObject(changed); readcontext.getReporter().report("Error during postprocessing: "+e, "postprocessor error", topse, topse.getLocation());
if(readcontext.getTopStackElement()!=null && readcontext.getTopStackElement().getReaderHandler()!=null) handler = readcontext.getTopStackElement().getReaderHandler(); List pathname = new ArrayList(); pathname.add(localname); for(int i=readcontext.getStackSize()-2; i>=0 && pse.getObject()==null; i--) pathname.add(0, readcontext.getStackElement(i+1).getTag()); TypeInfo patypeinfo = ((StackElement)pse).getTypeInfo(); SubobjectInfo linkinfo = getSubobjectInfoRead(localname, fullpath, patypeinfo, readcontext.getTopStackElement()!=null? readcontext.getTopStackElement().getRawAttributes(): null); if(linkinfo!=null && linkinfo.getAccessInfo().isIgnoreRead()) StackElement se = new StackElement(handler, localname, object, rawattrs, typeinfo, StaxLocationWrapper.fromLocation(parser.getLocation())); readcontext.addStackElement(se); StackElement se = new StackElement(handler, localname, null, rawattrs, typeinfo, StaxLocationWrapper.fromLocation(parser.getLocation())); readcontext.addStackElement(se); readcontext.getReporter().report("idref not contained: "+idref, "idref error", se, se.getLocation()); readcontext.addStackElement(new StackElement(handler, localname, object, rawattrs, typeinfo, StaxLocationWrapper.fromLocation(parser.getLocation()))); attrpath.add(readcontext.getTopStackElement().getTag()); for(int i=readcontext.getStackSize()-2; i>=0 && object==null; i--) attrpath.add(pse.getTag()); typeinfo = pse.getTypeInfo();
public void report(String msg, String type, Object info, ILocation location) throws Exception { // System.out.println("XML error: "+msg+", "+type+", "+info+", "+location); // Thread.dumpStack(); IContext context = (IContext)AReader.READ_CONTEXT.get(); Map user = (Map)context.getUserContext(); MultiCollection report = (MultiCollection)user.get(CONTEXT_ENTRIES); String pos; Tuple stack = new Tuple(((AReadContext)context).getStack()); if(stack.getEntities().length>0) { StackElement se = (StackElement)stack.get(stack.getEntities().length-1); pos = " (line "+se.getLocation().getLineNumber()+", column "+se.getLocation().getColumnNumber()+")"; } else { pos = " (line 0, column 0)"; } report.put(stack, msg+pos); } });
public void callPostProcessor() throws Exception { try { Object check = postprocs[fi].postProcess(readcontext, ftopse.getObject()); if(check!=null) { readcontext.getReporter().report("Object replacement only possible in first pass.", "postprocessor error", ftopse, ftopse.getLocation()); } } catch(Exception e) { // e.printStackTrace(); readcontext.getReporter().report("Error during postprocessing: "+e, "postprocessor error", stack, ftopse!=null ? ftopse.getLocation() : readcontext.getLocation()); } } });
stack.add(new StackElement(subtag, null));
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"); else if(context.getTopStackElement().getTag().equals(new QName(uri, "factadded"))) MTrigger mtrig = (MTrigger)context.getStackElement(context.getStackSize()-2).getObject(); mtrig.addFactAdded(MElement.internalName((String)object)); else if(context.getTopStackElement().getTag().equals(new QName(uri, "factremoved"))) MTrigger mtrig = (MTrigger)context.getStackElement(context.getStackSize()-2).getObject(); mtrig.addFactRemoved(MElement.internalName((String)object)); else if(context.getTopStackElement().getTag().equals(new QName(uri, "factchanged"))) MTrigger mtrig = (MTrigger)context.getStackElement(context.getStackSize()-2).getObject(); mtrig.addFactChanged(MElement.internalName((String)object)); context.getTopStackElement().getReaderHandler().linkObject(object, parent, linkinfo, pathname, context);
stack.add(new StackElement(path[i], object)); writeNewline(writer); for(int i=0; i<stack.size() && !rec; i++) if(object.equals(((StackElement)stack.get(i)).getObject())) throw new RuntimeException("Object structure contains cycles: Enable 'genids' mode for serialization."); StackElement topse = new StackElement(tag, object); stack.add(topse); wc.getWrittenObjects().put(object, ""+curid);
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); } } };
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 { // Exchange parent for OAV children of configuration object. Map user = (Map)context.getUserContext(); IOAVState state = (IOAVState)user.get(OAVObjectReaderHandler.CONTEXT_STATE); if(state.isIdentifier(object)) { parent = getOAVConfiguration(uri, parent, context, user, state); } context.getTopStackElement().getReaderHandler().linkObject(object, parent, linkinfo, pathname, context); } };
public void report(String msg, String type, Object info, ILocation location) throws XMLStreamException { // System.out.println("XML error: "+msg+", "+type+", "+info+", "+location); // Thread.dumpStack(); IContext context = (IContext)(info instanceof IContext ? info : AReader.READ_CONTEXT.get()); Tuple stack = new Tuple(info instanceof StackElement[] ? (StackElement[])info : ((AReadContext)context).getStack()); Map user = (Map)context.getUserContext(); MultiCollection report = (MultiCollection)user.get(CONTEXT_ENTRIES); String pos; if(stack.getEntities().length>0) { StackElement se = (StackElement)stack.get(stack.getEntities().length-1); pos = " (line "+se.getLocation().getLineNumber()+", column "+se.getLocation().getColumnNumber()+")"; } else { pos = " (line 0, column 0)"; } report.put(stack, msg+pos); } });
new StackElement(new QName(model instanceof OAVAgentModel ? "agent" : "capability"), mcapa), new StackElement(new QName(state.getType(melement).getName()), melement), new StackElement(new QName(state.getType(mcondition).getName()), mcondition)}); new StackElement(new QName(model instanceof OAVAgentModel ? "agent" : "capability"), mcapa), new StackElement(new QName(state.getType(mcondition).getName()), mcondition)});
for(StackElement se: ar.getStack()) if(se.getObject() instanceof MParameterElement) pe = (MParameterElement)se.getObject(); String bels = ar.getTopStackElement().getRawAttributes()==null? null: ar.getTopStackElement().getRawAttributes().get("beliefs"); if(bels!=null) String params = ar.getTopStackElement().getRawAttributes()==null? null: ar.getTopStackElement().getRawAttributes().get("parameters"); if(params!=null) String goals = ar.getTopStackElement().getRawAttributes()==null? null: ar.getTopStackElement().getRawAttributes().get("goals"); if(goals!=null) String rawevs = ar.getTopStackElement().getRawAttributes()==null? null: ar.getTopStackElement().getRawAttributes().get("rawevents"); if(rawevs!=null)
public void linkObject(Object object, Object parent, Object linkinfo, QName[] pathname, AReadContext context) throws Exception { // Exchange parent for OAV children of root object. Map user = (Map)context.getUserContext(); IOAVState state = (IOAVState)user.get(OAVObjectReaderHandler.CONTEXT_STATE); if(state.isIdentifier(object)) { parent = getOAVRoot(uri, context, user, state); } context.getTopStackElement().getReaderHandler().linkObject(object, parent, linkinfo, pathname, context); } };
public void report(String msg, String type, Object info, ILocation location) throws Exception { // System.out.println("XML error: "+msg+", "+type+", "+info+", "+location); // Thread.dumpStack(); IContext context = (IContext)AReader.READ_CONTEXT.get(); Map user = (Map)context.getUserContext(); MultiCollection<Tuple, String> report = (MultiCollection<Tuple, String>)user.get(CONTEXT_ENTRIES); String pos; Tuple stack = new Tuple(((AReadContext)context).getStack()); if(stack.getEntities().length>0) { StackElement se = (StackElement)stack.get(stack.getEntities().length-1); pos = " (line "+se.getLocation().getLineNumber()+", column "+se.getLocation().getColumnNumber()+")"; } else { pos = " (line 0, column 0)"; } report.add(stack, msg+pos); } });
public Object getPathElementObject(Object element) { return ((StackElement)element).getObject(); }
addEntry(new Tuple(new Object[]{new StackElement(new QName(this instanceof OAVAgentModel ? "agent" : "capability"), handle)}), "Exception when resolving arguments/results: "+e);