List of usage examples for org.apache.ibatis.parsing XNode getStringBody
public String getStringBody()
From source file:com.ibatis.sqlmap.engine.builder.SimpleSqlSource.java
License:Apache License
private void parseNodes(XNode node) { StringBuilder sqlBuffer = new StringBuilder(sql); NodeList children = node.getNode().getChildNodes(); for (int i = 0; i < children.getLength(); i++) { XNode child = node.newXNode(children.item(i)); String nodeName = child.getNode().getNodeName(); if (child.getNode().getNodeType() == Node.CDATA_SECTION_NODE || child.getNode().getNodeType() == Node.TEXT_NODE) { String data = child.getStringBody(); InlineParameterMapParser inlineParameterMapParser = new InlineParameterMapParser(configuration); SqlText sqlText = inlineParameterMapParser.parseInlineParameterMap(data); sqlText.setPostParseRequired(false); parameterMappings.addAll(sqlText.getParameterMappings()); sqlBuffer.append(sqlText.getText()); } else if ("include".equals(nodeName)) { String refid = child.getStringAttribute("refid"); XNode includeNode = configParser.getSqlFragment(refid); if (includeNode == null) { String nsrefid = mapParser.applyNamespace(refid); includeNode = configParser.getSqlFragment(nsrefid); if (includeNode == null) { throw new RuntimeException( "Could not find SQL statement to include with refid '" + refid + "'"); }/*from w w w.j a v a2 s .c om*/ } parseNodes(includeNode); } } sql = sqlBuffer.toString(); }
From source file:das.orm.ORMFacade.java
License:Apache License
public String getSQLFragment(String ID) throws IOException { String mthdName = "getSQLFragment"; log.trace(mthdName);/*from w ww . j a v a 2s .c om*/ Configuration conf = getConfiguration(); if (conf != null) { //log.debug("conf != null"); Map<String, XNode> sqlNodes = conf.getSqlFragments(); if (sqlNodes != null) { //log.debug("sqlNodes != null"); /* for (Map.Entry<String, XNode> es : sqlNodes.entrySet()) { XNode node = es.getValue(); log.debug("node.key="+es.getKey()+", node.name="+node.getName() +", node.path="+node.getPath()+", node.body="+node.getStringBody() +", node.toString="+node.toString() +", node.Attribute="+node.getStringAttribute("lang")); } */ /* node.key=fxapp01.dao.filter.FilterMapper.And, node.name=sql, node.path=mapper/sql, node.body=({0}) and ({1}), node.toString=<sql databaseId="oracle" id="And">({0}) and ({1})</sql> node.key=And, node.name=sql, node.path=mapper/sql, node.body=({0}) and ({1}), node.toString=<sql databaseId="oracle" id="And">({0}) and ({1})</sql> */ XNode node = sqlNodes.get(ID); if (node != null) { //log.debug("node != null"); //evalString(String expression) //getStringBody() //toString() return node.getStringBody(); } else { //log.debug("node == null"); return null; } } else { throw new ENullArgument(mthdName, "getSqlFragments()"); } } else { throw new ENullArgument(mthdName, "getConfiguration()"); } }