package com.elong.pb.newdda.client.router.result.router;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;

/**
 * Created by zhangyong on 2016/8/14.
 */
public class SqlBuilderForVisitor implements Appendable {

    private final static Logger logger = LoggerFactory.getLogger(SqlBuilderForVisitor.class);

    @Override
    public Appendable append(CharSequence csq) throws IOException {
        return null;
    }

    @Override
    public Appendable append(CharSequence csq, int start, int end) throws IOException {
        throw new UnsupportedOperationException();
    }

    @Override
    public Appendable append(char c) throws IOException {
        return null;
    }

}

@@ -51,16 +51,54 @@
 outer;%0A%0A
+import com.google.common.base.Joiner;%0A
 import o
@@ -174,16 +174,74 @@
 ception;
+%0Aimport java.util.Collection;%0Aimport java.util.LinkedList;
 %0A%0A/**%0A *
@@ -434,16 +434,271 @@
 lass);%0A%0A
+    private final Collection%3CObject%3E segments = new LinkedList%3CObject%3E();%0A%0A    private StringBuilder currentSegment;%0A%0A    public SqlBuilderForVisitor() %7B%0A        this.currentSegment = new StringBuilder();%0A        this.segments.add(currentSegment);%0A    %7D%0A%0A
     @Ove
@@ -745,19 +745,19 @@
 equence 
-c
 sq
+l
 ) throws
@@ -763,32 +763,68 @@
 s IOException %7B%0A
+        currentSegment.append(sql);%0A
         return n
@@ -814,36 +814,36 @@
 %0A        return 
-null
+this
 ;%0A    %7D%0A%0A    @Ov
@@ -1079,20 +1079,990 @@
     
-return null;
+currentSegment.append(c);%0A        return this;%0A    %7D%0A%0A    @Override%0A    public String toString() %7B%0A        StringBuilder result = new StringBuilder();%0A        for (Object each : segments) %7B%0A            if (each instanceof StringToken) %7B%0A                result.append(((StringToken) each).toToken());%0A            %7D else %7B%0A                result.append(each.toString());%0A            %7D%0A        %7D%0A        return result.toString();%0A    %7D%0A%0A    /**%0A     * %E7%94%9F%E6%88%90SQL%E8%AF%AD%E5%8F%A5.%0A     */%0A    public String toSQL() %7B%0A        StringBuilder result = new StringBuilder();%0A        for (Object each : segments) %7B%0A            result.append(each.toString());%0A        %7D%0A        return result.toString();%0A    %7D%0A%0A    private class StringToken %7B%0A%0A        private String value;%0A%0A        public String toToken() %7B%0A            return null == value ? %22%22 : Joiner.on(%22%22).join(%22%5BToken(%22, value, %22)%5D%22);%0A        %7D%0A%0A        @Override%0A        public String toString() %7B%0A            return null == value ? %22%22 : value;%0A        %7D
 %0A   

append char