private String paramsToString(Map<String, ExpressionFormLine> params) { if ( params.isEmpty() ) { return ""; } ToStringVisitor stringVisitor = new ToStringVisitor(); StringBuilder strParams = new StringBuilder(); for ( ExpressionFormLine param : params.values() ) { strParams.append( ", " ).append( stringVisitor.buildString( param.getBinding(), param.getRootExpression() ) ); } return strParams.substring( 2 ); }
private String paramsToString(Map<String, ExpressionFormLine> params) { if ( params.isEmpty() ) { return ""; } ToStringVisitor stringVisitor = new ToStringVisitor(); StringBuilder strParams = new StringBuilder(); for ( ExpressionFormLine param : params.values() ) { strParams.append( ", " ).append( stringVisitor.buildString( param.getBinding(), param.getRootExpression() ) ); } return strParams.substring( 2 ); }
public ExpressionFormLine(ExpressionFormLine other) { CopyExpressionVisitor copier = new CopyExpressionVisitor(); if ( other.getParts().size() == 0 ) { return; } for ( ExpressionPart exp = copier.copy( other.getRootExpression() ); exp != null; exp = exp.getNext() ) { parts.add( exp ); } }
public ExpressionFormLine(ExpressionFormLine other) { CopyExpressionVisitor copier = new CopyExpressionVisitor(); if ( other.getParts().size() == 0 ) { return; } for ( ExpressionPart exp = copier.copy( other.getRootExpression() ); exp != null; exp = exp.getNext() ) { parts.add( exp ); } }
public String getText(boolean renderBindVariable) { return new ToStringVisitor().buildString( renderBindVariable ? getBinding() : null, getRootExpression() ); }
public String getText(boolean renderBindVariable) { return new ToStringVisitor().buildString( renderBindVariable ? getBinding() : null, getRootExpression() ); }
@Test public void testCopy() { ExpressionFormLine efl = new ExpressionFormLine(); FactPattern fp = new FactPattern(SuggestionCompletionEngine.TYPE_OBJECT); fp.setBoundName("$o"); efl.appendPart(new ExpressionVariable(fp)); ExpressionMethod em = new ExpressionMethod("aMethod", "aClass", "aType"); ExpressionFormLine param = new ExpressionFormLine(); param.appendPart(new ExpressionText("\"hello world\"")); em.putParam("hi", param); efl.appendPart(em); ExpressionCollectionIndex index = new ExpressionCollectionIndex("get", "aRetType", "aGeneric"); efl.appendPart(index); index = new ExpressionCollectionIndex("get2", "aRetType", "aGeneric"); efl.appendPart(index); System.out.println(efl.getText()); ExpressionFormLine copy = new ExpressionFormLine(efl); assertNotSame(efl, copy); assertEquals(efl.getText(), copy.getText()); for (ExpressionPart e1 = efl.getRootExpression(), e2 = copy.getRootExpression(); e1 != null; e1 = e1.getNext(), e2 = e2.getNext()) { assertNotSame(e1, e2); assertEquals(e1.getClass(), e2.getClass()); } }