@Override public String toString() { StringBuilder b = new StringBuilder(); b.append(name).append("("); if (expression != null) { b.append(expression.toString()); if (offset != null) { b.append(", ").append(offset.toString()); if (defaultValue != null) { b.append(", ").append(defaultValue.toString()); } } } else if (isAllColumns()) { b.append("*"); } b.append(") OVER ("); toStringPartitionBy(b); toStringOrderByElements(b); b.append(")"); return b.toString(); }
public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append("("); buffer.append(opToString(op)); buffer.append(", "); buffer.append(left.toString()); buffer.append(", "); buffer.append(right.toString()); buffer.append(")"); return buffer.toString(); }
public String toString() { StringBuilder b = new StringBuilder(); if (startExpression != null) { b.append(" START WITH ").append(startExpression.toString()); } b.append(" CONNECT BY "); if (isNoCycle()) { b.append("NOCYCLE "); } b.append(connectExpression.toString()); return b.toString(); }
@Override public StringBuilder toString(StringBuilder sb) { fRangeExp.toString(sb); sb.append("->").append(this.name()).append("("); if (!fElemVarDecls.isEmpty()) { fElemVarDecls.toString(sb); sb.append(" | "); } fQueryExp.toString(sb); return sb.append(")"); }
public String toString() { StringBuilder b = new StringBuilder(); b.append('('); if (left != null) { b.append(left.toString()); } if (operator != null) { b.append(operator.toString()); if (right != null) { b.append(right.toString()); } } b.append(')'); return b.toString(); }
@Test public void testParams_NullHandling_CAY847() { Expression e = ExpressionFactory.exp("X = $x"); e = e.params(Collections.singletonMap("x", null)); assertEquals("X = null", e.toString()); }
@Test public void testParams_Positional_Repeating() { Expression e = ExpressionFactory.exp("a = $a or x = $x and y = $x"); Expression ep = e.paramsArray("A", 5); assertNotSame(e, ep); assertEquals("(a = \"A\") or ((x = 5) and (y = 5))", ep.toString()); }
public String toString() { StringBuffer result = new StringBuffer(); result.append("atomize["); result.append(expression.toString()); result.append("]"); return result.toString(); }
public void display(int indent) { indent(indent); Util.println("ForEach"); indent(indent + IndentIncrement); Util.println("select " + _select.toString()); displayContents(indent + IndentIncrement); }
public String toString() { if (exp != null) { return exp.toString(); } else { return "No Expression Defined"; } }
@Override public boolean visit(MethodInvocation node) { String mName = node.getName().getFullyQualifiedName().toString(); Expression e = node.getExpression(); String typName = ""; if (e instanceof StringLiteral) { typName = "string"; } else if (e instanceof FieldAccess) { FieldAccess field = (FieldAccess) e; typName = field.getName().getFullyQualifiedName(); } else if (e instanceof Name) { typName = ((Name) e).getFullyQualifiedName(); if (varTypMap.containsKey(typName)) { typName = varTypMap.get(typName); } } else { if (e != null) { typName = e.toString(); if (typName.contains(".")) typName = typName.substring(0, typName.indexOf('.', 0)); if (varTypMap.containsKey(typName)) typName = varTypMap.get(typName); } } String key = typName + "->" + mName; if (freqRecord.containsKey(key)) { freqRecord.put(key, freqRecord.get(key) + 1); } else { freqRecord.put(key, 1); } return super.visit(node); }
public static boolean visit( Like obj, BooleanJunction<BooleanJunction> junction, QueryBuilder queryBuilder) throws TranslatorException { LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Parsing LIKE criteria."); // $NON-NLS-1$ Expression lhs = obj.getLeftExpression(); Expression rhs = obj.getRightExpression(); Column c = null; Expression literalExp = null; if (lhs instanceof ColumnReference) { c = ((ColumnReference) lhs).getMetadataObject(); literalExp = rhs; } else { c = ((ColumnReference) rhs).getMetadataObject(); literalExp = lhs; } String value = null; if (literalExp instanceof Literal) { value = (String) escapeReservedChars(((Literal) literalExp).getValue()); createLikeQuery( c, value.replaceAll("%", ""), junction, queryBuilder); // "*" //$NON-NLS-1$ //$NON-NLS-2$ } else { final String msg = ObjectPlugin.Util.getString( "LuceneSearch.Unsupported_expression", //$NON-NLS-1$ new Object[] {literalExp.toString(), "LIKE"}); // $NON-NLS-1$ throw new TranslatorException(msg); } return true; }
public String toString() { StringBuilder result = new StringBuilder(); result.append(expression.toString()); result.append(" castable as "); result.append(Type.getTypeName(requiredType)); return result.toString(); }
public String toString() { StringBuffer result = new StringBuffer(); result.append(expression.toString()); for (Iterator i = predicates.iterator(); i.hasNext(); ) { result.append(((Expression) i.next()).toString()); } return result.toString(); }
// Extract all quotes from the quote bundle which cause the given // expression to equate to true. If there is no expression (string is null or // empty) then extract all the quotes. private List extractQuotesUsingRule(String filterExpression, EODQuoteBundle quoteBundle) { // If there is no rule, then just return all quotes if (filterExpression == null || filterExpression.length() == 0) return extractAllQuotes(quoteBundle); // First parse the expression Expression expression = null; try { expression = Parser.parse(filterExpressionString); } catch (ExpressionException e) { // We should have already checked the string for errors before here assert false; } // Add symbols to list when expression proves true ArrayList quotes = new ArrayList(); Iterator iterator = quoteBundle.iterator(); TradingDate lastDate = quoteBundle.getLastDate(); try { // Traverse all symbols on all dates while (iterator.hasNext()) { Quote quote = (Quote) iterator.next(); Symbol symbol = quote.getSymbol(); TradingDate date = quote.getDate(); int dateOffset = 0; try { dateOffset = quoteBundle.dateToOffset(date); } catch (WeekendDateException e) { assert false; } if (!singleDate || (lastDate.equals(quote.getDate()))) { if (expression.evaluate(new Variables(), quoteBundle, symbol, dateOffset) >= Expression.TRUE_LEVEL) quotes.add(quote); } } return quotes; } catch (EvaluationException e) { // Tell user expression didnt evaluate properly JOptionPane.showInternalMessageDialog( DesktopManager.getDesktop(), e.getReason() + ": " + expression.toString(), Locale.getString("ERROR_EVALUATION_EQUATION"), JOptionPane.ERROR_MESSAGE); // delete erroneous expression expression = null; // If the expression didn't evaluate then just return all the quotes return extractAllQuotes(quoteBundle); } }
public void toString(StringBuffer buffer, String tab) { buffer.append(tab).append("<ConditionalExpression"); // $NON-NLS-1$ appendInterval(buffer); buffer.append(" operatorType='" + operatorType + "'"); buffer.append(">\n"); // $NON-NLS-1$ buffer.append(TAB).append(tab).append("<Condition>\n"); // $NON-NLS-1$ condition.toString(buffer, TAB + TAB + tab); buffer .append("\n") .append(TAB) .append(tab) .append("</Condition>\n"); // $NON-NLS-1$ //$NON-NLS-2$ if (operatorType == OP_TERNARY) { if (ifTrue != null) { buffer.append(TAB).append(tab).append("<IfTrue>\n"); // $NON-NLS-1$ ifTrue.toString(buffer, TAB + TAB + tab); buffer .append("\n") .append(TAB) .append(tab) // $NON-NLS-1$ .append("</IfTrue>\n"); // $NON-NLS-1$ } if (ifFalse != null) { buffer.append(TAB).append(tab).append("<IfFalse>\n"); // $NON-NLS-1$ ifFalse.toString(buffer, TAB + TAB + tab); buffer .append("\n") .append(TAB) .append(tab) // $NON-NLS-1$ .append("</IfFalse>\n"); // $NON-NLS-1$ } } else if (operatorType == OP_COALESCE) { buffer.append(TAB).append(tab).append("<IfNull>\n"); // $NON-NLS-1$ ifTrue.toString(buffer, TAB + TAB + tab); buffer .append("\n") .append(TAB) .append(tab) .append("</IfNull>\n"); // $NON-NLS-1$ //$NON-NLS-2$ } buffer.append(tab).append("</ConditionalExpression>"); // $NON-NLS-1$ }
/** * Returns a string representation of the simple expression. * * @return the string representation. */ public String toString() { if (children.isEmpty()) return expr.toString(); StringBuilder str = new StringBuilder(80); str.append("("); str.append(cop.get(sop).toString()); str.append(", "); str.append(Tools.listToString(children, ", ")); str.append(")"); return str.toString(); }
public void toString(StringBuffer buffer, String tab) { buffer.append(tab).append("<CastExpression"); // $NON-NLS-1$ appendInterval(buffer); buffer .append(" castType='") .append(getCastType(castingType)) .append("'>\n"); // $NON-NLS-1$ //$NON-NLS-2$ expression.toString(buffer, TAB + tab); buffer.append("\n").append(tab).append("</CastExpression>"); // $NON-NLS-1$ //$NON-NLS-2$ }
@Override public String toString() { StringBuffer result = new StringBuffer("("); for (Expression e : this.disj) result.append(e.toString()).append("+"); result.deleteCharAt(result.length() - 1); result.append(")"); return result.toString(); }
@Override public String toString() { StringBuilder sb = new StringBuilder("print "); for (Expression e : expressions) { sb.append(e.toString()).append(", "); } sb.append(";"); return sb.toString(); }
@Override public String toString() { return "for " + initialAssign.getLocation().getId() + " = " + initialAssign.getExpression().toString() + ", " + condition.toString() + " " + block.toString(); }
@Override public void toString(StringBuffer buffer, String tab) { buffer.append(tab).append("<ContinueStatement"); // $NON-NLS-1$ appendInterval(buffer); buffer.append(">\n"); // $NON-NLS-1$ if (expression != null) { expression.toString(buffer, TAB + tab); buffer.append("\n"); // $NON-NLS-1$ } buffer.append(tab).append("</ContinueStatement>"); // $NON-NLS-1$ }
@Test public void test_infix() throws Exception { Expression exp = new InfixExpression("( ( a + b - c ) * d / e ) ^ 1 ^ 2 ^ 3 % 4 ^ 5"); assertEquals("((a + b - c) * d / e) ^ 1 ^ 2 ^ 3 % 4 ^ 5", exp.toString()); for (int i = 0; i < n; i++) { int a = r.nextInt(), b = r.nextInt(), c = r.nextInt(), d = r.nextInt(), e = r.nextInt(); fillTable(new char[] {'a', 'b', 'c', 'd', 'e'}, new int[] {a, b, c, d, e}); exp.setVarTable(varTable); int expected = (a + b - c) * d / e % (1 << 10); assertEquals(expected, exp.evaluate()); } }
public void toString(StringBuffer buffer, String tab) { buffer.append(tab).append("<Assignment"); // $NON-NLS-1$ appendInterval(buffer); buffer .append(" operator='") .append(getXmlStringValue(getOperator(operator))) .append("'>\n"); // $NON-NLS-1$ //$NON-NLS-2$ leftHandSide.toString(buffer, TAB + tab); buffer.append("\n").append(TAB).append(tab).append("<Value>\n"); // $NON-NLS-1$ //$NON-NLS-2$ rightHandSide.toString(buffer, TAB + TAB + tab); buffer.append("\n").append(TAB).append(tab).append("</Value>\n"); // $NON-NLS-1$ //$NON-NLS-2$ buffer.append(tab).append("</Assignment>"); // $NON-NLS-1$ }
/* * Visit the AST expression and get the ParseTree Expression. * This is used by the individual visits when parsing a tree. * It passes to the top method (createExpression), which can * handle the InvalidExpressionException. * * If any visit doesn't return an expression, then an invalid * expression exception will be thrown to indicate this. If the * incoming expression is <code>null</code>, then return of <code>null</code> is ok because * this would be for an optional expression which didn't exist. * * @return The new ParseTree Expression or <code>null</code> if incoming expression was null. * * @see createExpression(org.eclipse.jdt.core.dom.Expression) * @exception InvalidExpressionException * @since 1.0.0 */ protected final PTExpression perform(Expression astExpression) { if (astExpression != null) { expression = null; astExpression.accept(this); if (expression == null) throw new InvalidExpressionException( MessageFormat.format( WorkbenchUtilityMessages.ParseTreeCreationFromAST_ExpressionTooComplicated_EXC_, new Object[] {astExpression.toString()})); return expression; } else return null; // This is ok. It means an optional expression was being processed and the // expression didn't exist. }
/** * Process the AST Expression and return a PTExpression. If any part was invalid, then only an * PTInvalidExpression will be returned. * * @param astExpression * @return The PTExpression. * @since 1.0.0 */ public final PTExpression createExpression(Expression astExpression) { try { return perform(astExpression); } catch (InvalidExpressionException e) { // Create a msg that is formed of the exception message and the full init string. String msg = MessageFormat.format( WorkbenchUtilityMessages.ParseTreeCreationFromAST_0, new Object[] {e.getLocalizedMessage(), astExpression.toString()}); PTInvalidExpression exp = InstantiationFactory.eINSTANCE.createPTInvalidExpression(); exp.setMessage(msg); return exp; } }
@Test public void testParams_Map_Partial_Prune() { Expression e = ExpressionFactory.exp("a = $a or x = $x"); @SuppressWarnings("serial") Expression ep = e.params( new HashMap<String, Object>() { { put("a", "A"); } }); assertNotSame(e, ep); assertEquals("(a = \"A\")", ep.toString()); }
/** * template method * * @param leftHandSide left hand side * @param rightHandSide right hand side * @return results */ protected String[] convert( Path<?> leftHandSide, Expression<?> rightHandSide, QueryMetadata metadata) { if (rightHandSide instanceof Operation) { Operation<?> operation = (Operation<?>) rightHandSide; if (operation.getOperator() == LuceneOps.PHRASE) { return Iterables.toArray(WS_SPLITTER.split(operation.getArg(0).toString()), String.class); } else if (operation.getOperator() == LuceneOps.TERM) { return new String[] {operation.getArg(0).toString()}; } else { throw new IllegalArgumentException(rightHandSide.toString()); } } else if (rightHandSide instanceof ParamExpression<?>) { Object value = metadata.getParams().get(rightHandSide); if (value == null) { throw new ParamNotSetException((ParamExpression<?>) rightHandSide); } return convert(leftHandSide, value); } else if (rightHandSide instanceof Constant<?>) { return convert(leftHandSide, ((Constant<?>) rightHandSide).getConstant()); } else { throw new IllegalArgumentException(rightHandSide.toString()); } }
public String toString() { StringBuilder buf = new StringBuilder(); buf.append("["); boolean first = true; for (Expression each : this.exprs) { if (!first) { buf.append(", "); } if (each != null) { buf.append(each.toString()); } } buf.append("]"); return buf.toString(); }
public String toString() { StringBuffer sb = new StringBuffer("Connector["); boolean addConn = false; String conn = " AND "; if (op == OR_CONN) { conn = " OR "; } for (Expression e : exp) { if (addConn) { sb.append(conn); } sb.append(e.toString()); addConn = true; } sb.append("]"); return sb.toString(); }