Skip to content

Commit

Permalink
Added writeNonBreaking() method to prevent breaking at non-white-space
Browse files Browse the repository at this point in the history
character
  • Loading branch information
sangupta committed Sep 2, 2016
1 parent 38e9c36 commit daa2f23
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/main/java/com/sangupta/jerry/io/IndentedStringWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* writer can resize depending as we add more strings to it.
*
* @author sangupta
*
*
*/
public class IndentedStringWriter {

Expand Down Expand Up @@ -118,6 +118,23 @@ public void write(String str) {
}
}

/**
* Write the given string values without breaking the strings unless there
* is no other way.
*
* @param strings
*/
public void writeNonBreaking(String... strings) {
StringBuilder builder = new StringBuilder();
for(String str : strings) {
if(str != null) {
builder.append(str);
}
}

this.write(builder.toString());
}

private void writeInternal(String str) {
if(AssertUtils.isEmpty(str)) {
return;
Expand Down

0 comments on commit daa2f23

Please sign in to comment.