diff --git a/datastructures-api/src/main/java/org/xbib/datastructures/api/Builder.java b/datastructures-api/src/main/java/org/xbib/datastructures/api/Builder.java index 9eac9e6..c1f3d8c 100644 --- a/datastructures-api/src/main/java/org/xbib/datastructures/api/Builder.java +++ b/datastructures-api/src/main/java/org/xbib/datastructures/api/Builder.java @@ -58,5 +58,7 @@ public interface Builder { Builder copy(Builder builder) throws IOException; + Builder copy(String string) throws IOException; + String build(); } diff --git a/datastructures-json-tiny/src/main/java/org/xbib/datastructures/json/tiny/JsonBuilder.java b/datastructures-json-tiny/src/main/java/org/xbib/datastructures/json/tiny/JsonBuilder.java index 7327479..b4b7cda 100644 --- a/datastructures-json-tiny/src/main/java/org/xbib/datastructures/json/tiny/JsonBuilder.java +++ b/datastructures-json-tiny/src/main/java/org/xbib/datastructures/json/tiny/JsonBuilder.java @@ -182,6 +182,15 @@ public class JsonBuilder implements Builder { return this; } + @Override + public Builder copy(String string) throws IOException { + if (state.structure == Structure.COLLECTION) { + beginArrayValue(); + } + appendable.append(string); + return this; + } + @Override public String build() { return appendable.toString(); diff --git a/datastructures-xml/src/main/java/org/xbib/datastructures/xml/XMLBuilder.java b/datastructures-xml/src/main/java/org/xbib/datastructures/xml/XMLBuilder.java index 8232183..44c55df 100644 --- a/datastructures-xml/src/main/java/org/xbib/datastructures/xml/XMLBuilder.java +++ b/datastructures-xml/src/main/java/org/xbib/datastructures/xml/XMLBuilder.java @@ -305,6 +305,12 @@ public class XMLBuilder implements Builder { return this; } + @Override + public Builder copy(String string) throws IOException { + appendable.append(string); + return this; + } + @Override public String build() { return appendable.toString(); diff --git a/datastructures-yaml-tiny/src/main/java/org/xbib/datastructures/yaml/tiny/YamlBuilder.java b/datastructures-yaml-tiny/src/main/java/org/xbib/datastructures/yaml/tiny/YamlBuilder.java index cc6eefe..ebc8abe 100644 --- a/datastructures-yaml-tiny/src/main/java/org/xbib/datastructures/yaml/tiny/YamlBuilder.java +++ b/datastructures-yaml-tiny/src/main/java/org/xbib/datastructures/yaml/tiny/YamlBuilder.java @@ -175,6 +175,12 @@ public class YamlBuilder implements Builder { return this; } + @Override + public Builder copy(String string) throws IOException { + buildValue(string); + return this; + } + @Override public String build() { return appendable.toString();