List of usage examples for java.util Stack toString
public String toString()
From source file:FunctionParser.MathExp2SPARQL.java
private String prefixToInfix(Stack<String> stack, Stack<String> infixstack) { String s;/*from w w w. ja va 2 s . co m*/ while (!stack.isEmpty()) { s = stack.pop(); if (opmap.containsValue(s)) { String pop1 = infixstack.pop(); String pop2 = infixstack.pop(); //System.out.println(pop1 + s +pop2); if (s.equals("==")) s = "="; String nelem = "( " + pop1 + " " + s + " " + pop2 + " )"; infixstack.push(nelem); } else if (s.equals("CEIL")) { String nelem = "CEIL" + infixstack.pop(); infixstack.push(nelem); } else { infixstack.add(s); } } return infixstack.toString(); }
From source file:com.taobao.tdhs.jdbc.sqlparser.ParseSQL.java
public boolean checkRealEqual(Stack<String> stack) { logger.debug("checkRealEqual:" + stack.toString()); String tmp_str = ""; @SuppressWarnings("unchecked") Stack<String> tmpStack = (Stack<String>) stack.clone(); while (tmpStack.isEmpty() == false) { tmp_str = tmpStack.pop() + tmp_str; }// w ww . j ava2 s . c o m //?',?,?,value boolean result = !checkSpecialStr(tmp_str, "'"); logger.debug(result ? "=?" : "?=?"); return result; }
From source file:com.taobao.tdhs.jdbc.sqlparser.ParseSQL.java
private boolean checkSpecialStr(String sqlstring, String searchStr) { //????searchStr Stack<String> stack = new Stack<String>(); boolean exist_danyinhao = false; for (int i = 0; i < sqlstring.length(); i++) { ////from w w w. j av a2 s . co m if (sqlstring.substring(i, i + 1).equals("'") == false) { stack.push(sqlstring.substring(i, i + 1)); } //' if (sqlstring.substring(i, i + 1).equals("'")) { //?\,?,\,,?? int count = 0; int k = i; boolean real_danyinhao; while (k - 1 >= 0 && sqlstring.substring(k - 1, k).equals("\\") == true) { k--; count++; } //System.out.println("\\:"+count); if (count % 2 == 0) { //?? real_danyinhao = true; } else { //???,value real_danyinhao = false; stack.push(sqlstring.substring(i, i + 1)); } if (real_danyinhao == true) { if (exist_danyinhao == false) { exist_danyinhao = true; stack.push(sqlstring.substring(i, i + 1)); } else { boolean find_real_danyinhao = false; while (find_real_danyinhao == false) { while (!stack.pop().equals("'")) { ; } //???,??\ if (stack.isEmpty() == false && stack.peek().equals("\\")) { //?,??? count = 0; while (stack.peek().equals("\\")) { stack.pop(); count++; } if (count % 2 == 0) { //? find_real_danyinhao = true; } else { //? find_real_danyinhao = false; } } else { // find_real_danyinhao = true; } } exist_danyinhao = false; } } } } //end for logger.debug(stack.toString()); if (stack.isEmpty() == false && stack.search(searchStr) > -1) { stack.clear(); return true; } else { return false; } }
From source file:org.kepler.objectmanager.library.LibraryGenerator.java
public CompositeEntity generate(Workspace workspace, LibIndex libIndex) { CompositeEntity _root = null;/*from w w w.ja v a 2s. c o m*/ try { _root = (CompositeEntity) new EntityLibrary(workspace); _root.setName("kepler actor library"); } catch (ptolemy.kernel.util.NameDuplicationException nde) { // do nothing, just leave the name blank System.out.println("the name 'kepler actor library' is already in use"); } catch (IllegalActionException e) { e.printStackTrace(); } if (_root == null) return null; Stack<LibItem> s = new Stack<LibItem>(); Stack<NamedObj> treeObjs = new Stack<NamedObj>(); treeObjs.push(_root); Vector<LibItem> items = libIndex.getItems(); System.gc(); for (LibItem item : items) { // if (isDebugging) log.debug(item.debugString()); try { // if (isDebugging) log.debug("s.size(): " + s.size()); // if (isDebugging) log.debug("treeObjs.size(): " + // treeObjs.size()); while (s.size() > 0) { int lastRight = s.elementAt(s.size() - 1).getRight(); int thisRight = item.getRight(); if (lastRight < thisRight) { // if (isDebugging) // log.debug(s.elementAt(s.size()-1).getRight() + " < " // + item.getRight()); s.pop(); treeObjs.pop(); } else { break; } } if (isDebugging) log.debug(s.toString()); if (isDebugging) log.debug(treeObjs.toString()); NamedObj parent = treeObjs.elementAt(treeObjs.size() - 1); if (isDebugging) log.debug(parent.getName() + " " + parent.getClass().getName()); if (parent instanceof CompositeEntity) { ComponentEntity current = _libMan.createAndAddTreeItem((CompositeEntity) parent, item); if (isDebugging) { String indent = " "; for (int i = 0; i < treeObjs.size(); i++) { indent += "+-"; } log.debug(indent + " " + current.getName() + " " + current.getClass().getName()); } s.push(item); treeObjs.push(current); } else { log.error("Parent is something other than CompositeEntity! Should never happen."); // Try refreshing the order // Try complete reubild return _root; } } catch (Exception e) { e.printStackTrace(); } } System.gc(); return _root; }