@@ -143,39 +143,59 @@ public boolean hasLinesClause() {
143143
144144 public StringBuilder appendTo (StringBuilder builder ) {
145145 builder .append ("INTO " ).append (type );
146+ appendFileName (builder );
147+ appendCharacterSet (builder );
148+ appendFieldsClause (builder );
149+ appendLinesClause (builder );
150+ return builder ;
151+ }
152+
153+ private void appendFileName (StringBuilder builder ) {
146154 if (fileName != null ) {
147155 builder .append (" " ).append (fileName );
148156 }
157+ }
158+
159+ private void appendCharacterSet (StringBuilder builder ) {
149160 if (characterSet != null ) {
150161 builder .append (" CHARACTER SET " ).append (characterSet );
151162 }
152- if (hasFieldsClause ()) {
153- builder .append (" " )
154- .append (fieldsKeyword != null ? fieldsKeyword : FieldsKeyword .FIELDS );
155- if (fieldsTerminatedBy != null ) {
156- builder .append (" TERMINATED BY " ).append (fieldsTerminatedBy );
157- }
158- if (fieldsEnclosedBy != null ) {
159- builder .append (" " );
160- if (fieldsOptionallyEnclosed ) {
161- builder .append ("OPTIONALLY " );
162- }
163- builder .append ("ENCLOSED BY " ).append (fieldsEnclosedBy );
164- }
165- if (fieldsEscapedBy != null ) {
166- builder .append (" ESCAPED BY " ).append (fieldsEscapedBy );
167- }
163+ }
164+
165+ private void appendFieldsClause (StringBuilder builder ) {
166+ if (!hasFieldsClause ()) {
167+ return ;
168168 }
169- if (hasLinesClause ()) {
170- builder .append (" LINES" );
171- if (linesStartingBy != null ) {
172- builder .append (" STARTING BY " ).append (linesStartingBy );
173- }
174- if (linesTerminatedBy != null ) {
175- builder .append (" TERMINATED BY " ).append (linesTerminatedBy );
169+
170+ builder .append (" " ).append (fieldsKeyword != null ? fieldsKeyword : FieldsKeyword .FIELDS );
171+
172+ if (fieldsTerminatedBy != null ) {
173+ builder .append (" TERMINATED BY " ).append (fieldsTerminatedBy );
174+ }
175+ if (fieldsEnclosedBy != null ) {
176+ builder .append (" " );
177+ if (fieldsOptionallyEnclosed ) {
178+ builder .append ("OPTIONALLY " );
176179 }
180+ builder .append ("ENCLOSED BY " ).append (fieldsEnclosedBy );
181+ }
182+ if (fieldsEscapedBy != null ) {
183+ builder .append (" ESCAPED BY " ).append (fieldsEscapedBy );
184+ }
185+ }
186+
187+ private void appendLinesClause (StringBuilder builder ) {
188+ if (!hasLinesClause ()) {
189+ return ;
190+ }
191+
192+ builder .append (" LINES" );
193+ if (linesStartingBy != null ) {
194+ builder .append (" STARTING BY " ).append (linesStartingBy );
195+ }
196+ if (linesTerminatedBy != null ) {
197+ builder .append (" TERMINATED BY " ).append (linesTerminatedBy );
177198 }
178- return builder ;
179199 }
180200
181201 @ Override
0 commit comments