List of usage examples for org.w3c.dom Element getLocalName
public String getLocalName();
From source file:com.fujitsu.dc.core.model.impl.es.DavCmpEsImpl.java
@Override @SuppressWarnings("unchecked") public Multistatus proppatch(final Propertyupdate propUpdate, final String url) { long now = new Date().getTime(); String reqUri = url;/*from w ww. j a v a2s.co m*/ Multistatus ms = this.of.createMultistatus(); Response res = this.of.createResponse(); res.getHref().add(reqUri); // Lock lock = this.lock(); // ? try { this.load(); // ?? Map<String, Object> propsJson = (Map<String, Object>) this.davNode.getProperties(); List<Prop> propsToSet = propUpdate.getPropsToSet(); for (Prop prop : propsToSet) { if (null == prop) { throw DcCoreException.Dav.XML_CONTENT_ERROR; } List<Element> lpe = prop.getAny(); for (Element elem : lpe) { res.setProperty(elem, HttpStatus.SC_OK); String key = elem.getLocalName() + "@" + elem.getNamespaceURI(); String value = DcCoreUtils.nodeToString(elem); log.debug("key: " + key); log.debug("val: " + value); propsJson.put(key, value); } } List<Prop> propsToRemove = propUpdate.getPropsToRemove(); for (Prop prop : propsToRemove) { if (null == prop) { throw DcCoreException.Dav.XML_CONTENT_ERROR; } List<Element> lpe = prop.getAny(); for (Element elem : lpe) { String key = elem.getLocalName() + "@" + elem.getNamespaceURI(); String v = (String) propsJson.get(key); log.debug("Removing key: " + key); if (v == null) { res.setProperty(elem, HttpStatus.SC_NOT_FOUND); } else { propsJson.remove(key); res.setProperty(elem, HttpStatus.SC_OK); } } } // this.davNode.setUpdated(now); // JSON??? setPropToJson(propsJson); DcIndexResponse resp = updateNodeWithVersion(); // ETAG??Version?? this.version = resp.version(); } finally { // lock.release(); } ms.getResponse().add(res); return ms; }
From source file:com.evolveum.midpoint.testing.model.client.sample.TestExchangeConnector.java
private Map<String, Object> getAttributesAsMap(ShadowType shadowType) { Map<String, Object> rv = new HashMap<>(); ShadowAttributesType attributes = shadowType.getAttributes(); for (Object item : attributes.getAny()) { if (item instanceof Element) { Element e = (Element) item; put(rv, e.getLocalName(), e.getTextContent()); } else if (item instanceof JAXBElement) { JAXBElement je = (JAXBElement) item; put(rv, je.getName().getLocalPart(), je.getValue()); } else {/*from www .j ava 2 s .c o m*/ // nothing to do here } } return rv; }
From source file:it.cnr.icar.eric.server.profile.ws.wsdl.cataloger.WSDLCatalogerEngine.java
private void resolveTypeImports(Element portTypeElement, RegistryObjectType wsdlEO) throws CatalogingException { try {// w w w. j a v a 2 s . c om String id = getPortTypeId(portTypeElement); if (idToRIMMap.get(id) == null) { processPortType(portTypeElement); } @SuppressWarnings("unused") ExtrinsicObjectType rimPortType = (ExtrinsicObjectType) idToRIMMap.get(id); List<Element> typeElements = resolveTypes(wsdlDocument); Iterator<?> schemaItr = resolveSchemaExtensions(typeElements); while (schemaItr.hasNext()) { Element schemaElement = (Element) schemaItr.next(); Iterator<?> schemaAttributeItr = wsdlDocument.getAttributes(schemaElement).iterator(); String location = null; @SuppressWarnings("unused") String localName = schemaElement.getLocalName(); String namespace = schemaElement.getNamespaceURI(); while (schemaAttributeItr.hasNext()) { Attr schemaAttribute = (Attr) schemaAttributeItr.next(); String localAttrName = schemaAttribute.getLocalName(); if (localAttrName.equalsIgnoreCase("namespace")) { namespace = schemaAttribute.getValue(); } else if (localAttrName.equalsIgnoreCase("schemaLocation")) { location = schemaAttribute.getValue(); } } RegistryObjectType importedObject = catalogImportStatement(wsdlEO, namespace, location); if (importedObject != null) { AssociationType1 ebAssociationType = bu.createAssociationType(wsdlEO.getId(), importedObject.getId(), CanonicalConstants.CANONICAL_ASSOCIATION_TYPE_ID_Imports); //May need a more deterministic algorithm for setting this id?? ebAssociationType.setId(wsdlEO.getId() + ":Imports:" + importedObject.getId()); registryObjects.add(ebAssociationType); } } } catch (CatalogingException e) { throw e; } catch (Exception e) { throw new CatalogingException(e); } }
From source file:iristk.flow.FlowCompiler.java
private Map<String, String> getParameters(Map<QName, String> attributes, List<Object> content, Object parent) throws FlowCompilerException { Map<String, String> result = new HashMap<String, String>(); for (QName attr : attributes.keySet()) { if (attr.getNamespaceURI() != null && attr.getNamespaceURI().equals("http://www.w3.org/2000/xmlns/")) continue; String name = attr.getLocalPart(); String value = formatAttrExpr(attributes.get(attr)); result.put(name, value);//w w w . ja va2s. c om } if (content.size() > 0) { ListMap<String, String> paramList = new ListMap<>(); for (Object child : content) { if (child instanceof Element) { Element elem = (Element) child; if (elem.getNamespaceURI().equals("iristk.flow.param")) { String key = elem.getLocalName(); List<Object> paramChildren = new ArrayList<Object>(); for (int j = 0; j < elem.getChildNodes().getLength(); j++) { paramChildren.add(elem.getChildNodes().item(j)); } String text = createExpression(paramChildren, elem); paramList.add(key, text); } } } if (paramList.size() == 0) { paramList.add("text", createExpression(content, parent)); } for (String key : paramList.keySet()) { if (paramList.get(key).size() > 1) { result.put(key, "java.util.Arrays.asList(" + listToString(paramList.get(key)) + ")"); } else { result.put(key, paramList.get(key).get(0)); } } } return result; }
From source file:com.evolveum.midpoint.testing.model.client.sample.TestExchangeConnector.java
private void dumpAttributes(ShadowType shadowType) { ShadowAttributesType attributes = shadowType.getAttributes(); System.out.println("Attributes for " + shadowType.getObjectClass().getLocalPart() + " " + getOrig(shadowType.getName()) + " {" + attributes.getAny().size() + " entries):"); for (Object item : attributes.getAny()) { if (item instanceof Element) { Element e = (Element) item; System.out.println(" - " + e.getLocalName() + ": " + e.getTextContent()); } else if (item instanceof JAXBElement) { JAXBElement je = (JAXBElement) item; String typeInfo = je.getValue() instanceof String ? "" : (" (" + je.getValue().getClass().getSimpleName() + ")"); System.out.println(" - " + je.getName().getLocalPart() + ": " + je.getValue() + typeInfo); } else {/*from w ww. ja v a 2 s . c o m*/ System.out.println(" - " + item); } } }
From source file:it.cnr.icar.eric.common.BindingUtility.java
/** * Gets trhe root element for a registry request * @return the root element as a String/* w w w .ja v a2 s .c om*/ */ public String getRequestRootElement(InputStream request) throws JAXRException { String rootElementName = null; try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(request); Element root = doc.getDocumentElement(); rootElementName = root.getLocalName(); } catch (IOException e) { throw new JAXRException(e); } catch (ParserConfigurationException e) { throw new JAXRException(e); } catch (SAXException e) { throw new JAXRException(e); } return rootElementName; }
From source file:org.bedework.util.dav.DavUtil.java
private DavChild makeDavResponse(final Element resp) throws Throwable { /* <!ELEMENT response (href, ((href*, status)|(propstat+)), responsedescription?) >/* w ww .ja v a 2s . c o m*/ */ final Iterator<Element> elit = getChildren(resp).iterator(); Node nd = elit.next(); final DavChild dc = new DavChild(); if (!XmlUtil.nodeMatches(nd, WebdavTags.href)) { throw new Exception("Bad response. Expected href found " + nd); } dc.uri = URLDecoder.decode(getElementContent((Element) nd), HTTP.UTF_8); // href should be escaped while (elit.hasNext()) { nd = elit.next(); if (XmlUtil.nodeMatches(nd, WebdavTags.status)) { dc.status = httpStatus((Element) nd); continue; } dc.status = HttpServletResponse.SC_OK; if (!XmlUtil.nodeMatches(nd, WebdavTags.propstat)) { throw new Exception("Bad response. Expected propstat found " + nd); } /* <!ELEMENT propstat (prop, status, responsedescription?) > */ Iterator<Element> propstatit = getChildren(nd).iterator(); Node propnd = propstatit.next(); if (!XmlUtil.nodeMatches(propnd, WebdavTags.prop)) { throw new Exception("Bad response. Expected prop found " + propnd); } if (!propstatit.hasNext()) { throw new Exception("Bad response. Expected propstat/status"); } final int st = httpStatus(propstatit.next()); if (propstatit.hasNext()) { Node rdesc = propstatit.next(); if (!XmlUtil.nodeMatches(rdesc, WebdavTags.responseDescription)) { throw new Exception("Bad response, expected null or " + "responsedescription. Found: " + rdesc); } } /* process each property with this status */ Collection<Element> respProps = getChildren(propnd); for (Element pr : respProps) { /* XXX This needs fixing to handle content that is xml */ if (XmlUtil.nodeMatches(pr, WebdavTags.resourcetype)) { Collection<Element> rtypeProps = getChildren(pr); for (Element rtpr : rtypeProps) { if (XmlUtil.nodeMatches(rtpr, WebdavTags.collection)) { dc.isCollection = true; } dc.resourceTypes.add(XmlUtil.fromNode(rtpr)); } } else { DavProp dp = new DavProp(); dc.propVals.add(dp); dp.name = new QName(pr.getNamespaceURI(), pr.getLocalName()); dp.status = st; dp.element = pr; if (XmlUtil.nodeMatches(pr, WebdavTags.displayname)) { dc.displayName = getElementContent(pr); } } } } return dc; }
From source file:com.fujitsu.dc.test.jersey.box.CollectionTest.java
/** * PROPPATCH????.// w w w . j ava 2s . co m * @param doc ??XML * @param resorce PROPPATCH?? * @param map ???KeyValue Key?Value???????? Valuenull???Key??????remove???? */ private void proppatchResponseTest(Element doc, String resorce, Map<String, String> map) { NodeList response = doc.getElementsByTagName("response"); assertEquals(1, response.getLength()); Element node = (Element) response.item(0); assertEquals(resorce, node.getElementsByTagName("href").item(0).getFirstChild().getNodeValue()); assertEquals("HTTP/1.1 200 OK", node.getElementsByTagName("status").item(0).getFirstChild().getNodeValue()); for (Iterator<String> it = map.keySet().iterator(); it.hasNext();) { Object key = it.next(); Object value = map.get(key); String textContext = null; NodeList tmp = node.getElementsByTagName("prop").item(0).getChildNodes(); for (int i = 0; i < tmp.getLength(); i++) { Node child = tmp.item(i); if (child instanceof Element) { Element childElement = (Element) child; if (childElement.getLocalName().equals(key)) { textContext = childElement.getTextContent(); break; } } } assertEquals(value, textContext); } }
From source file:com.fujitsu.dc.test.jersey.box.CollectionTest.java
/** * PROPPATCH????./* w ww .j a v a 2 s .c o m*/ * @param doc ??XML * @param resorce PROPPATCH?? * @param lapName prop?????? * @param map ???KeyValue Key?Value???????? Valuenull???Key??????remove???? */ private void proppatchClassResponseTest(Element doc, String resorce, String lapName, ArrayList<String> list) { NodeList response = doc.getElementsByTagName("response"); assertEquals(1, response.getLength()); Element node = (Element) response.item(0); assertEquals(resorce, node.getElementsByTagName("href").item(0).getFirstChild().getNodeValue()); assertEquals("HTTP/1.1 200 OK", node.getElementsByTagName("status").item(0).getFirstChild().getNodeValue()); String lapNameFlg = null; NodeList tmp = node.getElementsByTagName("prop").item(0).getChildNodes(); for (int i = 0; i < tmp.getLength(); i++) { Node child = tmp.item(i); if (child instanceof Element) { // ????? Element childElement = (Element) child; if (childElement.getLocalName().equals(lapName)) { lapNameFlg = "true"; // Path?? NodeList pTmp = childElement.getChildNodes(); for (int ii = 0; ii < pTmp.getLength(); ii++) { Node pChild = pTmp.item(ii); if (pChild instanceof Element) { Element pChildElement = (Element) pChild; NamedNodeMap attrs = pChildElement.getAttributes(); if (attrs != null) { String falg = null; for (Iterator<String> it = list.listIterator(); it.hasNext();) { Object key = it.next(); Object value = it.next(); Node attr = (Node) attrs.getNamedItem((String) key); if (attr != null && attr.getNodeValue().equals(value)) { falg = "true"; } } assertNotNull(falg); } } } } } } // ????? assertNotNull(lapNameFlg); }
From source file:iristk.flow.FlowCompiler.java
protected void printAction(Object action, Object parent, String exprContext) throws FlowCompilerException { if (action instanceof JAXBElement<?>) action = ((JAXBElement<?>) action).getValue(); printLocation(action);//ww w .j a v a2 s.c o m if (action instanceof iristk.xml.flow.Goto) { iristk.xml.flow.Goto gotoAction = (iristk.xml.flow.Goto) action; if (exprContext != null) throw new FlowCompilerException("<goto> not allowed in expression", gotoAction.sourceLocation().getLineNumber()); String stateVar = ""; if (gotoAction.getState() != null) { if (!stateExists(gotoAction.getState())) throw new FlowCompilerException("State " + gotoAction.getState() + " does not exist", gotoAction.sourceLocation().getLineNumber()); stateVar = varname("state"); code.println(stateClass(gotoAction.getState()) + " " + stateVar + " = " + newState(gotoAction.getState()) + ";"); printSetStateParameters(stateVar, getParameters(gotoAction.getOtherAttributes(), gotoAction.getContent(), gotoAction)); } else if (gotoAction.getExpr() != null) { stateVar = gotoAction.getExpr(); } else { throw new FlowCompilerException("Goto must either have a 'state' or 'expr' attribute", gotoAction.sourceLocation().getLineNumber()); } code.println( "flowThread.gotoState(" + stateVar + ", currentState, new FlowEventInfo(currentState, event, " + location(flowXml.getLocation(action)) + "));"); code.println("eventResult = EVENT_ABORTED;"); code.println("break EXECUTION;"); } else if (action instanceof iristk.xml.flow.Run) { iristk.xml.flow.Run runAction = (iristk.xml.flow.Run) action; if (exprContext != null) throw new FlowCompilerException("<run> not allowed in expression", runAction.sourceLocation().getLineNumber()); String stateVar = varname("state"); code.println(stateClass(runAction.getState()) + " " + stateVar + " = " + newState(runAction.getState()) + ";"); printSetStateParameters(stateVar, getParameters(runAction.getOtherAttributes(), runAction.getContent(), runAction)); code.println("FlowRunner.FlowThread " + stateVar + "Thread = flowThread.runState(" + stateVar + ", new FlowEventInfo(currentState, event, " + location(flowXml.getLocation(action)) + "));"); } else if (action instanceof iristk.xml.flow.Call) { iristk.xml.flow.Call callAction = (iristk.xml.flow.Call) action; if (exprContext != null) throw new FlowCompilerException("<call> not allowed in expression", callAction.sourceLocation().getLineNumber()); String stateVar = varname("state"); code.println(stateClass(callAction.getState()) + " " + stateVar + " = " + newState(callAction.getState()) + ";"); printSetStateParameters(stateVar, getParameters(callAction.getOtherAttributes(), callAction.getContent(), callAction)); code.println("if (!flowThread.callState(" + stateVar + ", new FlowEventInfo(currentState, event, " + location(flowXml.getLocation(action)) + "))) {"); code.println("eventResult = EVENT_ABORTED;"); code.println("break EXECUTION;"); code.println("}"); } else if (action instanceof iristk.xml.flow.Return) { iristk.xml.flow.Return returnAction = (iristk.xml.flow.Return) action; if (exprContext != null) throw new FlowCompilerException("<return> not allowed in expression", returnAction.sourceLocation().getLineNumber()); if (returnAction.getEvent() != null || returnAction.getCopy() != null) { String returnEvent = varname("returnEvent"); printInitEvent(returnEvent, returnAction.getCopy(), returnAction.getEvent(), getParameters(returnAction.getOtherAttributes(), returnAction.getContent(), returnAction)); //code.println("flowThread.raiseEvent(" + returnEvent + ", new FlowEventInfo(currentState, event, " + locationConstructor(flowReader.getLocation(action)) + ");"); code.println("flowThread.returnFromCall(this, " + returnEvent + ", new FlowEventInfo(currentState, event, " + location(flowXml.getLocation(action)) + "));"); } else { code.println("flowThread.returnFromCall(this, null, new FlowEventInfo(currentState, event, " + location(flowXml.getLocation(action)) + "));"); } code.println("eventResult = EVENT_ABORTED;"); code.println("break EXECUTION;"); } else if (action instanceof Reentry) { //code.println("flowThread.raiseEvent(new EntryEvent(), new FlowEventInfo(currentState, event, " + locationConstructor(flowReader.getLocation(action)) + ");"); Reentry reentryAction = (Reentry) action; if (exprContext != null) throw new FlowCompilerException("<reentry> not allowed in expression", reentryAction.sourceLocation().getLineNumber()); code.println("flowThread.reentryState(this, new FlowEventInfo(currentState, event, " + location(flowXml.getLocation(action)) + "));"); code.println("eventResult = EVENT_ABORTED;"); code.println("break EXECUTION;"); } else if (action instanceof iristk.xml.flow.Block) { //System.out.println("BLOCK " + currentLineNumber); iristk.xml.flow.Block blockAction = (iristk.xml.flow.Block) action; String cond = ""; if (blockAction.getCond() != null) { cond = "if (" + formatCondExpr(blockAction.getCond()) + ") "; } code.println(cond + "{"); printActions(blockAction.getContent(), action, exprContext); code.println("}"); } else if (action instanceof iristk.xml.flow.Wait) { iristk.xml.flow.Wait waitAction = (iristk.xml.flow.Wait) action; if (exprContext != null) throw new FlowCompilerException("<wait> not allowed in expression", waitAction.sourceLocation().getLineNumber()); String waitvar = varname("waitState"); code.println(DialogFlow.class.getName() + ".wait " + waitvar + " = new " + DialogFlow.class.getName() + ".wait();"); code.println(waitvar + ".setMsec(" + waitAction.getMsec() + ");"); code.println("if (!flowThread.callState(" + waitvar + ", new FlowEventInfo(currentState, event, " + location(flowXml.getLocation(action)) + "))) {"); code.println("eventResult = EVENT_ABORTED;"); code.println("break EXECUTION;"); code.println("}"); } else if (action instanceof Random) { Random randomAction = (Random) action; if (randomAction.getList() != null) { if (exprContext == null) { throw new FlowCompilerException("<random list=\"...\"/> only allowed in expressions", randomAction.sourceLocation().getLineNumber()); } code.println(exprContext + ".append(randstr(" + randomAction.getList() + "));"); } else { int tot = 0; for (Object child : randomAction.getAny()) { int inc = 1; if (child instanceof JAXBElement) child = ((JAXBElement) child).getValue(); if (child instanceof Block && ((Block) child).getWeight() != null) inc = ((Block) child).getWeight(); tot += inc; } int n = 0; int lastn = 0; String chosenVar = varname("chosen"); String matchingVar = varname("matching"); code.println("boolean " + chosenVar + " = false;"); code.println("boolean " + matchingVar + " = true;"); code.println("while (!" + chosenVar + " && " + matchingVar + ") {"); String randVar = varname("rand"); String model = "iristk.util.RandomList.RandomModel." + randomAction.getModel().toUpperCase(); code.println("int " + randVar + " = random(" + randomAction.hashCode() + ", " + tot + ", " + model + ");"); code.println(matchingVar + " = false;"); for (Object child : randomAction.getAny()) { if (n > 0) code.println("}"); int inc = 1; String cond = "true"; List<Object> actions = new ArrayList<>(); if (child instanceof JAXBElement) child = ((JAXBElement) child).getValue(); if (child instanceof Block) { Block block = (Block) child; if (block.getWeight() != null) inc = block.getWeight(); if (block.getCond() != null) cond = formatCondExpr(block.getCond()); actions.addAll(block.getContent()); } else { actions.add(child); } n += inc; code.println("if (" + cond + ") {"); code.println(matchingVar + " = true;"); code.println("if (" + randVar + " >= " + lastn + " && " + randVar + " < " + n + ") {"); code.println(chosenVar + " = true;"); printActions(actions, randomAction, exprContext); code.println("}"); lastn = n; } code.println("}"); code.println("}"); } } else if (action instanceof Select) { Select select = (Select) action; String label = varname("SELECTION"); code.println(label + ":"); code.println("{"); for (Object child : select.getAny()) { String cond = ""; List<Object> actions = new ArrayList<>(); if (child instanceof JAXBElement) child = ((JAXBElement) child).getValue(); if (child instanceof Block) { Block block = (Block) child; if (block.getCond() != null) cond = "if (" + formatCondExpr(block.getCond()) + ") "; actions.addAll(block.getContent()); } else { actions.add(child); } code.println(cond + "{"); printActions(actions, select, exprContext); code.println("break " + label + ";"); code.println("}"); if (cond.equals("")) break; } code.println("}"); } else if (action instanceof iristk.xml.flow.Raise) { iristk.xml.flow.Raise raiseAction = (iristk.xml.flow.Raise) action; if (exprContext != null) throw new FlowCompilerException("<raise> not allowed in expression", raiseAction.sourceLocation().getLineNumber()); String raiseEvent = varname("raiseEvent"); printInitEvent(raiseEvent, raiseAction.getCopy(), raiseAction.getEvent(), getParameters(raiseAction.getOtherAttributes(), raiseAction.getContent(), raiseAction)); if (raiseAction.getDelay() != null) { String delayedEvent = "flowThread.raiseEvent(" + raiseEvent + ", " + formatAttrExpr(raiseAction.getDelay()) + ", new FlowEventInfo(currentState, event, " + location(flowXml.getLocation(action)) + "))"; if (raiseAction.isForgetOnExit()) { code.println("forgetOnExit(" + delayedEvent + ");"); } else { code.println(delayedEvent + ";"); } } else { code.println("if (flowThread.raiseEvent(" + raiseEvent + ", new FlowEventInfo(currentState, event, " + location(flowXml.getLocation(action)) + ")) == State.EVENT_ABORTED) {"); code.println("eventResult = EVENT_ABORTED;"); code.println("break EXECUTION;"); code.println("}"); } } else if (action instanceof iristk.xml.flow.Send) { iristk.xml.flow.Send sendAction = (iristk.xml.flow.Send) action; if (exprContext != null) throw new FlowCompilerException("<send> not allowed in expression", sendAction.sourceLocation().getLineNumber()); String sendEvent = varname("sendEvent"); printInitEvent(sendEvent, sendAction.getCopy(), sendAction.getEvent(), getParameters(sendAction.getOtherAttributes(), sendAction.getContent(), sendAction)); if (sendAction.getDelay() != null) code.println("flowRunner.sendEvent(" + sendEvent + ", " + formatAttrExpr(sendAction.getDelay()) + ", new FlowEventInfo(currentState, event, " + location(flowXml.getLocation(action)) + "));"); else code.println("flowRunner.sendEvent(" + sendEvent + ", new FlowEventInfo(currentState, event, " + location(flowXml.getLocation(action)) + "));"); if (sendAction.getBindId() != null) { code.println(sendAction.getBindId() + " = " + sendEvent + ".getId();"); } } else if (action instanceof iristk.xml.flow.If) { iristk.xml.flow.If ifAction = (iristk.xml.flow.If) action; code.println("if (" + formatCondExpr(ifAction.getCond()) + ") {"); printActions(ifAction.getContent(), ifAction, exprContext); code.println("}"); } else if (action instanceof iristk.xml.flow.Else) { code.println("} else {"); } else if (action instanceof iristk.xml.flow.Elseif) { iristk.xml.flow.Elseif eifAction = (iristk.xml.flow.Elseif) action; code.println("} else if (" + formatCondExpr(eifAction.getCond()) + ") {"); } else if (action instanceof iristk.xml.flow.Propagate) { iristk.xml.flow.Propagate propagateAction = (iristk.xml.flow.Propagate) action; if (exprContext != null) throw new FlowCompilerException("<propagate> not allowed in expression", propagateAction.sourceLocation().getLineNumber()); code.println("eventResult = EVENT_IGNORED;"); code.println("break EXECUTION;"); } else if (action instanceof Repeat) { Repeat repeat = (Repeat) action; String handler = repeat.getHandler(); if (handler == null) { handler = varname("handler"); } code.println("{"); if (repeat.getTimes() != null) { code.println("RepeatHandler " + handler + " = new RepeatHandler(" + formatAttrExpr(repeat.getTimes()) + ");"); code.println("while (" + handler + ".getPosition() < " + handler + ".getLength()) {"); } else if (repeat.getWhile() != null) { code.println("RepeatHandler " + handler + " = new RepeatHandler();"); code.println("while (" + formatAttrExpr(repeat.getWhile()) + ") {"); } else if (repeat.getList() != null) { code.println("RepeatHandler " + handler + " = new RepeatHandler(" + formatAttrExpr(repeat.getList()) + ");"); code.println("while (" + handler + ".getPosition() < " + handler + ".getLength()) {"); } printActions(repeat.getContent(), repeat, exprContext); code.println(handler + ".next();"); code.println("}"); code.println("}"); } else if (action instanceof Var) { Var varAction = (Var) action; if (exprContext != null) throw new FlowCompilerException("<var> not allowed in expression", varAction.sourceLocation().getLineNumber()); code.println(variable((Var) action)); } else if (action instanceof iristk.xml.flow.Exec) { code.println(formatExec(((iristk.xml.flow.Exec) action).getValue().trim())); } else if (action instanceof iristk.xml.flow.Log) { code.println("log(" + createExpression(((iristk.xml.flow.Log) action).getContent(), action) + ");"); } else if (action instanceof iristk.xml.flow.Expr) { if (exprContext == null) { throw new FlowCompilerException("<expr> not allowed", currentLineNumber); } else { code.println(exprContext + ".append(" + formatExpr(((Expr) action).getValue()) + ");"); } } else if (action instanceof Element) {//perhaps implement variable name here Element elem = (Element) action; if (exprContext == null) { if (elem.getNamespaceURI().equals("iristk.flow") || elem.getPrefix() == null) { throw new FlowCompilerException("Bad element: <" + elem.getLocalName() + ">", currentLineNumber); } String stateVar = varname("state"); code.println(stateClass(elem) + " " + stateVar + " = " + newState(elem) + ";"); printSetStateParameters(stateVar, getParameters(elem)); code.println("if (!flowThread.callState(" + stateVar + ", new FlowEventInfo(currentState, event, " + location(flowXml.getLocation(parent)) + "))) {"); code.println("eventResult = EVENT_ABORTED;"); code.println("break EXECUTION;"); code.println("}"); } else { try { Object o = flowXml.unmarshal(elem); printAction(o, parent, exprContext); } catch (FlowCompilerException e) { code.println(exprContext + ".append(" + createExpression(elem) + ");"); } } } else if (action instanceof Text) { printAction(((Text) action).getTextContent(), parent, exprContext); } else if (action instanceof String) { String str = action.toString().trim(); if (str.length() > 0) { if (exprContext == null) { throw new FlowCompilerException("Text node not allowed: " + str, currentLineNumber); } else { code.println(exprContext + ".append(\"" + str.replaceAll("\\n", " ") + "\");"); } } } else { throw new FlowCompilerException("Could not parse " + action, currentLineNumber); } }